Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java57
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchElement.java1
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java96
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java17
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java24
7 files changed, 167 insertions, 34 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java
index 8d9f5a7d5..fccd5f8c3 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java
@@ -13,9 +13,12 @@
package org.eclipse.debug.internal.core.groups;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -47,6 +50,7 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
private static final String NAME_PROP = "name"; //$NON-NLS-1$
private static final String ENABLED_PROP = "enabled"; //$NON-NLS-1$
+ private static final String ADOPT_PROP = "adoptIfRunning"; //$NON-NLS-1$
private static final String MODE_PROP = "mode"; //$NON-NLS-1$
private static final String ACTION_PROP = "action"; //$NON-NLS-1$
private static final String ACTION_PARAM_PROP = "actionParam"; //$NON-NLS-1$
@@ -61,10 +65,6 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
private static final Status GROUP_LAUNCH_START = new Status(IStatus.INFO, DEBUG_CORE, CODE_GROUP_LAUNCH_START, IInternalDebugCoreConstants.EMPTY_STRING, null);
private static final Status GROUP_LAUNCH_DONE = new Status(IStatus.INFO, DEBUG_CORE, CODE_GROUP_LAUNCH_DONE, IInternalDebugCoreConstants.EMPTY_STRING, null);
- public GroupLaunchConfigurationDelegate() {
- // nothing
- }
-
@Override
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
return new GroupLaunch(configuration, mode);
@@ -89,7 +89,7 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
}
// find launch; if not found, skip (error?)
- final ILaunchConfiguration conf = findLaunch(le.name);
+ final ILaunchConfiguration conf = findLaunchConfiguration(le.name);
if (conf == null) {
continue;
}
@@ -136,7 +136,12 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
}
private void launchChild(SubMonitor monitor, final GroupLaunch group, GroupLaunchElement le, final ILaunchConfiguration child, final String localMode, boolean lastConfig) throws CoreException {
- ILaunch subLaunch = child.launch(localMode, monitor);
+ final Set<ILaunch> running = le.adoptIfRunning ? findRunningLaunch(le.name) : Collections.emptySet();
+ ILaunch subLaunch = running.stream().findFirst().orElse(null);
+ if (subLaunch == null) {
+ subLaunch = child.launch(localMode, monitor);
+ }
+
group.addSubLaunch(subLaunch);
// Now that we added the launch in our list, we have already
@@ -218,7 +223,7 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
return false;
}
- protected static ILaunchConfiguration findLaunch(String name) throws CoreException {
+ protected static ILaunchConfiguration findLaunchConfiguration(String name) throws CoreException {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations();
for (int i = 0; i < launchConfigurations.length; i++) {
@@ -230,6 +235,20 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
return null;
}
+ protected static Set<ILaunch> findRunningLaunch(String name) {
+ Set<ILaunch> result = new HashSet<>();
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ for (ILaunch l : launchManager.getLaunches()) {
+ if (l.isTerminated()) {
+ continue;
+ }
+ if (l.getLaunchConfiguration().getName().equals(name)) {
+ result.add(l);
+ }
+ }
+ return result;
+ }
+
/**
* (Re-)reads all {@link GroupLaunchElement}s from a
* {@link ILaunchConfiguration}s attributes.
@@ -247,8 +266,8 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
String attr = (String) iterator.next();
try {
- if (attr.startsWith(GroupLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
- String prop = attr.substring(GroupLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX.length() + 1);
+ if (attr.startsWith(MULTI_LAUNCH_CONSTANTS_PREFIX)) {
+ String prop = attr.substring(MULTI_LAUNCH_CONSTANTS_PREFIX.length() + 1);
int k = prop.indexOf('.');
String num = prop.substring(0, k);
int index = Integer.parseInt(num);
@@ -276,10 +295,13 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
}
el.action = action;
el.actionParam = actionParam;
+ if (attrs.containsKey(getProp(index, ADOPT_PROP))) {
+ el.adoptIfRunning = (Boolean) attrs.get(getProp(index, ADOPT_PROP));
+ }
el.mode = (String) attrs.get(getProp(index, MODE_PROP));
el.enabled = (Boolean) attrs.get(getProp(index, ENABLED_PROP));
try {
- el.data = findLaunch(el.name);
+ el.data = findLaunchConfiguration(el.name);
} catch (Exception e) {
el.data = null;
}
@@ -307,14 +329,15 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
if (el == null) {
continue;
}
- configuration.setAttribute(GroupLaunchConfigurationDelegate.getProp(i, NAME_PROP), el.name);
- configuration.setAttribute(GroupLaunchConfigurationDelegate.getProp(i, ACTION_PROP), el.action.toString());
+ configuration.setAttribute(getProp(i, NAME_PROP), el.name);
+ configuration.setAttribute(getProp(i, ACTION_PROP), el.action.toString());
+ configuration.setAttribute(getProp(i, ADOPT_PROP), el.adoptIfRunning);
// note: the saving of the action param will need to be enhanced if
// ever an action type is introduced that uses something that can't
// be reconstructed from its toString()
- configuration.setAttribute(GroupLaunchConfigurationDelegate.getProp(i, ACTION_PARAM_PROP), el.actionParam != null ? el.actionParam.toString() : null);
- configuration.setAttribute(GroupLaunchConfigurationDelegate.getProp(i, MODE_PROP), el.mode);
- configuration.setAttribute(GroupLaunchConfigurationDelegate.getProp(i, ENABLED_PROP), el.enabled);
+ configuration.setAttribute(getProp(i, ACTION_PARAM_PROP), el.actionParam != null ? el.actionParam.toString() : null);
+ configuration.setAttribute(getProp(i, MODE_PROP), el.mode);
+ configuration.setAttribute(getProp(i, ENABLED_PROP), el.enabled);
i++;
}
}
@@ -325,7 +348,7 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
String attr = (String) iterator.next();
try {
- if (attr.startsWith(GroupLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
+ if (attr.startsWith(MULTI_LAUNCH_CONSTANTS_PREFIX)) {
configuration.removeAttribute(attr);
}
} catch (Exception e) {
@@ -338,6 +361,6 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat
}
public static String getProp(int index, String string) {
- return GroupLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX + "." + index + "." + string; //$NON-NLS-1$ //$NON-NLS-2$
+ return MULTI_LAUNCH_CONSTANTS_PREFIX + "." + index + "." + string; //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchElement.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchElement.java
index 310a8d368..767f90514 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchElement.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchElement.java
@@ -60,6 +60,7 @@ public class GroupLaunchElement {
public boolean enabled = true;
public String mode = MODE_INHERIT;
public GroupLaunchElement.GroupElementPostLaunchAction action = GroupElementPostLaunchAction.NONE;
+ public boolean adoptIfRunning = false;
public Object actionParam;
public String name;
public ILaunchConfiguration data;
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java
index 7f6f828fe..b046728c6 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java
@@ -4,12 +4,14 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchListener;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IDisconnect;
import org.eclipse.debug.core.model.IProcess;
@@ -22,18 +24,54 @@ import org.eclipse.debug.ui.IDebugUIConstants;
public class LaunchGroupTests extends AbstractLaunchTest {
private static final String GROUP_TYPE = "org.eclipse.debug.core.groups.GroupLaunchConfigurationType"; //$NON-NLS-1$
+ private static final String DEF_GRP_NAME = "Test Group"; //$NON-NLS-1$
+
+ private final AtomicInteger launchCount = new AtomicInteger(0);
+ private ILaunchConfiguration lcToCount = null;
+ private ILaunchListener lcListener = new ILaunchListener() {
+ @Override
+ public void launchRemoved(ILaunch launch) {
+ }
+
+ @Override
+ public void launchChanged(ILaunch launch) {
+ }
+
+ @Override
+ public void launchAdded(ILaunch launch) {
+ if (launch.getLaunchConfiguration().contentsEqual(lcToCount)) {
+ launchCount.incrementAndGet();
+ }
+ }
+ };
public LaunchGroupTests() {
super("Launch Groups Test"); //$NON-NLS-1$
}
- private ILaunchConfiguration createLaunchGroup(GroupLaunchElement... children) throws CoreException {
- ILaunchConfigurationWorkingCopy grp = getLaunchManager().getLaunchConfigurationType(GROUP_TYPE).newInstance(null, "Test Group"); //$NON-NLS-1$
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // reset count
+ launchCount.set(0);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ // make sure listener is removed
+ getLaunchManager().removeLaunchListener(lcListener);
+
+ super.tearDown();
+ }
+
+ private ILaunchConfiguration createLaunchGroup(String name, GroupLaunchElement... children) throws CoreException {
+ ILaunchConfigurationWorkingCopy grp = getLaunchManager().getLaunchConfigurationType(GROUP_TYPE).newInstance(null, name);
GroupLaunchConfigurationDelegate.storeLaunchElements(grp, Arrays.asList(children));
return grp.doSave();
}
- private GroupLaunchElement createLaunchGroupElement(ILaunchConfiguration source, GroupElementPostLaunchAction action, Object param) {
+ private GroupLaunchElement createLaunchGroupElement(ILaunchConfiguration source, GroupElementPostLaunchAction action, Object param, boolean adopt) {
GroupLaunchElement e = new GroupLaunchElement();
e.name = source.getName();
@@ -42,6 +80,7 @@ public class LaunchGroupTests extends AbstractLaunchTest {
e.actionParam = param;
e.mode = GroupLaunchElement.MODE_INHERIT;
e.enabled = true;
+ e.adoptIfRunning = adopt;
return e;
}
@@ -60,7 +99,7 @@ public class LaunchGroupTests extends AbstractLaunchTest {
public void testNone() throws Exception {
ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$
ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$
- ILaunchConfiguration grp = createLaunchGroup(createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null), createLaunchGroupElement(t2, GroupElementPostLaunchAction.NONE, null));
+ ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, false), createLaunchGroupElement(t2, GroupElementPostLaunchAction.NONE, null, false));
// attention: need to do this before launching!
LaunchHistory runHistory = getRunLaunchHistory();
@@ -76,7 +115,7 @@ public class LaunchGroupTests extends AbstractLaunchTest {
public void testDelay() throws Exception {
ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$
ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$
- ILaunchConfiguration grp = createLaunchGroup(createLaunchGroupElement(t1, GroupElementPostLaunchAction.DELAY, 2), createLaunchGroupElement(t2, GroupElementPostLaunchAction.NONE, null));
+ ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.DELAY, 2, false), createLaunchGroupElement(t2, GroupElementPostLaunchAction.NONE, null, false));
long start = System.currentTimeMillis();
// attention: need to do this before launching!
@@ -95,7 +134,7 @@ public class LaunchGroupTests extends AbstractLaunchTest {
public void testTerminated() throws Exception {
final ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$
final ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$
- ILaunchConfiguration grp = createLaunchGroup(createLaunchGroupElement(t1, GroupElementPostLaunchAction.WAIT_FOR_TERMINATION, null), createLaunchGroupElement(t2, GroupElementPostLaunchAction.NONE, null));
+ ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.WAIT_FOR_TERMINATION, null, false), createLaunchGroupElement(t2, GroupElementPostLaunchAction.NONE, null, false));
long start = System.currentTimeMillis();
new Thread("Terminate Test1") { //$NON-NLS-1$
@@ -153,4 +192,49 @@ public class LaunchGroupTests extends AbstractLaunchTest {
assertTrue("history[2] should be Test1", history[2].contentsEqual(t1)); //$NON-NLS-1$
}
+ public void testAdopt() throws Exception {
+ final ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$
+ final ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, false), createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, true));
+
+ // attention: need to do this before launching!
+ LaunchHistory runHistory = getRunLaunchHistory();
+
+ lcToCount = t1;
+ getLaunchManager().addLaunchListener(lcListener);
+ grp.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
+
+ ILaunchConfiguration[] history = runHistory.getHistory();
+ assertTrue("history should be size 2", history.length == 2); //$NON-NLS-1$
+ assertTrue("history[0] should be Test Group", history[0].contentsEqual(grp)); //$NON-NLS-1$
+ assertTrue("history[1] should be Test1", history[1].contentsEqual(t1)); //$NON-NLS-1$
+ assertTrue("Test1 should be launched only once", launchCount.get() == 1); //$NON-NLS-1$
+ }
+
+ public void testAdoptComplex() throws Exception {
+ final ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$
+
+ // Group 1 has Test1 (adopt = false)
+ // Group 2 has Group 1
+ // Group 3 has Group 2 and Test1 (adopt = true)
+
+ final ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, false));
+ final ILaunchConfiguration grp2 = createLaunchGroup("Group 2", createLaunchGroupElement(grp, GroupElementPostLaunchAction.NONE, null, false)); //$NON-NLS-1$
+ final ILaunchConfiguration grp3 = createLaunchGroup("Group 3", createLaunchGroupElement(grp2, GroupElementPostLaunchAction.NONE, null, false), createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, true)); //$NON-NLS-1$
+
+ // attention: need to do this before launching!
+ LaunchHistory runHistory = getRunLaunchHistory();
+
+ lcToCount = t1;
+ getLaunchManager().addLaunchListener(lcListener);
+ grp3.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
+
+ ILaunchConfiguration[] history = runHistory.getHistory();
+ assertTrue("history should be size 4", history.length == 4); //$NON-NLS-1$
+ assertTrue("history[0] should be Group 3", history[0].contentsEqual(grp3)); //$NON-NLS-1$
+ assertTrue("history[1] should be Group 2", history[1].contentsEqual(grp2)); //$NON-NLS-1$
+ assertTrue("history[2] should be Group 1", history[2].contentsEqual(grp)); //$NON-NLS-1$
+ assertTrue("history[3] should be Test1", history[3].contentsEqual(t1)); //$NON-NLS-1$
+ assertTrue("Test1 should be launched only once", launchCount.get() == 1); //$NON-NLS-1$
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
index 8839fa73c..49e6ab536 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
@@ -255,6 +255,8 @@ public class DebugUIMessages extends NLS {
public static String GroupLaunchConfigurationSelectionDialog_7;
public static String GroupLaunchConfigurationSelectionDialog_8;
public static String GroupLaunchConfigurationSelectionDialog_9;
+ public static String GroupLaunchConfigurationSelectionDialog_adoptText;
+ public static String GroupLaunchConfigurationSelectionDialog_adoptTooltip;
public static String GroupLaunchConfigurationTabGroup_1;
public static String GroupLaunchConfigurationTabGroup_10;
public static String GroupLaunchConfigurationTabGroup_12;
@@ -268,6 +270,7 @@ public class DebugUIMessages extends NLS {
public static String GroupLaunchConfigurationTabGroup_5;
public static String GroupLaunchConfigurationTabGroup_6;
public static String GroupLaunchConfigurationTabGroup_7;
+ public static String GroupLaunchConfigurationTabGroup_lblAdopt;
//
// Blocks
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
index 7d396fc92..912758da5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
@@ -128,6 +128,8 @@ GroupLaunchConfigurationSelectionDialog_12=Add Launch Configuration
GroupLaunchConfigurationSelectionDialog_13=Edit Launch Configuration
GroupLaunchConfigurationSelectionDialog_14=Add one or more launch configurations to the launch group
GroupLaunchConfigurationSelectionDialog_15=Edit an existing entry in the launch group
+GroupLaunchConfigurationSelectionDialog_adoptText=Adopt launch if already running
+GroupLaunchConfigurationSelectionDialog_adoptTooltip=Instead of launching a new process, adds the running launch to the group.
GroupLaunchConfigurationTabGroup_1=&Up
GroupLaunchConfigurationTabGroup_2=Do&wn
GroupLaunchConfigurationTabGroup_3=&Edit...
@@ -141,6 +143,7 @@ GroupLaunchConfigurationTabGroup_13=Delay {0} seconds
GroupLaunchConfigurationTabGroup_14=Launch {0} does not exist.
GroupLaunchConfigurationTabGroup_15=Launch {0} is filtered.
GroupLaunchConfigurationTabGroup_16=Must have at least one valid enabled launch.
+GroupLaunchConfigurationTabGroup_lblAdopt=\ (adopt if running)
CodePagesPrefDialog_1=Select Codepages
CodePagesPrefDialog_2=Memory to ASCII strings:
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java
index 6db551d82..8ae809995 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java
@@ -77,6 +77,7 @@ class GroupLaunchConfigurationSelectionDialog extends TitleAreaDialog implements
private String mode;
private GroupElementPostLaunchAction action = GroupElementPostLaunchAction.NONE;
private Object actionParam;
+ private boolean adoptIfRunning;
private ViewerFilter emptyTypeFilter;
private IStructuredSelection fInitialSelection;
private ComboControlledStackComposite fStackComposite;
@@ -210,6 +211,17 @@ class GroupLaunchConfigurationSelectionDialog extends TitleAreaDialog implements
}
});
+ Button chkAdopt = new Button(comp, SWT.CHECK);
+ chkAdopt.setText(DebugUIMessages.GroupLaunchConfigurationSelectionDialog_adoptText);
+ chkAdopt.setToolTipText(DebugUIMessages.GroupLaunchConfigurationSelectionDialog_adoptTooltip);
+ chkAdopt.setSelection(adoptIfRunning);
+ chkAdopt.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ adoptIfRunning = chkAdopt.getSelection();
+ }
+ });
+
createPostLaunchControl(comp);
return comp;
}
@@ -288,6 +300,10 @@ class GroupLaunchConfigurationSelectionDialog extends TitleAreaDialog implements
return action;
}
+ public boolean getAdoptIfRunning() {
+ return adoptIfRunning;
+ }
+
public Object getActionParam() {
return actionParam;
}
@@ -406,6 +422,7 @@ class GroupLaunchConfigurationSelectionDialog extends TitleAreaDialog implements
public void setInitialSelection(GroupLaunchElement el) {
action = el.action;
actionParam = el.actionParam;
+ adoptIfRunning = el.adoptIfRunning;
fInitialSelection = new StructuredSelection(el.data);
fSelection = fInitialSelection;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java
index 183ce1e39..692c681a8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java
@@ -148,7 +148,7 @@ public class GroupLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
// launch mode
if (columnIndex == 1) {
- return el.mode;
+ return el.mode + (el.adoptIfRunning ? DebugUIMessages.GroupLaunchConfigurationTabGroup_lblAdopt : ""); //$NON-NLS-1$
}
// launch post action
@@ -309,11 +309,7 @@ public class GroupLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
input.add(el);
el.index = input.size() - 1;
el.enabled = true;
- el.name = config.getName();
- el.data = config;
- el.mode = dialog.getMode();
- el.action = dialog.getAction();
- el.actionParam = dialog.getActionParam();
+ applyFromDialog(el, dialog, config);
treeViewer.refresh(true);
treeViewer.setChecked(el, el.enabled);
}
@@ -351,16 +347,22 @@ public class GroupLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
return;
}
assert confs.length == 1 : "invocation of the dialog for editing an entry sholdn't allow OK to be hit if the user chooses multiple launch configs in the dialog"; //$NON-NLS-1$
- el.name = confs[0].getName();
- el.data = confs[0];
- el.mode = dialog.getMode();
- el.action = dialog.getAction();
- el.actionParam = dialog.getActionParam();
+ applyFromDialog(el, dialog, confs[0]);
treeViewer.refresh(true);
updateWidgetEnablement();
updateLaunchConfigurationDialog();
}
}
+
+ private void applyFromDialog(GroupLaunchElement el, GroupLaunchConfigurationSelectionDialog dialog, ILaunchConfiguration config) {
+ el.name = config.getName();
+ el.data = config;
+ el.mode = dialog.getMode();
+ el.action = dialog.getAction();
+ el.adoptIfRunning = dialog.getAdoptIfRunning();
+ el.actionParam = dialog.getActionParam();
+ }
+
@Override
protected void deletePressed() {
int[] indices = getMultiSelectionIndices();

Back to the top