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.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.LaunchUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -36,18 +37,56 @@ public class MultiLaunchConfigurationDelegate 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 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 class LaunchElement {
|
||||
public static final String POST_LAUNCH_WAIT_FOR_TERM = "wait";
|
||||
public static final String POST_LAUNCH_CONTINUE = "";
|
||||
public static final String POST_LAUNCH_DELAY_3_SEC = "delay 3s";
|
||||
public static final String POST_LAUNCH_DELAY_PREFIX = "delay";
|
||||
public static enum EPostLaunchAction {
|
||||
NONE,
|
||||
WAIT_FOR_TERMINATION,
|
||||
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 boolean enabled;
|
||||
private String mode;
|
||||
private String action;
|
||||
private EPostLaunchAction action;
|
||||
private Object actionParam;
|
||||
private String name;
|
||||
private ILaunchConfiguration data;
|
||||
public void setName(String name) {
|
||||
|
@ -56,12 +95,16 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setAction(String action) {
|
||||
public void setAction(EPostLaunchAction action, Object actionParam) {
|
||||
this.action = action;
|
||||
this.actionParam = actionParam;
|
||||
}
|
||||
public String getAction() {
|
||||
public EPostLaunchAction getAction() {
|
||||
return action;
|
||||
}
|
||||
public Object getActionParam() {
|
||||
return actionParam;
|
||||
}
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
@ -218,7 +261,8 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
// So, fake another event now.
|
||||
listener.launchChanged(subLaunch);
|
||||
|
||||
postLaunchAction(subLaunch, le.getAction(), monitor);
|
||||
postLaunchAction(subLaunch, le.getAction(), le.getActionParam(), monitor);
|
||||
|
||||
|
||||
} catch (StackOverflowError e) {
|
||||
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
||||
|
@ -241,10 +285,13 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
}
|
||||
}
|
||||
|
||||
private void postLaunchAction(ILaunch subLaunch, String action, IProgressMonitor monitor) {
|
||||
if (action==null) return;
|
||||
if (LaunchElement.POST_LAUNCH_WAIT_FOR_TERM.equals(action)) {
|
||||
monitor.subTask("Waiting for termination of "+subLaunch.getLaunchConfiguration().getName());
|
||||
private void postLaunchAction(ILaunch subLaunch, EPostLaunchAction action, Object actionParam, IProgressMonitor monitor) {
|
||||
switch (action) {
|
||||
case NONE:
|
||||
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()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
|
@ -252,29 +299,23 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
break;
|
||||
}
|
||||
}
|
||||
monitor.subTask("");
|
||||
} else
|
||||
if (action.startsWith(LaunchElement.POST_LAUNCH_DELAY_PREFIX)) {
|
||||
String num = action.substring(LaunchElement.POST_LAUNCH_DELAY_PREFIX.length()).trim();
|
||||
int k = 1000;
|
||||
if (num.endsWith("ms")) {
|
||||
num = num.substring(0,num.length()-2);
|
||||
k = 1;
|
||||
} else if (num.endsWith("s")) {
|
||||
num = num.substring(0,num.length()-1);
|
||||
}
|
||||
int parseInt;
|
||||
try {
|
||||
parseInt = Integer.parseInt(num);
|
||||
} catch (NumberFormatException e) {
|
||||
parseInt = 3;
|
||||
k = 1000;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(parseInt * k);
|
||||
} catch (InterruptedException e) {
|
||||
// ok
|
||||
monitor.subTask(""); //$NON-NLS-1$
|
||||
break;
|
||||
case DELAY:
|
||||
Integer waitSecs = (Integer)actionParam;
|
||||
if (waitSecs != null) {
|
||||
monitor.subTask(LaunchMessages.getFormattedString("MultiLaunchConfigurationDelegate.Action.Delaying", //$NON-NLS-1$
|
||||
waitSecs.toString()));
|
||||
try {
|
||||
Thread.sleep(waitSecs * 1000); // param is milliseconds
|
||||
} 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,
|
||||
ArrayList<MultiLaunchConfigurationDelegate.LaunchElement> input) {
|
||||
try {
|
||||
Map attrs = configuration.getAttributes();
|
||||
for (Iterator iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||
Map<?,?> attrs = configuration.getAttributes();
|
||||
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||
String attr = (String) iterator.next();
|
||||
try {
|
||||
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
||||
|
@ -317,7 +358,18 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
||||
el.setIndex(index);
|
||||
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.setEnabled("true".equals(attrs.get(getProp(index, ENABLED_PROP)))); //$NON-NLS-1$
|
||||
try {
|
||||
|
@ -349,7 +401,9 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next();
|
||||
if (el == null) continue;
|
||||
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, ENABLED_PROP), el.isEnabled() + ""); //$NON-NLS-1$
|
||||
i++;
|
||||
|
@ -358,8 +412,8 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
|||
|
||||
public static void removeLaunchElements(ILaunchConfigurationWorkingCopy configuration) {
|
||||
try {
|
||||
Map attrs = configuration.getAttributes();
|
||||
for (Iterator iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||
Map<?,?> attrs = configuration.getAttributes();
|
||||
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||
String attr = (String) iterator.next();
|
||||
try {
|
||||
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.Cannot=Cannot launch ''{0}'' in the ''{1}'' mode
|
||||
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.1=Select a Launch Configuration and a Launch Mode
|
||||
MultiLaunchConfigurationSelectionDialog.4=Launch Mode:
|
||||
MultiLaunchConfigurationSelectionDialog.5=Use default mode when launching
|
||||
MultiLaunchConfigurationSelectionDialog.7=Select a Launch Configuration
|
||||
MultiLaunchConfigurationSelectionDialog.8=Post launch action:
|
||||
MultiLaunchConfigurationSelectionDialog.9=Seconds:
|
||||
MultiLaunchConfigurationSelectionDialog.10=Enter valid number of seconds
|
||||
MultiLaunchConfigurationTabGroup.1=Up
|
||||
MultiLaunchConfigurationTabGroup.2=Down
|
||||
MultiLaunchConfigurationTabGroup.3=Edit...
|
||||
|
@ -169,5 +176,8 @@ MultiLaunchConfigurationTabGroup.7=Mode
|
|||
MultiLaunchConfigurationTabGroup.8=Select Launch Configuration
|
||||
MultiLaunchConfigurationTabGroup.9=Edit Launch Configuration
|
||||
MultiLaunchConfigurationTabGroup.10=Launches
|
||||
MultiLaunchConfigurationTabGroup.11=seconds
|
||||
MultiLaunchConfigurationTabGroup.12=Action
|
||||
MultiLaunchConfigurationTabGroup.13=Delay {0} seconds
|
||||
ProjectRenameChange.name=Update 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.LaunchElement;
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||
import org.eclipse.cdt.launch.ui.ComboControlledStackComposite;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
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.ViewerFilter;
|
||||
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.SelectionEvent;
|
||||
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.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.ui.dialogs.FilteredTree;
|
||||
import org.eclipse.ui.dialogs.PatternFilter;
|
||||
|
@ -53,12 +57,15 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
|||
private ISelection fSelection;
|
||||
private ILaunchGroup[] launchGroups;
|
||||
private String mode;
|
||||
private String action;
|
||||
private EPostLaunchAction action = EPostLaunchAction.NONE;
|
||||
private Object actionParam;
|
||||
private boolean isDefaultMode;
|
||||
private ViewerFilter emptyTypeFilter;
|
||||
private IStructuredSelection fInitialSelection;
|
||||
private ComboControlledStackComposite fStackComposite;
|
||||
|
||||
private Label fDelayAmountLabel;
|
||||
private Text fDelayAmountWidget; // in seconds
|
||||
|
||||
public MultiLaunchConfigurationSelectionDialog(Shell shell, String title, String initMode) {
|
||||
super(shell);
|
||||
LaunchConfigurationManager manager = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
|
||||
|
@ -178,20 +185,54 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
|||
|
||||
private void createPostLaunchControl(Composite parent) {
|
||||
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));
|
||||
Label label = new Label(comp, SWT.NONE);
|
||||
label.setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.8")); //$NON-NLS-1$
|
||||
Combo combo = new Combo(comp, SWT.READ_ONLY);
|
||||
combo.add(LaunchElement.POST_LAUNCH_CONTINUE);
|
||||
combo.add(LaunchElement.POST_LAUNCH_WAIT_FOR_TERM);
|
||||
combo.add(LaunchElement.POST_LAUNCH_DELAY_3_SEC);
|
||||
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.NONE));
|
||||
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.WAIT_FOR_TERMINATION));
|
||||
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.DELAY));
|
||||
combo.addSelectionListener(new SelectionAdapter() {
|
||||
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() {
|
||||
|
@ -207,10 +248,14 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
|||
return isDefaultMode ? MultiLaunchConfigurationDelegate.DEFAULT_MODE : mode;
|
||||
}
|
||||
|
||||
public String getAction(){
|
||||
public EPostLaunchAction getAction(){
|
||||
return action;
|
||||
}
|
||||
|
||||
public Object getActionParam(){
|
||||
return actionParam;
|
||||
}
|
||||
|
||||
public static MultiLaunchConfigurationSelectionDialog createDialog(Shell shell, String title, String groupId) {
|
||||
return new MultiLaunchConfigurationSelectionDialog(shell, title, groupId);
|
||||
}
|
||||
|
@ -243,8 +288,7 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
|||
boolean selectionIsForVisibleViewer = false;
|
||||
final Object src = event.getSource();
|
||||
if (src instanceof Viewer) {
|
||||
final Viewer viewer = (Viewer)src;
|
||||
final Control viewerControl = viewer.getControl();
|
||||
final Control viewerControl = ((Viewer)src).getControl();
|
||||
if (viewerControl == topTree) {
|
||||
selectionIsForVisibleViewer = true;
|
||||
}
|
||||
|
@ -260,17 +304,28 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
|||
|
||||
protected void validate() {
|
||||
Button ok_button = getButton(IDialogConstants.OK_ID);
|
||||
boolean isValid = true;
|
||||
if (getSelectedLaunchConfiguration() == null) {
|
||||
setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.7")); //$NON-NLS-1$
|
||||
if (ok_button!=null) ok_button.setEnabled(false);
|
||||
isValid = false;
|
||||
} else {
|
||||
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) {
|
||||
action = el.getAction();
|
||||
actionParam = el.getActionParam();
|
||||
isDefaultMode = el.getMode().equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE);
|
||||
fInitialSelection = new StructuredSelection(el.getData());
|
||||
fSelection = fInitialSelection;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
||||
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.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
|
@ -56,9 +57,10 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
input = null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // nothing we can do about this
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
if (newInput instanceof ArrayList)
|
||||
input = (ArrayList) newInput;
|
||||
if (newInput instanceof ArrayList<?>)
|
||||
input = (ArrayList<LaunchElement>) newInput;
|
||||
}
|
||||
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
|
@ -106,16 +108,37 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
if (!(element instanceof MultiLaunchConfigurationDelegate.LaunchElement))
|
||||
return null;
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
|
||||
if (columnIndex == 0)
|
||||
|
||||
// launch name
|
||||
if (columnIndex == 0) {
|
||||
try {
|
||||
return (el.getData() != null) ? el.getData().getType().getName() + "::" + el.getName() : el.getName(); //$NON-NLS-1$
|
||||
} catch (CoreException e) {
|
||||
return el.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// launch mode
|
||||
if (columnIndex == 1)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +213,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
}
|
||||
static class GroupLaunchTab extends AbstractLaunchConfigurationTab {
|
||||
protected CheckboxTreeViewer treeViewer;
|
||||
protected ArrayList input = new ArrayList();
|
||||
protected ArrayList<LaunchElement> input = new ArrayList<LaunchElement>();
|
||||
private 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.setWidth(100);
|
||||
TreeColumn col3 = new TreeColumn(table, SWT.NONE);
|
||||
col3.setText("Action");
|
||||
col3.setText(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.12")); //$NON-NLS-1$
|
||||
col3.setWidth(100);
|
||||
|
||||
treeViewer.setInput(input);
|
||||
|
@ -236,7 +259,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
el.setName(conf.getName());
|
||||
el.setData(conf);
|
||||
el.setMode(dialog.getMode());
|
||||
el.setAction(dialog.getAction());
|
||||
el.setAction(dialog.getAction(), dialog.getActionParam());
|
||||
treeViewer.refresh(true);
|
||||
treeViewer.setChecked(el, el.isEnabled());
|
||||
updateWidgetEnablement();
|
||||
|
@ -256,8 +279,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
int index = getSelIndex();
|
||||
if (index < 0)
|
||||
return;
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) input
|
||||
.get(index);
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index);
|
||||
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog.createDialog(treeViewer
|
||||
.getControl().getShell(), LaunchMessages.getString("MultiLaunchConfigurationTabGroup.9"), //$NON-NLS-1$
|
||||
el.getMode()
|
||||
|
@ -269,7 +291,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
el.setName(conf.getName());
|
||||
el.setData(conf);
|
||||
el.setMode(dialog.getMode());
|
||||
el.setAction(dialog.getAction());
|
||||
el.setAction(dialog.getAction(), dialog.getActionParam());
|
||||
treeViewer.refresh(true);
|
||||
updateWidgetEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
|
@ -298,8 +320,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
if (!isDownEnabled()) return;
|
||||
int index = getSelIndex();
|
||||
|
||||
MultiLaunchConfigurationDelegate.LaunchElement x = (MultiLaunchConfigurationDelegate.LaunchElement) input
|
||||
.get(index);
|
||||
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||
input.set(index, input.get(index + 1));
|
||||
input.set(index + 1, x);
|
||||
treeViewer.refresh(true);
|
||||
|
@ -324,8 +345,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
protected void upPressed() {
|
||||
if (!isUpEnabled()) return;
|
||||
int index = getSelIndex();
|
||||
MultiLaunchConfigurationDelegate.LaunchElement x = (MultiLaunchConfigurationDelegate.LaunchElement) input
|
||||
.get(index);
|
||||
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||
input.set(index, input.get(index - 1));
|
||||
input.set(index - 1, x);
|
||||
treeViewer.refresh(true);
|
||||
|
@ -365,9 +385,8 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
|||
public void initializeFrom(ILaunchConfiguration configuration) {
|
||||
MultiLaunchConfigurationDelegate.createLaunchElements(configuration, input);
|
||||
if (treeViewer != null) {
|
||||
for (Iterator iterator = input.iterator(); iterator.hasNext();) {
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) iterator
|
||||
.next();
|
||||
for (Iterator<LaunchElement> iterator = input.iterator(); iterator.hasNext();) {
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = iterator.next();
|
||||
treeViewer.setChecked(el, el.isEnabled());
|
||||
}
|
||||
treeViewer.refresh(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue