Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2009-04-14 20:50:32 +0000
committerSusan Franklin2009-04-14 20:50:32 +0000
commit84862ed961f90667f5faf03f5c229cf2a179dafd (patch)
treed09d3ad15fd17ace5f5a94e0c3d4cdc6de97a0df /bundles/org.eclipse.equinox.p2.ui.sdk.scheduler
parentbd533dd39e78631b07b6a05d39d97851f7d009cd (diff)
downloadrt.equinox.p2-84862ed961f90667f5faf03f5c229cf2a179dafd.tar.gz
rt.equinox.p2-84862ed961f90667f5faf03f5c229cf2a179dafd.tar.xz
rt.equinox.p2-84862ed961f90667f5faf03f5c229cf2a179dafd.zip
Bug 258539 - [ui] Automatic update preference lost
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceInitializer.java115
2 files changed, 75 insertions, 41 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java
index 91876d471..19f9647f4 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java
@@ -23,4 +23,5 @@ public class PreferenceConstants {
public static final String PREF_REMIND_SCHEDULE = "remindOnSchedule"; // value is true or false //$NON-NLS-1$
public static final String PREF_REMIND_ELAPSED = "remindElapsedTime";//$NON-NLS-1$
public static final String PREF_AUTO_UPDATE_INIT = "autoUpdateInit"; //$NON-NLS-1$
+ public static final String PREF_MIGRATED_34 = "migrated34Prefs"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceInitializer.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceInitializer.java
index 46de9caf8..717a5418b 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceInitializer.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceInitializer.java
@@ -23,10 +23,12 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
private static final String P_ENABLED = "enabled"; //$NON-NLS-1$
private static final String UPDATE_PLUGIN_ID = "org.eclipse.update.scheduler"; //$NON-NLS-1$
+ private static final String SDK_UI_PLUGIN_ID = "org.eclipse.equinox.p2.ui.sdk"; //$NON-NLS-1$
public static void migratePreferences() {
// Migrate preference values that were stored in alternate locations.
- // 1) migrate from instance scope (during 3.5 development) to profile scope (final 3.5 format)
+ // 1) migrate from instance scope (during 3.5 development) to profile
+ // scope (final 3.5 format)
// 2) if applicable, migrate from 3.4 prefs kept in a different bundle
// 3) if applicable, migrate from 3.3 prefs known by Update Manager
Preferences pref = AutomaticUpdatePlugin.getPreferences();
@@ -48,42 +50,69 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
StatusManager.LOG);
}
- // Have we initialized the auto update prefs from previous
- // releases?
- boolean autoUpdateInit = pref.getBoolean(
- PreferenceConstants.PREF_AUTO_UPDATE_INIT, false);
- if (!autoUpdateInit) {
+ // Have we migrated from 3.4 pref values?
+ boolean migrated34 = pref.getBoolean(
+ PreferenceConstants.PREF_MIGRATED_34, false);
+ boolean node34exists = false;
+ if (!migrated34) {
// first look for the 3.4 automatic update preferences, which were
// located in a different bundle than now, in the instance scope.
- Preferences node34 = Platform.getPreferencesService().getRootNode()
- .node(InstanceScope.SCOPE).node(
- "org.eclipse.equinox.p2.ui.sdk"); //$NON-NLS-1$
- if (node34 != null) {
+ Preferences instanceScope = Platform.getPreferencesService()
+ .getRootNode().node(InstanceScope.SCOPE);
+ try {
+ node34exists = instanceScope.nodeExists(SDK_UI_PLUGIN_ID);
+ } catch (BackingStoreException e1) {
+ // nothing to report, assume node does not exist
+ }
+ if (node34exists) {
+ Preferences node34 = instanceScope.node(SDK_UI_PLUGIN_ID);
// We only migrate the preferences associated with auto update.
// Other preferences still remain in that bundle and are handled
- // there.
- pref.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED,
- node34.getBoolean("enabled", false));
- pref.put(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE, node34
- .get("schedule",
- PreferenceConstants.PREF_UPDATE_ON_STARTUP));
- pref.putBoolean(PreferenceConstants.PREF_DOWNLOAD_ONLY, node34
- .getBoolean("download", false));
- pref.putBoolean(PreferenceConstants.PREF_REMIND_SCHEDULE,
- node34.getBoolean("remindOnSchedule", false)); //$NON-NLS-1$
- pref
- .put(
- PreferenceConstants.PREF_REMIND_ELAPSED,
- node34
- .get(
- "remindElapsedTime",
- AutomaticUpdateMessages.AutomaticUpdateScheduler_30Minutes));
- // mark the pref that says we've migrated
- pref
- .putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_INIT,
- true);
- AutomaticUpdatePlugin.savePreferences();
+ // there. We don't migrate if the value was never set.
+ if (node34.get("enabled", null) == null) {
+ pref.putBoolean(
+ PreferenceConstants.PREF_AUTO_UPDATE_ENABLED,
+ node34.getBoolean("enabled", false));
+ }
+ if (node34.get("schedule", null) == null) {
+ pref
+ .put(
+ PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE,
+ node34
+ .get(
+ "schedule",
+ PreferenceConstants.PREF_UPDATE_ON_STARTUP));
+ }
+ if (node34.get("download", null) == null) {
+ pref.putBoolean(PreferenceConstants.PREF_DOWNLOAD_ONLY,
+ node34.getBoolean("download", false));
+ }
+ if (node34.get("remindOnSchedule", null) == null) {
+ pref.putBoolean(PreferenceConstants.PREF_REMIND_SCHEDULE,
+ node34.getBoolean("remindOnSchedule", false)); //$NON-NLS-1$
+ }
+ if (node34.get("remindElapsedTime", null) == null) {
+
+ pref
+ .put(
+ PreferenceConstants.PREF_REMIND_ELAPSED,
+ node34
+ .get(
+ "remindElapsedTime",
+ AutomaticUpdateMessages.AutomaticUpdateScheduler_30Minutes));
+ }
}
+ // mark the pref that says we've migrated
+ pref.putBoolean(PreferenceConstants.PREF_MIGRATED_34, true);
+ AutomaticUpdatePlugin.savePreferences();
+ }
+ // pref used to track 3.3 migration
+ // Have we initialized the auto update prefs from previous
+ // releases?
+ boolean autoUpdateInit = pref.getBoolean(
+ PreferenceConstants.PREF_AUTO_UPDATE_INIT, false);
+
+ if (!migrated34 && !autoUpdateInit) {
// Look for the 3.3 UM automatic update preferences. We will
// not migrate them if we already pulled values from 3.4.
// However, we always want to turn off the UM automatic update
@@ -96,21 +125,21 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
Preferences prefUM = instanceScope.node(UPDATE_PLUGIN_ID);
boolean enableUpdate = prefUM.getBoolean(P_ENABLED, false);
// set p2 automatic update preference to match UM preference,
- // only if we haven't already used 3.4 values
- if (node34 == null) {
+ // only if we haven't already set a value.
+ if (pref.get(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, null) == null) {
pref.putBoolean(
PreferenceConstants.PREF_AUTO_UPDATE_ENABLED,
enableUpdate);
- // mark the pref that says we migrated
- pref.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_INIT,
- true);
- AutomaticUpdatePlugin.savePreferences();
}
// turn off UM automatic update preference if it exists
if (updateNodeExists) {
prefUM.putBoolean(P_ENABLED, false);
prefUM.flush();
}
+ // mark the pref that says we migrated
+ pref.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_INIT,
+ true);
+ AutomaticUpdatePlugin.savePreferences();
} catch (BackingStoreException e) {
ProvUI.handleException(e,
AutomaticUpdateMessages.ErrorSavingClassicPreferences,
@@ -118,13 +147,17 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
}
}
}
+
public void initializeDefaultPreferences() {
// initialize the default scope
- Preferences node = new DefaultScope().getNode(AutomaticUpdatePlugin.PLUGIN_ID);
+ Preferences node = new DefaultScope()
+ .getNode(AutomaticUpdatePlugin.PLUGIN_ID);
node.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, false);
- node.put(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE, PreferenceConstants.PREF_UPDATE_ON_STARTUP);
+ node.put(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE,
+ PreferenceConstants.PREF_UPDATE_ON_STARTUP);
node.putBoolean(PreferenceConstants.PREF_DOWNLOAD_ONLY, false);
node.putBoolean(PreferenceConstants.PREF_REMIND_SCHEDULE, false);
- node.put(PreferenceConstants.PREF_REMIND_ELAPSED, AutomaticUpdateMessages.AutomaticUpdateScheduler_30Minutes);
+ node.put(PreferenceConstants.PREF_REMIND_ELAPSED,
+ AutomaticUpdateMessages.AutomaticUpdateScheduler_30Minutes);
}
}

Back to the top