Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2009-04-13 18:25:50 +0000
committerSusan Franklin2009-04-13 18:25:50 +0000
commitc93e855717e502b253ccfc0b78e637836b37fc23 (patch)
treec1c48c4d51d5db7f50148ce8fab34c6a609853d4 /bundles/org.eclipse.equinox.p2.ui.sdk
parentef85873b64f6e846bfd232320014d1dc51c7d813 (diff)
downloadrt.equinox.p2-c93e855717e502b253ccfc0b78e637836b37fc23.tar.gz
rt.equinox.p2-c93e855717e502b253ccfc0b78e637836b37fc23.tar.xz
rt.equinox.p2-c93e855717e502b253ccfc0b78e637836b37fc23.zip
Bug 222498 - [ui] Scope for update preferences
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKUIActivator.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/PreferenceInitializer.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/ProvisioningPreferencePage.java32
5 files changed, 69 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
index ce5028a54..f03b04e39 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,9 +24,11 @@ public class ProvSDKMessages extends NLS {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, ProvSDKMessages.class);
}
+ public static String Error_Saving_Preferences;
public static String Handler_CannotLaunchUI;
public static String Handler_SDKUpdateUIMessageTitle;
public static String InstallNewSoftwareHandler_LoadRepositoryJobLabel;
+ public static String PreferenceInitializer_Error;
public static String ProvisioningPreferencePage_AlwaysOpenWizard;
public static String ProvisioningPreferencePage_BrowsingPrefsGroup;
public static String ProvisioningPreferencePage_ShowLatestVersions;
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKUIActivator.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKUIActivator.java
index caa1ad913..5131d076c 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKUIActivator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,7 +12,9 @@ package org.eclipse.equinox.internal.p2.ui.sdk;
import java.io.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceConstants;
+import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceInitializer;
import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
@@ -30,6 +32,8 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.*;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
/**
* Activator class for the p2 UI.
@@ -46,6 +50,7 @@ public class ProvSDKUIActivator extends AbstractUIPlugin {
private IPropertyChangeListener preferenceListener;
public static final String PLUGIN_ID = "org.eclipse.equinox.p2.ui.sdk"; //$NON-NLS-1$
+ public static final String PREFERENCE_ROOT = "/profile/_SELF_/"; //$NON-NLS-1$
public static BundleContext getContext() {
return context;
@@ -72,6 +77,22 @@ public class ProvSDKUIActivator extends AbstractUIPlugin {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
+ public static Preferences getPreferences() {
+ return Platform.getPreferencesService().getRootNode().node(PREFERENCE_ROOT + PLUGIN_ID);
+ }
+
+ public static Preferences getDefaultPreferences() {
+ return new DefaultScope().getNode(PLUGIN_ID);
+ }
+
+ public static void savePreferences() {
+ try {
+ getPreferences().flush();
+ } catch (BackingStoreException e) {
+ ProvUI.handleException(e, ProvSDKMessages.Error_Saving_Preferences, StatusManager.LOG);
+ }
+ }
+
public ProvSDKUIActivator() {
// constructor
}
@@ -86,6 +107,7 @@ public class ProvSDKUIActivator extends AbstractUIPlugin {
plugin = this;
ProvSDKUIActivator.context = bundleContext;
readLicenseRegistry();
+ PreferenceInitializer.migratePreferences();
certificateUIRegistration = context.registerService(IServiceUI.class.getName(), new ValidationDialogServiceUI(), null);
getPreferenceStore().addPropertyChangeListener(getPreferenceListener());
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
index 41c5f95db..2ed5413dc 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2008 IBM Corporation and others.
+# Copyright (c) 2007, 2009 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -10,9 +10,11 @@
###############################################################################
+Error_Saving_Preferences=Error saving update preferences
Handler_CannotLaunchUI=Cannot launch the Update UI. This installation has not been configured properly for Software Updates.
Handler_SDKUpdateUIMessageTitle=Software Updates
InstallNewSoftwareHandler_LoadRepositoryJobLabel=Contacting Software Sites
+PreferenceInitializer_Error=Error accessing preferences.
ProvSDKUIActivator_ErrorWritingLicenseRegistry=Error writing license registry. Accepted licenses will not be remembered.
ProvSDKUIActivator_LicenseManagerReadError=Error reading license registry. Accepted licenses will not be remembered.
ProvSDKUIActivator_NoSelfProfile=Could not locate the running profile instance. The eclipse.p2.data.area and eclipse.p2.profile properties may not be set correctly in this application's config.ini file.
@@ -27,4 +29,4 @@ ProvisioningPreferencePage_NeverOpenWizard=&Report the problems and do not open
ProvisioningPreferencePage_OpenWizardIfInvalid=When software selected for an install wizard may not be compatible
ProvisioningPreferencePage_PromptToOpenWizard=&Ask me what to do when it happens
UpdateHandler_NoSitesMessage=There are no update sites to search. Do you wish to open the "Available Software Sites" preferences?
-UpdateHandler_NoSitesTitle=No Updates Found
+UpdateHandler_NoSitesTitle=No Updates Found \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/PreferenceInitializer.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/PreferenceInitializer.java
index 83c7f1adf..829943fdb 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/PreferenceInitializer.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/PreferenceInitializer.java
@@ -12,7 +12,12 @@ package org.eclipse.equinox.internal.p2.ui.sdk.prefs;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKMessages;
+import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator;
+import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
/**
@@ -20,13 +25,30 @@ import org.osgi.service.prefs.Preferences;
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
+ public static void migratePreferences() {
+ Preferences pref = ProvSDKUIActivator.getPreferences();
+ try {
+ if (pref.keys().length == 0) {
+ // migrate preferences from instance scope to profile scope
+ org.eclipse.core.runtime.Preferences oldPref = ProvSDKUIActivator.getDefault().getPluginPreferences();
+ // don't migrate everything. Some of the preferences moved to
+ // another bundle.
+ pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, oldPref.getString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN));
+ pref.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, oldPref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION));
+ ProvSDKUIActivator.savePreferences();
+ }
+ } catch (BackingStoreException e) {
+ ProvUI.handleException(e, ProvSDKMessages.PreferenceInitializer_Error, StatusManager.LOG);
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
Preferences node = new DefaultScope().getNode("org.eclipse.equinox.p2.ui.sdk"); //$NON-NLS-1$
+ // default values
node.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, true);
node.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT);
}
-
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/ProvisioningPreferencePage.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/ProvisioningPreferencePage.java
index ca62afe0f..d4ab9e0eb 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/ProvisioningPreferencePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/prefs/ProvisioningPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2008, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk.prefs;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.equinox.internal.p2.ui.sdk.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -20,6 +19,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;
+import org.osgi.service.prefs.Preferences;
/**
* Preference page for general provisioning preferences.
@@ -97,10 +97,10 @@ public class ProvisioningPreferencePage extends PreferencePage implements IWorkb
}
private void initialize() {
- Preferences pref = ProvSDKUIActivator.getDefault().getPluginPreferences();
- showLatestRadio.setSelection(pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION));
- showAllRadio.setSelection(!pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION));
- String openWizard = pref.getString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN);
+ Preferences pref = ProvSDKUIActivator.getPreferences();
+ showLatestRadio.setSelection(pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, false));
+ showAllRadio.setSelection(!pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, false));
+ String openWizard = pref.get(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, ""); //$NON-NLS-1$
alwaysShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.ALWAYS));
neverShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.NEVER));
promptOnFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.PROMPT));
@@ -108,26 +108,26 @@ public class ProvisioningPreferencePage extends PreferencePage implements IWorkb
protected void performDefaults() {
super.performDefaults();
- Preferences pref = ProvSDKUIActivator.getDefault().getPluginPreferences();
- showLatestRadio.setSelection(pref.getDefaultBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION));
- showAllRadio.setSelection(!pref.getDefaultBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION));
- String openWizard = pref.getDefaultString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN);
+ Preferences pref = ProvSDKUIActivator.getDefaultPreferences();
+ showLatestRadio.setSelection(pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, false));
+ showAllRadio.setSelection(!pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, false));
+ String openWizard = pref.get(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, ""); //$NON-NLS-1$
alwaysShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.ALWAYS));
neverShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.NEVER));
promptOnFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.PROMPT));
}
public boolean performOk() {
- Preferences pref = ProvSDKUIActivator.getDefault().getPluginPreferences();
- pref.setValue(PreferenceConstants.PREF_SHOW_LATEST_VERSION, showLatestRadio.getSelection());
+ Preferences pref = ProvSDKUIActivator.getPreferences();
+ pref.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, showLatestRadio.getSelection());
if (alwaysShowFailedPlan.getSelection())
- pref.setValue(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.ALWAYS);
+ pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.ALWAYS);
else if (neverShowFailedPlan.getSelection())
- pref.setValue(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.NEVER);
+ pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.NEVER);
else
- pref.setValue(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT);
+ pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT);
- ProvSDKUIActivator.getDefault().savePluginPreferences();
+ ProvSDKUIActivator.savePreferences();
return true;
}

Back to the top