mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 276419: Improvements to post-launch actions (in Launch Group feature)
This commit is contained in:
parent
352aaaa924
commit
48b8dc1794
4 changed files with 210 additions and 72 deletions
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -37,17 +38,55 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
private static final String ENABLED_PROP = "enabled"; //$NON-NLS-1$
|
private static final String ENABLED_PROP = "enabled"; //$NON-NLS-1$
|
||||||
private static final String MODE_PROP = "mode"; //$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_PROP = "action"; //$NON-NLS-1$
|
||||||
|
private static final String ACTION_PARAM_PROP = "actionParam"; //$NON-NLS-1$
|
||||||
public static String MULTI_LAUNCH_CONSTANTS_PREFIX = "org.eclipse.cdt.launch.launchGroup"; //$NON-NLS-1$
|
public static String MULTI_LAUNCH_CONSTANTS_PREFIX = "org.eclipse.cdt.launch.launchGroup"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static class LaunchElement {
|
public static class LaunchElement {
|
||||||
public static final String POST_LAUNCH_WAIT_FOR_TERM = "wait";
|
public static enum EPostLaunchAction {
|
||||||
public static final String POST_LAUNCH_CONTINUE = "";
|
NONE,
|
||||||
public static final String POST_LAUNCH_DELAY_3_SEC = "delay 3s";
|
WAIT_FOR_TERMINATION,
|
||||||
public static final String POST_LAUNCH_DELAY_PREFIX = "delay";
|
DELAY
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Allows us decouple the enum identifier in the code from its textual representation in the GUI
|
||||||
|
*/
|
||||||
|
public static String actionEnumToStr(EPostLaunchAction action) {
|
||||||
|
switch (action) {
|
||||||
|
case NONE:
|
||||||
|
return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.None"); //$NON-NLS-1$
|
||||||
|
case WAIT_FOR_TERMINATION:
|
||||||
|
return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.WaitUntilTerminated"); //$NON-NLS-1$
|
||||||
|
case DELAY:
|
||||||
|
return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.Delay"); //$NON-NLS-1$
|
||||||
|
default:
|
||||||
|
assert false : "new post launch action type is missing logic"; //$NON-NLS-1$
|
||||||
|
return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.None"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Allows us decouple the enum identifier in the code from its textual representation in the GUI
|
||||||
|
*/
|
||||||
|
public static EPostLaunchAction strToActionEnum(String str) {
|
||||||
|
if (str.equals(LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.None"))) { //$NON-NLS-1$
|
||||||
|
return EPostLaunchAction.NONE;
|
||||||
|
}
|
||||||
|
else if (str.equals(LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.WaitUntilTerminated"))) { //$NON-NLS-1$
|
||||||
|
return EPostLaunchAction.WAIT_FOR_TERMINATION;
|
||||||
|
}
|
||||||
|
else if (str.equals(LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.Delay"))) { //$NON-NLS-1$
|
||||||
|
return EPostLaunchAction.DELAY;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert false : "new post launch action type is missing logic"; //$NON-NLS-1$
|
||||||
|
return EPostLaunchAction.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int index;
|
private int index;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private String mode;
|
private String mode;
|
||||||
private String action;
|
private EPostLaunchAction action;
|
||||||
|
private Object actionParam;
|
||||||
private String name;
|
private String name;
|
||||||
private ILaunchConfiguration data;
|
private ILaunchConfiguration data;
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
@ -56,12 +95,16 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
public void setAction(String action) {
|
public void setAction(EPostLaunchAction action, Object actionParam) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
this.actionParam = actionParam;
|
||||||
}
|
}
|
||||||
public String getAction() {
|
public EPostLaunchAction getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
public Object getActionParam() {
|
||||||
|
return actionParam;
|
||||||
|
}
|
||||||
public void setMode(String mode) {
|
public void setMode(String mode) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +261,8 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
// So, fake another event now.
|
// So, fake another event now.
|
||||||
listener.launchChanged(subLaunch);
|
listener.launchChanged(subLaunch);
|
||||||
|
|
||||||
postLaunchAction(subLaunch, le.getAction(), monitor);
|
postLaunchAction(subLaunch, le.getAction(), le.getActionParam(), monitor);
|
||||||
|
|
||||||
|
|
||||||
} catch (StackOverflowError e) {
|
} catch (StackOverflowError e) {
|
||||||
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
||||||
|
@ -241,10 +285,13 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postLaunchAction(ILaunch subLaunch, String action, IProgressMonitor monitor) {
|
private void postLaunchAction(ILaunch subLaunch, EPostLaunchAction action, Object actionParam, IProgressMonitor monitor) {
|
||||||
if (action==null) return;
|
switch (action) {
|
||||||
if (LaunchElement.POST_LAUNCH_WAIT_FOR_TERM.equals(action)) {
|
case NONE:
|
||||||
monitor.subTask("Waiting for termination of "+subLaunch.getLaunchConfiguration().getName());
|
return;
|
||||||
|
case WAIT_FOR_TERMINATION:
|
||||||
|
|
||||||
|
monitor.subTask(LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.WaitingForTermination") + " " + subLaunch.getLaunchConfiguration().getName()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
while (!subLaunch.isTerminated() && !monitor.isCanceled()) {
|
while (!subLaunch.isTerminated() && !monitor.isCanceled()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -252,29 +299,23 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
monitor.subTask("");
|
monitor.subTask(""); //$NON-NLS-1$
|
||||||
} else
|
break;
|
||||||
if (action.startsWith(LaunchElement.POST_LAUNCH_DELAY_PREFIX)) {
|
case DELAY:
|
||||||
String num = action.substring(LaunchElement.POST_LAUNCH_DELAY_PREFIX.length()).trim();
|
Integer waitSecs = (Integer)actionParam;
|
||||||
int k = 1000;
|
if (waitSecs != null) {
|
||||||
if (num.endsWith("ms")) {
|
monitor.subTask(LaunchMessages.getFormattedString("MultiLaunchConfigurationDelegate.Action.Delaying", //$NON-NLS-1$
|
||||||
num = num.substring(0,num.length()-2);
|
waitSecs.toString()));
|
||||||
k = 1;
|
try {
|
||||||
} else if (num.endsWith("s")) {
|
Thread.sleep(waitSecs * 1000); // param is milliseconds
|
||||||
num = num.substring(0,num.length()-1);
|
} catch (InterruptedException e) {
|
||||||
}
|
// ok
|
||||||
int parseInt;
|
}
|
||||||
try {
|
|
||||||
parseInt = Integer.parseInt(num);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
parseInt = 3;
|
|
||||||
k = 1000;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(parseInt * k);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// ok
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert false : "new post launch action type is missing logic"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +343,8 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
public static ArrayList<LaunchElement> createLaunchElements(ILaunchConfiguration configuration,
|
public static ArrayList<LaunchElement> createLaunchElements(ILaunchConfiguration configuration,
|
||||||
ArrayList<MultiLaunchConfigurationDelegate.LaunchElement> input) {
|
ArrayList<MultiLaunchConfigurationDelegate.LaunchElement> input) {
|
||||||
try {
|
try {
|
||||||
Map attrs = configuration.getAttributes();
|
Map<?,?> attrs = configuration.getAttributes();
|
||||||
for (Iterator iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||||
String attr = (String) iterator.next();
|
String attr = (String) iterator.next();
|
||||||
try {
|
try {
|
||||||
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
||||||
|
@ -317,7 +358,18 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
||||||
el.setIndex(index);
|
el.setIndex(index);
|
||||||
el.setName((String) attrs.get(attr));
|
el.setName((String) attrs.get(attr));
|
||||||
el.setAction((String) attrs.get(getProp(index, ACTION_PROP)));
|
|
||||||
|
Object actionParam = null;
|
||||||
|
final EPostLaunchAction action = EPostLaunchAction.valueOf((String)attrs.get(getProp(index, ACTION_PROP)));
|
||||||
|
if (action == EPostLaunchAction.DELAY) {
|
||||||
|
try {
|
||||||
|
actionParam = Integer.parseInt((String)attrs.get(getProp(index, ACTION_PARAM_PROP)));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException exc) {
|
||||||
|
LaunchUIPlugin.log(exc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
el.setAction(action, actionParam);
|
||||||
el.setMode((String) attrs.get(getProp(index, MODE_PROP)));
|
el.setMode((String) attrs.get(getProp(index, MODE_PROP)));
|
||||||
el.setEnabled("true".equals(attrs.get(getProp(index, ENABLED_PROP)))); //$NON-NLS-1$
|
el.setEnabled("true".equals(attrs.get(getProp(index, ENABLED_PROP)))); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
|
@ -349,7 +401,9 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next();
|
MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next();
|
||||||
if (el == null) continue;
|
if (el == null) continue;
|
||||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, NAME_PROP), el.getName());
|
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, NAME_PROP), el.getName());
|
||||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ACTION_PROP), el.getAction());
|
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ACTION_PROP), el.getAction().toString());
|
||||||
|
// 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(MultiLaunchConfigurationDelegate.getProp(i, ACTION_PARAM_PROP), el.getActionParam() != null ? el.getActionParam().toString() : null);
|
||||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, MODE_PROP), el.getMode());
|
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, MODE_PROP), el.getMode());
|
||||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ENABLED_PROP), el.isEnabled() + ""); //$NON-NLS-1$
|
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ENABLED_PROP), el.isEnabled() + ""); //$NON-NLS-1$
|
||||||
i++;
|
i++;
|
||||||
|
@ -358,8 +412,8 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
|
|
||||||
public static void removeLaunchElements(ILaunchConfigurationWorkingCopy configuration) {
|
public static void removeLaunchElements(ILaunchConfigurationWorkingCopy configuration) {
|
||||||
try {
|
try {
|
||||||
Map attrs = configuration.getAttributes();
|
Map<?,?> attrs = configuration.getAttributes();
|
||||||
for (Iterator iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||||
String attr = (String) iterator.next();
|
String attr = (String) iterator.next();
|
||||||
try {
|
try {
|
||||||
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
||||||
|
|
|
@ -153,12 +153,19 @@ LocalCDILaunchDelegate.10=Failed to set program arguments, environment or workin
|
||||||
MultiLaunchConfigurationDelegate.0=Launching
|
MultiLaunchConfigurationDelegate.0=Launching
|
||||||
MultiLaunchConfigurationDelegate.Cannot=Cannot launch ''{0}'' in the ''{1}'' mode
|
MultiLaunchConfigurationDelegate.Cannot=Cannot launch ''{0}'' in the ''{1}'' mode
|
||||||
MultiLaunchConfigurationDelegate.Loop=Infinite loop detected for ''{0}'' configuration
|
MultiLaunchConfigurationDelegate.Loop=Infinite loop detected for ''{0}'' configuration
|
||||||
|
MultiLaunchConfigurationDelegate.Action.None=None
|
||||||
|
MultiLaunchConfigurationDelegate.Action.WaitUntilTerminated=Wait until terminated
|
||||||
|
MultiLaunchConfigurationDelegate.Action.Delay=Delay
|
||||||
|
MultiLaunchConfigurationDelegate.Action.WaitingForTermination=Waiting for termination of
|
||||||
|
MultiLaunchConfigurationDelegate.Action.Delaying=Delaying next launch by {0} seconds
|
||||||
MultiLaunchConfigurationSelectionDialog.0=Launch Configuration Selector
|
MultiLaunchConfigurationSelectionDialog.0=Launch Configuration Selector
|
||||||
MultiLaunchConfigurationSelectionDialog.1=Select a Launch Configuration and a Launch Mode
|
MultiLaunchConfigurationSelectionDialog.1=Select a Launch Configuration and a Launch Mode
|
||||||
MultiLaunchConfigurationSelectionDialog.4=Launch Mode:
|
MultiLaunchConfigurationSelectionDialog.4=Launch Mode:
|
||||||
MultiLaunchConfigurationSelectionDialog.5=Use default mode when launching
|
MultiLaunchConfigurationSelectionDialog.5=Use default mode when launching
|
||||||
MultiLaunchConfigurationSelectionDialog.7=Select a Launch Configuration
|
MultiLaunchConfigurationSelectionDialog.7=Select a Launch Configuration
|
||||||
MultiLaunchConfigurationSelectionDialog.8=Post launch action:
|
MultiLaunchConfigurationSelectionDialog.8=Post launch action:
|
||||||
|
MultiLaunchConfigurationSelectionDialog.9=Seconds:
|
||||||
|
MultiLaunchConfigurationSelectionDialog.10=Enter valid number of seconds
|
||||||
MultiLaunchConfigurationTabGroup.1=Up
|
MultiLaunchConfigurationTabGroup.1=Up
|
||||||
MultiLaunchConfigurationTabGroup.2=Down
|
MultiLaunchConfigurationTabGroup.2=Down
|
||||||
MultiLaunchConfigurationTabGroup.3=Edit...
|
MultiLaunchConfigurationTabGroup.3=Edit...
|
||||||
|
@ -169,5 +176,8 @@ MultiLaunchConfigurationTabGroup.7=Mode
|
||||||
MultiLaunchConfigurationTabGroup.8=Select Launch Configuration
|
MultiLaunchConfigurationTabGroup.8=Select Launch Configuration
|
||||||
MultiLaunchConfigurationTabGroup.9=Edit Launch Configuration
|
MultiLaunchConfigurationTabGroup.9=Edit Launch Configuration
|
||||||
MultiLaunchConfigurationTabGroup.10=Launches
|
MultiLaunchConfigurationTabGroup.10=Launches
|
||||||
|
MultiLaunchConfigurationTabGroup.11=seconds
|
||||||
|
MultiLaunchConfigurationTabGroup.12=Action
|
||||||
|
MultiLaunchConfigurationTabGroup.13=Delay {0} seconds
|
||||||
ProjectRenameChange.name=Update launch configuration "{0}"
|
ProjectRenameChange.name=Update launch configuration "{0}"
|
||||||
ProjectRenameChange.saveFailed=Failed to save updated launch configuration "{0}"
|
ProjectRenameChange.saveFailed=Failed to save updated launch configuration "{0}"
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
||||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement;
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement;
|
||||||
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||||
import org.eclipse.cdt.launch.ui.ComboControlledStackComposite;
|
import org.eclipse.cdt.launch.ui.ComboControlledStackComposite;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
@ -28,6 +29,8 @@ import org.eclipse.jface.viewers.TreeViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerFilter;
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
@ -39,6 +42,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.ui.dialogs.FilteredTree;
|
import org.eclipse.ui.dialogs.FilteredTree;
|
||||||
import org.eclipse.ui.dialogs.PatternFilter;
|
import org.eclipse.ui.dialogs.PatternFilter;
|
||||||
|
@ -53,11 +57,14 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
private ISelection fSelection;
|
private ISelection fSelection;
|
||||||
private ILaunchGroup[] launchGroups;
|
private ILaunchGroup[] launchGroups;
|
||||||
private String mode;
|
private String mode;
|
||||||
private String action;
|
private EPostLaunchAction action = EPostLaunchAction.NONE;
|
||||||
|
private Object actionParam;
|
||||||
private boolean isDefaultMode;
|
private boolean isDefaultMode;
|
||||||
private ViewerFilter emptyTypeFilter;
|
private ViewerFilter emptyTypeFilter;
|
||||||
private IStructuredSelection fInitialSelection;
|
private IStructuredSelection fInitialSelection;
|
||||||
private ComboControlledStackComposite fStackComposite;
|
private ComboControlledStackComposite fStackComposite;
|
||||||
|
private Label fDelayAmountLabel;
|
||||||
|
private Text fDelayAmountWidget; // in seconds
|
||||||
|
|
||||||
public MultiLaunchConfigurationSelectionDialog(Shell shell, String title, String initMode) {
|
public MultiLaunchConfigurationSelectionDialog(Shell shell, String title, String initMode) {
|
||||||
super(shell);
|
super(shell);
|
||||||
|
@ -178,20 +185,54 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
|
|
||||||
private void createPostLaunchControl(Composite parent) {
|
private void createPostLaunchControl(Composite parent) {
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
comp.setLayout(new GridLayout(2, false));
|
comp.setLayout(new GridLayout(4, false));
|
||||||
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
Label label = new Label(comp, SWT.NONE);
|
Label label = new Label(comp, SWT.NONE);
|
||||||
label.setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.8")); //$NON-NLS-1$
|
label.setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.8")); //$NON-NLS-1$
|
||||||
Combo combo = new Combo(comp, SWT.READ_ONLY);
|
Combo combo = new Combo(comp, SWT.READ_ONLY);
|
||||||
combo.add(LaunchElement.POST_LAUNCH_CONTINUE);
|
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.NONE));
|
||||||
combo.add(LaunchElement.POST_LAUNCH_WAIT_FOR_TERM);
|
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.WAIT_FOR_TERMINATION));
|
||||||
combo.add(LaunchElement.POST_LAUNCH_DELAY_3_SEC);
|
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.DELAY));
|
||||||
combo.addSelectionListener(new SelectionAdapter() {
|
combo.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
action = ((Combo) e.widget).getText();
|
final String actionStr = ((Combo) e.widget).getText();
|
||||||
|
action = MultiLaunchConfigurationDelegate.LaunchElement.strToActionEnum(actionStr);
|
||||||
|
showHideDelayAmountWidgets();
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
combo.setText(action==null?LaunchElement.POST_LAUNCH_CONTINUE:action);
|
combo.setText(MultiLaunchConfigurationDelegate.LaunchElement.actionEnumToStr(action));
|
||||||
|
|
||||||
|
fDelayAmountLabel = new Label(comp, SWT.NONE);
|
||||||
|
fDelayAmountLabel.setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.9")); //$NON-NLS-1$
|
||||||
|
|
||||||
|
fDelayAmountWidget = new Text(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
GridData gridData = new GridData();
|
||||||
|
gridData.widthHint = convertWidthInCharsToPixels(8);
|
||||||
|
fDelayAmountWidget.setLayoutData(gridData);
|
||||||
|
fDelayAmountWidget.addModifyListener(new ModifyListener(){
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
String text = ((Text)e.widget).getText();
|
||||||
|
try {
|
||||||
|
actionParam = new Integer(Integer.parseInt(text));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException exc) {
|
||||||
|
actionParam = null;
|
||||||
|
}
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (actionParam instanceof Integer) {
|
||||||
|
fDelayAmountWidget.setText(((Integer)actionParam).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
showHideDelayAmountWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showHideDelayAmountWidgets() {
|
||||||
|
final boolean visible = action == EPostLaunchAction.DELAY;
|
||||||
|
fDelayAmountLabel.setVisible(visible);
|
||||||
|
fDelayAmountWidget.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILaunchConfiguration getSelectedLaunchConfiguration() {
|
public ILaunchConfiguration getSelectedLaunchConfiguration() {
|
||||||
|
@ -207,10 +248,14 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
return isDefaultMode ? MultiLaunchConfigurationDelegate.DEFAULT_MODE : mode;
|
return isDefaultMode ? MultiLaunchConfigurationDelegate.DEFAULT_MODE : mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAction(){
|
public EPostLaunchAction getAction(){
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getActionParam(){
|
||||||
|
return actionParam;
|
||||||
|
}
|
||||||
|
|
||||||
public static MultiLaunchConfigurationSelectionDialog createDialog(Shell shell, String title, String groupId) {
|
public static MultiLaunchConfigurationSelectionDialog createDialog(Shell shell, String title, String groupId) {
|
||||||
return new MultiLaunchConfigurationSelectionDialog(shell, title, groupId);
|
return new MultiLaunchConfigurationSelectionDialog(shell, title, groupId);
|
||||||
}
|
}
|
||||||
|
@ -243,8 +288,7 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
boolean selectionIsForVisibleViewer = false;
|
boolean selectionIsForVisibleViewer = false;
|
||||||
final Object src = event.getSource();
|
final Object src = event.getSource();
|
||||||
if (src instanceof Viewer) {
|
if (src instanceof Viewer) {
|
||||||
final Viewer viewer = (Viewer)src;
|
final Control viewerControl = ((Viewer)src).getControl();
|
||||||
final Control viewerControl = viewer.getControl();
|
|
||||||
if (viewerControl == topTree) {
|
if (viewerControl == topTree) {
|
||||||
selectionIsForVisibleViewer = true;
|
selectionIsForVisibleViewer = true;
|
||||||
}
|
}
|
||||||
|
@ -260,17 +304,28 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
|
|
||||||
protected void validate() {
|
protected void validate() {
|
||||||
Button ok_button = getButton(IDialogConstants.OK_ID);
|
Button ok_button = getButton(IDialogConstants.OK_ID);
|
||||||
|
boolean isValid = true;
|
||||||
if (getSelectedLaunchConfiguration() == null) {
|
if (getSelectedLaunchConfiguration() == null) {
|
||||||
setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.7")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.7")); //$NON-NLS-1$
|
||||||
if (ok_button!=null) ok_button.setEnabled(false);
|
isValid = false;
|
||||||
} else {
|
} else {
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
if (ok_button!=null) ok_button.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
if (action == EPostLaunchAction.DELAY) {
|
||||||
|
isValid = (actionParam instanceof Integer) && ((Integer)actionParam > 0);
|
||||||
|
setErrorMessage(isValid ? null : LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.10")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok_button != null)
|
||||||
|
ok_button.setEnabled(isValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInitialSelection(LaunchElement el) {
|
public void setInitialSelection(LaunchElement el) {
|
||||||
action = el.getAction();
|
action = el.getAction();
|
||||||
|
actionParam = el.getActionParam();
|
||||||
isDefaultMode = el.getMode().equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE);
|
isDefaultMode = el.getMode().equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE);
|
||||||
fInitialSelection = new StructuredSelection(el.getData());
|
fInitialSelection = new StructuredSelection(el.getData());
|
||||||
fSelection = fInitialSelection;
|
fSelection = fInitialSelection;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
||||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement;
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement;
|
||||||
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||||
import org.eclipse.cdt.launch.ui.CommonTabLite;
|
import org.eclipse.cdt.launch.ui.CommonTabLite;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
@ -56,9 +57,10 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
input = null;
|
input = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked") // nothing we can do about this
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
if (newInput instanceof ArrayList)
|
if (newInput instanceof ArrayList<?>)
|
||||||
input = (ArrayList) newInput;
|
input = (ArrayList<LaunchElement>) newInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
|
@ -106,16 +108,37 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
if (!(element instanceof MultiLaunchConfigurationDelegate.LaunchElement))
|
if (!(element instanceof MultiLaunchConfigurationDelegate.LaunchElement))
|
||||||
return null;
|
return null;
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
|
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
|
||||||
if (columnIndex == 0)
|
|
||||||
|
// launch name
|
||||||
|
if (columnIndex == 0) {
|
||||||
try {
|
try {
|
||||||
return (el.getData() != null) ? el.getData().getType().getName() + "::" + el.getName() : el.getName(); //$NON-NLS-1$
|
return (el.getData() != null) ? el.getData().getType().getName() + "::" + el.getName() : el.getName(); //$NON-NLS-1$
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return el.getName();
|
return el.getName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// launch mode
|
||||||
if (columnIndex == 1)
|
if (columnIndex == 1)
|
||||||
return el.getMode();
|
return el.getMode();
|
||||||
if (columnIndex == 2)
|
|
||||||
return el.getAction();
|
// launch post action
|
||||||
|
if (columnIndex == 2) {
|
||||||
|
EPostLaunchAction action = el.getAction();
|
||||||
|
switch (action) {
|
||||||
|
case NONE:
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
case WAIT_FOR_TERMINATION:
|
||||||
|
return LaunchMessages.getString("MultiLaunchConfigurationDelegate.Action.WaitUntilTerminated"); //$NON-NLS-1$
|
||||||
|
case DELAY:
|
||||||
|
final Object actionParam = el.getActionParam();
|
||||||
|
return LaunchMessages.getFormattedString("MultiLaunchConfigurationTabGroup.13", //$NON-NLS-1$
|
||||||
|
actionParam instanceof Integer ? Integer.toString((Integer)actionParam) : "?"); //$NON-NLS-1$
|
||||||
|
default:
|
||||||
|
assert false : "new post launch action missing logic here"; //$NON-NLS-1$
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +213,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
}
|
}
|
||||||
static class GroupLaunchTab extends AbstractLaunchConfigurationTab {
|
static class GroupLaunchTab extends AbstractLaunchConfigurationTab {
|
||||||
protected CheckboxTreeViewer treeViewer;
|
protected CheckboxTreeViewer treeViewer;
|
||||||
protected ArrayList input = new ArrayList();
|
protected ArrayList<LaunchElement> input = new ArrayList<LaunchElement>();
|
||||||
private String mode;
|
private String mode;
|
||||||
|
|
||||||
public GroupLaunchTab(String mode) {
|
public GroupLaunchTab(String mode) {
|
||||||
|
@ -216,7 +239,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
col2.setText(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.7")); //$NON-NLS-1$
|
col2.setText(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.7")); //$NON-NLS-1$
|
||||||
col2.setWidth(100);
|
col2.setWidth(100);
|
||||||
TreeColumn col3 = new TreeColumn(table, SWT.NONE);
|
TreeColumn col3 = new TreeColumn(table, SWT.NONE);
|
||||||
col3.setText("Action");
|
col3.setText(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.12")); //$NON-NLS-1$
|
||||||
col3.setWidth(100);
|
col3.setWidth(100);
|
||||||
|
|
||||||
treeViewer.setInput(input);
|
treeViewer.setInput(input);
|
||||||
|
@ -236,7 +259,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
el.setName(conf.getName());
|
el.setName(conf.getName());
|
||||||
el.setData(conf);
|
el.setData(conf);
|
||||||
el.setMode(dialog.getMode());
|
el.setMode(dialog.getMode());
|
||||||
el.setAction(dialog.getAction());
|
el.setAction(dialog.getAction(), dialog.getActionParam());
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
treeViewer.setChecked(el, el.isEnabled());
|
treeViewer.setChecked(el, el.isEnabled());
|
||||||
updateWidgetEnablement();
|
updateWidgetEnablement();
|
||||||
|
@ -256,8 +279,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
int index = getSelIndex();
|
int index = getSelIndex();
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) input
|
MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index);
|
||||||
.get(index);
|
|
||||||
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog.createDialog(treeViewer
|
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog.createDialog(treeViewer
|
||||||
.getControl().getShell(), LaunchMessages.getString("MultiLaunchConfigurationTabGroup.9"), //$NON-NLS-1$
|
.getControl().getShell(), LaunchMessages.getString("MultiLaunchConfigurationTabGroup.9"), //$NON-NLS-1$
|
||||||
el.getMode()
|
el.getMode()
|
||||||
|
@ -269,7 +291,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
el.setName(conf.getName());
|
el.setName(conf.getName());
|
||||||
el.setData(conf);
|
el.setData(conf);
|
||||||
el.setMode(dialog.getMode());
|
el.setMode(dialog.getMode());
|
||||||
el.setAction(dialog.getAction());
|
el.setAction(dialog.getAction(), dialog.getActionParam());
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
updateWidgetEnablement();
|
updateWidgetEnablement();
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
|
@ -298,8 +320,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
if (!isDownEnabled()) return;
|
if (!isDownEnabled()) return;
|
||||||
int index = getSelIndex();
|
int index = getSelIndex();
|
||||||
|
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement x = (MultiLaunchConfigurationDelegate.LaunchElement) input
|
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||||
.get(index);
|
|
||||||
input.set(index, input.get(index + 1));
|
input.set(index, input.get(index + 1));
|
||||||
input.set(index + 1, x);
|
input.set(index + 1, x);
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
|
@ -324,8 +345,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
protected void upPressed() {
|
protected void upPressed() {
|
||||||
if (!isUpEnabled()) return;
|
if (!isUpEnabled()) return;
|
||||||
int index = getSelIndex();
|
int index = getSelIndex();
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement x = (MultiLaunchConfigurationDelegate.LaunchElement) input
|
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||||
.get(index);
|
|
||||||
input.set(index, input.get(index - 1));
|
input.set(index, input.get(index - 1));
|
||||||
input.set(index - 1, x);
|
input.set(index - 1, x);
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
|
@ -365,9 +385,8 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
public void initializeFrom(ILaunchConfiguration configuration) {
|
public void initializeFrom(ILaunchConfiguration configuration) {
|
||||||
MultiLaunchConfigurationDelegate.createLaunchElements(configuration, input);
|
MultiLaunchConfigurationDelegate.createLaunchElements(configuration, input);
|
||||||
if (treeViewer != null) {
|
if (treeViewer != null) {
|
||||||
for (Iterator iterator = input.iterator(); iterator.hasNext();) {
|
for (Iterator<LaunchElement> iterator = input.iterator(); iterator.hasNext();) {
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) iterator
|
MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next();
|
||||||
.next();
|
|
||||||
treeViewer.setChecked(el, el.isEnabled());
|
treeViewer.setChecked(el, el.isEnabled());
|
||||||
}
|
}
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue