Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Duft2017-01-20 07:35:20 -0500
committerSarika Sinha2017-02-06 03:46:20 -0500
commitab220976ddfb22a8b3230f3598f6dc0a2baac501 (patch)
treebfe409dc90926d6224e1d7eadca48fd70e5ddd73 /org.eclipse.debug.core
parent11d8e4118051e4830ab9676c41821f63848387e5 (diff)
downloadeclipse.platform.debug-ab220976ddfb22a8b3230f3598f6dc0a2baac501.tar.gz
eclipse.platform.debug-ab220976ddfb22a8b3230f3598f6dc0a2baac501.tar.xz
eclipse.platform.debug-ab220976ddfb22a8b3230f3598f6dc0a2baac501.zip
Bug 508718 - Allow groups to catch up with renames in launch configs
This change registers a global listener in the LaunchManager that handles updating launch groups whenever a member of that group is renamed. This relies on the workings of the ILaunchmanager#getMovedFrom method. Change-Id: Ie1a617b6e826b0a1b6adb0a1b962dc18484f071a Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java4
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java63
2 files changed, 67 insertions, 0 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
index 4009f9a54..fd39a0972 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
@@ -68,6 +68,7 @@ import org.eclipse.debug.internal.core.MemoryBlockManager;
import org.eclipse.debug.internal.core.Preferences;
import org.eclipse.debug.internal.core.StepFilterManager;
import org.eclipse.debug.internal.core.commands.CommandAdapterFactory;
+import org.eclipse.debug.internal.core.groups.GroupMemberChangeListener;
import org.eclipse.debug.internal.core.sourcelookup.SourceLookupUtils;
import org.eclipse.osgi.service.environment.Constants;
import org.osgi.framework.BundleContext;
@@ -713,6 +714,9 @@ public class DebugPlugin extends Plugin {
manager.registerAdapters(actionFactory, ILaunch.class);
manager.registerAdapters(actionFactory, IProcess.class);
manager.registerAdapters(actionFactory, IDebugElement.class);
+
+ // monitor launch configuration renames for launch groups
+ getLaunchManager().addLaunchConfigurationListener(new GroupMemberChangeListener());
}
/**
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java
new file mode 100644
index 000000000..84c8eee5d
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java
@@ -0,0 +1,63 @@
+package org.eclipse.debug.internal.core.groups;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationListener;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+
+/**
+ * Manages renames of launch configurations that are members of group launches
+ *
+ * @since 3.11
+ */
+public class GroupMemberChangeListener implements ILaunchConfigurationListener {
+
+ private static final String GROUP_TYPE_ID = "org.eclipse.debug.core.groups.GroupLaunchConfigurationType"; //$NON-NLS-1$
+
+ @Override
+ public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfiguration original = launchManager.getMovedFrom(configuration);
+ if (original != null) {
+ ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(GROUP_TYPE_ID);
+ if (type == null) {
+ DebugPlugin.logMessage("cannot find group launch configuration type", null); //$NON-NLS-1$
+ return;
+ }
+ try {
+ for (ILaunchConfiguration c : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type)) {
+ List<GroupLaunchElement> elements = GroupLaunchConfigurationDelegate.createLaunchElements(c);
+ boolean updated = false;
+ for (GroupLaunchElement e : elements) {
+ if (e.name.equals(original.getName())) {
+ updated = true;
+ e.name = configuration.getName();
+ }
+ }
+
+ if (updated) {
+ ILaunchConfigurationWorkingCopy workingCopy = c.getWorkingCopy();
+ GroupLaunchConfigurationDelegate.storeLaunchElements(workingCopy, elements);
+ workingCopy.doSave();
+ }
+ }
+ } catch (CoreException e) {
+ DebugPlugin.log(e);
+ }
+ }
+ }
+
+ @Override
+ public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+ }
+
+ @Override
+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ }
+
+}

Back to the top