diff -r 6fdb332e0aa9 ide.branding/options.api/src/org/netbeans/modules/options/export/Bundle_nb.properties
--- a/ide.branding/options.api/src/org/netbeans/modules/options/export/Bundle_nb.properties Thu Mar 14 12:38:42 2013 +0100
+++ b/ide.branding/options.api/src/org/netbeans/modules/options/export/Bundle_nb.properties Thu Mar 14 12:53:02 2013 +0100
@@ -2,3 +2,5 @@
ImportConfirmationPanel.cbRestart.text=&Restart IDE now
(without restart imported settings may not work)
ImportConfirmationPanel.cbRestart.AD=Decide whether restart IDE now or later
ImportConfirmationPanel.cbRestart.AN=Restart IDE now?
+OPT_RestartAfterImport=true
+
diff -r 6fdb332e0aa9 options.api/apichanges.xml
--- a/options.api/apichanges.xml Thu Mar 14 12:38:42 2013 +0100
+++ b/options.api/apichanges.xml Thu Mar 14 12:53:02 2013 +0100
@@ -75,6 +75,27 @@
+
+
+ Should Import Require Restart?
+
+
+
+
+ Compared to previous versions, the default changed - now
+ the restart is not needed. Applications can change that by using
+
+ this branding API and specifying false
as the value
+ of associated key.
+
+
+ Should an import of settings require a restart? Some applications
+ need that, some don't. There is a
+
+ branding API to control such behavior now.
+
+
+
API to control whether the options window should be modal or not when opened
diff -r 6fdb332e0aa9 options.api/arch.xml
--- a/options.api/arch.xml Thu Mar 14 12:38:42 2013 +0100
+++ b/options.api/arch.xml Thu Mar 14 12:53:02 2013 +0100
@@ -1144,6 +1144,13 @@
can have the following structure
filePattern1#keyPattern1#|filePattern2|filePattern3#keyPattern3
.
+
+ By default importing settings (as described by OptionsExport
+ API does not require restart. Some systems may however support complex
+ modifications to the installation structure. Then they should brand the
+ OPT_RestartAfterImport
to true
. NetBeans IDE
+ does require restart after settings import.
+
diff -r 6fdb332e0aa9 options.api/manifest.mf
--- a/options.api/manifest.mf Thu Mar 14 12:38:42 2013 +0100
+++ b/options.api/manifest.mf Thu Mar 14 12:53:02 2013 +0100
@@ -2,6 +2,6 @@
OpenIDE-Module: org.netbeans.modules.options.api/1
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/options/Bundle.properties
OpenIDE-Module-Layer: org/netbeans/modules/options/resources/mf-layer.xml
-OpenIDE-Module-Specification-Version: 1.33
+OpenIDE-Module-Specification-Version: 1.34
AutoUpdate-Show-In-Client: false
AutoUpdate-Essential-Module: true
diff -r 6fdb332e0aa9 options.api/src/org/netbeans/modules/options/export/OptionsChooserPanel.java
--- a/options.api/src/org/netbeans/modules/options/export/OptionsChooserPanel.java Thu Mar 14 12:38:42 2013 +0100
+++ b/options.api/src/org/netbeans/modules/options/export/OptionsChooserPanel.java Thu Mar 14 12:53:02 2013 +0100
@@ -51,6 +51,7 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -73,9 +74,12 @@
import org.openide.DialogDisplayer;
import org.openide.LifecycleManager;
import org.openide.NotifyDescriptor;
+import org.openide.awt.Actions;
import org.openide.awt.Mnemonics;
import org.openide.awt.NotificationDisplayer;
import org.openide.filesystems.FileChooserBuilder;
+import org.openide.filesystems.FileStateInvalidException;
+import org.openide.filesystems.FileUtil;
import org.openide.modules.Places;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
@@ -197,18 +201,24 @@
LOGGER.fine("Export canceled."); //NOI18N
return;
}
+
+ Action save = Actions.forID("Window", "org.netbeans.core.windows.actions.SaveWindowsAction"); // NOI18N
+ if (save != null) {
+ save.actionPerformed(new ActionEvent(optionsChooserPanel, 0, ""));
+ }
+
final String targetPath = optionsChooserPanel.getSelectedFilePath();
- RequestProcessor RP = new RequestProcessor("OptionsChooserPanel Export", 1); // NOI18N
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- optionsChooserPanel.getOptionsExportModel().doExport(new File(targetPath));
- NotificationDisplayer.getDefault().notify(
- NbBundle.getMessage(OptionsChooserPanel.class, "OptionsChooserPanel.export.status.text"), //NOI18N
- OPTIONS_ICON, Bundle.Export_Notification_DetailsText(targetPath), null);
- LOGGER.fine("Export finished."); //NOI18N
- }
- };
+ RequestProcessor RP = new RequestProcessor("OptionsChooserPanel Export", 1); // NOI18N
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ optionsChooserPanel.getOptionsExportModel().doExport(new File(targetPath));
+ NotificationDisplayer.getDefault().notify(
+ NbBundle.getMessage(OptionsChooserPanel.class, "OptionsChooserPanel.export.status.text"), //NOI18N
+ OPTIONS_ICON, Bundle.Export_Notification_DetailsText(targetPath), null);
+ LOGGER.fine("Export finished."); //NOI18N
+ }
+ };
exportTask = RP.create(runnable);
final ProgressHandle ph = ProgressHandleFactory.createHandle(Bundle.ProgressHandle_Export_DisplayName(), exportTask);
@@ -224,6 +234,9 @@
}
}
+ @NbBundle.Messages({
+ "OPT_RestartAfterImport=false"
+ })
/** Shows panel for import of options. */
public static void showImportDialog() {
LOGGER.fine("showImportDialog"); //NOI18N
@@ -244,11 +257,13 @@
null);
dd.createNotificationLineSupport();
dd.setValid(false);
+ boolean ok;
+ final boolean willRestart = "true".equals(Bundle.OPT_RestartAfterImport()); // NOI18N
final ImportConfirmationPanel confirmationPanel = new ImportConfirmationPanel();
dd.setButtonListener(new ActionListener() {
-
+ @Override
public void actionPerformed(ActionEvent e) {
- if (e.getSource() == DialogDescriptor.OK_OPTION) {
+ if (willRestart && e.getSource() == DialogDescriptor.OK_OPTION) {
// show confirmation dialog when user click OK
confirmationPanel.showConfirmation();
}
@@ -256,12 +271,15 @@
});
optionsChooserPanel.setDialogDescriptor(dd);
DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
-
- if (DialogDescriptor.OK_OPTION.equals(dd.getValue())) {
+ ok = DialogDescriptor.OK_OPTION.equals(dd.getValue());
+ if (willRestart) {
if (!confirmationPanel.confirmed()) {
LOGGER.fine("Import canceled."); //NOI18N
- return;
+ ok = false;
}
+ }
+
+ if (ok) {
// do import
File targetUserdir = Places.getUserDirectory();
try {
@@ -274,9 +292,20 @@
return;
}
LOGGER.fine("Import finished."); //NOI18N
- // restart IDE
- LifecycleManager.getDefault().markForRestart();
- LifecycleManager.getDefault().exit();
+ if (willRestart) { // NOI18N
+ // restart IDE
+ LifecycleManager.getDefault().markForRestart();
+ LifecycleManager.getDefault().exit();
+ }
+ try {
+ FileUtil.getConfigRoot().getFileSystem().refresh(true);
+ } catch (FileStateInvalidException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ Action reload = Actions.forID("Window", "org.netbeans.core.windows.actions.ReloadWindowsAction");
+ if (reload != null) {
+ reload.actionPerformed(new ActionEvent(optionsChooserPanel, 0, ""));
+ }
}
}
diff -r 6fdb332e0aa9 options.api/src/org/netbeans/modules/options/export/OptionsExportModel.java
--- a/options.api/src/org/netbeans/modules/options/export/OptionsExportModel.java Thu Mar 14 12:38:42 2013 +0100
+++ b/options.api/src/org/netbeans/modules/options/export/OptionsExportModel.java Thu Mar 14 12:53:02 2013 +0100
@@ -59,7 +59,6 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.prefs.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -69,7 +68,6 @@
import org.openide.util.EditableProperties;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
-import org.openide.util.NbPreferences;
/**
* Model for export/import options. It reads {@code OptionsExport//- }
@@ -175,45 +173,6 @@
void doImport(File targetUserdir) throws IOException {
LOGGER.fine("Copying from: " + source + "\n to: " + targetUserdir); //NOI18N
this.targetUserdir = targetUserdir;
- FileUtil.getConfigRoot().addRecursiveListener(new FileChangeListener() {
-
- @Override
- public void fileFolderCreated(FileEvent fe) {
- String path = fe.getFile().getPath();
- Preferences pref = Preferences.userRoot().node(path);
- }
-
- @Override
- public void fileDataCreated(FileEvent fe) {
- String path = fe.getFile().getPath();
- Preferences pref = NbPreferences.root().node("config").node(path);
- }
-
- @Override
- public void fileChanged(FileEvent fe) {
- String path = fe.getFile().getPath();
- Preferences pref = NbPreferences.root().node("config").node(path);
- }
-
- @Override
- public void fileDeleted(FileEvent fe) {
- String path = fe.getFile().getPath();
- Preferences pref = NbPreferences.root().node("config").node(path);
- try {
- pref.removeNode();
- } catch (BackingStoreException ex) {
- Exceptions.printStackTrace(ex);
- }
- }
-
- @Override
- public void fileRenamed(FileRenameEvent fe) {
- }
-
- @Override
- public void fileAttributeChanged(FileAttributeEvent fe) {
- }
- });
copyFiles();
}
@@ -225,7 +184,7 @@
try {
ensureParent(targetZipFile);
// Create the ZIP file
- zipOutputStream = new ZipOutputStream(new FileOutputStream(targetZipFile));
+ zipOutputStream = new ZipOutputStream(createOutputStream(targetZipFile));
copyFiles();
createProductInfo(zipOutputStream);
// Complete the ZIP file
@@ -869,7 +828,7 @@
if (includeKeys.isEmpty() && excludeKeys.isEmpty()) {
// copy entire file
try {
- out = new FileOutputStream(targetFile);
+ out = createOutputStream(targetFile);
copyFile(relativePath, out);
} finally {
if (out != null) {
@@ -915,7 +874,7 @@
}
OutputStream out = null;
try {
- out = new FileOutputStream(targetFile);
+ out = createOutputStream(targetFile);
targetProperties.store(out);
} finally {
if (out != null) {
@@ -1041,7 +1000,7 @@
ZipOutputStream out = null;
try {
// Create the ZIP file
- out = new ZipOutputStream(new FileOutputStream(targetFile));
+ out = new ZipOutputStream(createOutputStream(targetFile));
// Compress the files
for (String relativePath : relativePaths) {
LOGGER.finest("Adding to zip: " + relativePath); //NOI18N
@@ -1091,4 +1050,32 @@
// Complete the entry
out.closeEntry();
}
+
+ private static OutputStream createOutputStream(File file) throws IOException {
+ if (containsConfig(file)) {
+ file = file.getCanonicalFile();
+ File root = FileUtil.toFile(FileUtil.getConfigRoot());
+ String filePath = file.getPath();
+ String rootPath = root.getPath();
+ if (filePath.startsWith(rootPath)) {
+ String res = filePath.substring(rootPath.length()).replace(File.separatorChar, '/');
+ FileObject fo = FileUtil.createData(FileUtil.getConfigRoot(), res);
+ if (fo != null) {
+ return fo.getOutputStream();
+ }
+ }
+ }
+ return new FileOutputStream(file);
+ }
+ private static boolean containsConfig(File file) {
+ for (;;) {
+ if (file == null) {
+ return false;
+ }
+ if (file.getName().equals("config")) {
+ return true;
+ }
+ file = file.getParentFile();
+ }
+ }
}