Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-06-26 07:09:33 -0400
committerJean Michel-Lemieux2003-06-26 07:09:33 -0400
commite68410b0b69db36a3b8ef78898eb66fcfa3fb41b (patch)
treee934c613719f97e01a63188ef30ff8047ec170c4
parentafa0c0f92697f55b8d9b179f0bb0edc8aa997d9c (diff)
downloadeclipse.platform.team-Bug_36957.tar.gz
eclipse.platform.team-Bug_36957.tar.xz
eclipse.platform.team-Bug_36957.zip
handle storing the preferences on ok pressedBug_36957
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java41
1 files changed, 38 insertions, 3 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java
index 097aab847..24f7cb433 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java
@@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.dialogs;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceDialog;
@@ -43,6 +46,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
public class PreferencePageContainerDialog extends Dialog implements IPreferencePageContainer {
@@ -120,14 +124,15 @@ public class PreferencePageContainerDialog extends Dialog implements IPreference
protected void okPressed() {
final List changedProperties = new ArrayList(5);
getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() {
- /**
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
public void propertyChange(PropertyChangeEvent event) {
changedProperties.add(event.getProperty());
}
});
+
page.performOk();
+
+ handleSave();
+
super.okPressed();
}
@@ -383,4 +388,34 @@ public class PreferencePageContainerDialog extends Dialog implements IPreference
fOkButton= createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
+
+ /**
+ * Save the values specified in the pages.
+ * <p>
+ * The default implementation of this framework method saves all
+ * pages of type <code>PreferencePage</code> (if their store needs saving
+ * and is a <code>PreferenceStore</code>).
+ * </p>
+ * <p>
+ * Subclasses may override.
+ * </p>
+ */
+ protected void handleSave() {
+ if (page instanceof PreferencePage) {
+ // Save now in case tbe workbench does not shutdown cleanly
+ IPreferenceStore store =
+ ((PreferencePage) page).getPreferenceStore();
+ if (store != null
+ && store.needsSaving()
+ && store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ MessageDialog.openError(
+ getShell(), Policy.bind("saving"),
+ Policy.bind("saving", page.getTitle(), e.getMessage()));
+ }
+ }
+ }
+ }
}

Back to the top