Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java63
1 files changed, 63 insertions, 0 deletions
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