Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2010-05-19 14:29:24 -0400
committerDarin Wright2010-05-19 14:29:24 -0400
commit4ea79359f47ecb7d9481ac0cd58482b89a63be1e (patch)
tree1f76c168864339cb300abd1fbf564c71f7d58efc
parent5df5921b3c3350803b4a5064b1c78ba6f46a6d01 (diff)
downloadeclipse.platform.debug-4ea79359f47ecb7d9481ac0cd58482b89a63be1e.tar.gz
eclipse.platform.debug-4ea79359f47ecb7d9481ac0cd58482b89a63be1e.tar.xz
eclipse.platform.debug-4ea79359f47ecb7d9481ac0cd58482b89a63be1e.zip
Bug 284557 - Default Launchers preference settings are not imported
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java71
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java55
-rw-r--r--org.eclipse.debug.core/plugin.xml3
4 files changed, 111 insertions, 27 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
index 15ad6ad5b..f3d3a555f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
@@ -186,12 +186,14 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
} else {
fPreferredDelegates.put(modes, delegate);
}
+ ((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).persistPreferredLaunchDelegate(this);
}
/**
* @see org.eclipse.debug.core.ILaunchConfigurationType#getPreferredDelegate(java.util.Set)
*/
public ILaunchDelegate getPreferredDelegate(Set modes) {
+ initializePreferredDelegates();
return (ILaunchDelegate) fPreferredDelegates.get(modes);
}
@@ -208,6 +210,7 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
* @since 3.3
*/
public Map getPreferredDelegates() {
+ initializePreferredDelegates();
return fPreferredDelegates;
}
@@ -503,5 +506,11 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
return fModeCombinations.contains(modes);
}
+ /**
+ * Called on preference import to reset preferred delegates.
+ */
+ void resetPreferredDelegates() {
+ fPreferredDelegates = null;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index feb765196..6780dfde9 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -1596,6 +1596,16 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
/**
+ * Allows internal access to reset preferred delegates when re-importing
+ * preferences.
+ *
+ * @since 3.6
+ */
+ protected void resetPreferredDelegates() {
+ fPreferredDelegates = null;
+ }
+
+ /**
* Allows internal access to a preferred delegate for a given type and mode set
* @param typeid the id of the <code>ILaunchConfigurationType</code> to find a delegate for
* @param modes the set of modes for the delegate
@@ -2347,43 +2357,50 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*
* @since 3.3
*/
- private void persistPreferredLaunchDelegates() {
+ public void persistPreferredLaunchDelegates() {
ILaunchConfigurationType[] types = getLaunchConfigurationTypes();
- Map preferred = null;
- ILaunchDelegate delegate = null;
- Set modes = null;
for(int i = 0; i < types.length; i++) {
- String preferenceName = PREF_PREFERRED_DELEGATES + '/' + types[i].getIdentifier();
- preferred = ((LaunchConfigurationType)types[i]).getPreferredDelegates();
- if(preferred != null && preferred.size() > 0) {
- StringBuffer str = new StringBuffer();
- for(Iterator iter = preferred.keySet().iterator(); iter.hasNext();) {
- modes = (Set) iter.next();
- delegate = (ILaunchDelegate) preferred.get(modes);
- if(delegate != null) {
- str.append(delegate.getId());
- str.append(',');
- for(Iterator iter2 = modes.iterator(); iter2.hasNext();) {
- str.append(iter2.next());
- if(iter2.hasNext()) {
- str.append(',');
- }
- }
- if (iter.hasNext()) {
- str.append(';');
+ persistPreferredLaunchDelegate((LaunchConfigurationType)types[i]);
+ }
+ }
+
+ /**
+ * Persists the given launch configuration delegate.
+ * @param type Launch configuration type to persist
+ *
+ * @since 3.6
+ */
+ public void persistPreferredLaunchDelegate(LaunchConfigurationType type) {
+ String preferenceName = PREF_PREFERRED_DELEGATES + '/' + type.getIdentifier();
+ Map preferred = type.getPreferredDelegates();
+ if(preferred != null && preferred.size() > 0) {
+ StringBuffer str = new StringBuffer();
+ for(Iterator iter = preferred.keySet().iterator(); iter.hasNext();) {
+ Set modes = (Set) iter.next();
+ ILaunchDelegate delegate = (ILaunchDelegate) preferred.get(modes);
+ if(delegate != null) {
+ str.append(delegate.getId());
+ str.append(',');
+ for(Iterator iter2 = modes.iterator(); iter2.hasNext();) {
+ str.append(iter2.next());
+ if(iter2.hasNext()) {
+ str.append(',');
}
}
+ if (iter.hasNext()) {
+ str.append(';');
+ }
}
- Preferences.setString(DebugPlugin.getUniqueIdentifier(), preferenceName, str.toString(), null);
- } else {
- Preferences.setToDefault(DebugPlugin.getUniqueIdentifier(), preferenceName);
}
+ Preferences.setString(DebugPlugin.getUniqueIdentifier(), preferenceName, str.toString(), null);
+ } else {
+ Preferences.setToDefault(DebugPlugin.getUniqueIdentifier(), preferenceName);
}
// Reset the legacy preference string.
Preferences.setToDefault(DebugPlugin.getUniqueIdentifier(), PREF_PREFERRED_DELEGATES);
- }
-
+ }
+
/**
* finds and terminates any running launch configurations associated with the given resource
* @param resource the resource to search for launch configurations and hence launches for
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java
new file mode 100644
index 000000000..b75ced816
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.core;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor;
+import org.eclipse.core.runtime.preferences.PreferenceModifyListener;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * Used to listen for preference imports that include changes to
+ * preferred launch delegates.
+ *
+ * @since 3.6
+ */
+public class PreferredDelegateModifyListener extends PreferenceModifyListener {
+ class Visitor implements IPreferenceNodeVisitor {
+
+ public boolean visit(IEclipsePreferences node) throws BackingStoreException {
+ if (node.name().equals(DebugPlugin.getUniqueIdentifier())) {
+ // reset preferred delegates, so they are re-initialized from the preferences
+ LaunchManager manager = (LaunchManager)DebugPlugin.getDefault().getLaunchManager();
+ manager.resetPreferredDelegates();
+ ILaunchConfigurationType[] types = manager.getLaunchConfigurationTypes();
+ for (int i = 0; i < types.length; i++) {
+ ((LaunchConfigurationType) types[i]).resetPreferredDelegates();
+ }
+ return false;
+ }
+ return true;
+ }
+
+ }
+
+ public IEclipsePreferences preApply(IEclipsePreferences node) {
+ try {
+ // force VMs to be initialized before we import the new VMs
+ node.accept(new Visitor());
+ } catch (BackingStoreException e) {
+ DebugPlugin.log(e);
+ }
+ return node;
+ }
+
+}
diff --git a/org.eclipse.debug.core/plugin.xml b/org.eclipse.debug.core/plugin.xml
index 7db501732..19ba532a6 100644
--- a/org.eclipse.debug.core/plugin.xml
+++ b/org.eclipse.debug.core/plugin.xml
@@ -234,6 +234,9 @@
<initializer
class="org.eclipse.debug.internal.core.DebugPreferenceInitializer">
</initializer>
+ <modifier
+ class="org.eclipse.debug.internal.core.PreferredDelegateModifyListener">
+ </modifier>
</extension>
<!-- ===================================== -->

Back to the top