mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
Bugzilla 276498: Support multiple selection in Launch Group feature
This commit is contained in:
parent
cff7d18b90
commit
7e22c45fe6
4 changed files with 134 additions and 82 deletions
|
@ -3,6 +3,7 @@ package org.eclipse.cdt.launch.internal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||||
|
@ -218,7 +219,7 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES,
|
DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final ArrayList<LaunchElement> input = createLaunchElements(configuration, new ArrayList<LaunchElement>());
|
final List<LaunchElement> input = createLaunchElements(configuration, new ArrayList<LaunchElement>());
|
||||||
MultiLaunchListener listener = new MultiLaunchListener(launch);
|
MultiLaunchListener listener = new MultiLaunchListener(launch);
|
||||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||||
launchManager.addLaunchListener(listener); // listener removed when launch is removed
|
launchManager.addLaunchListener(listener); // listener removed when launch is removed
|
||||||
|
@ -340,8 +341,8 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<LaunchElement> createLaunchElements(ILaunchConfiguration configuration,
|
public static List<LaunchElement> createLaunchElements(ILaunchConfiguration configuration,
|
||||||
ArrayList<MultiLaunchConfigurationDelegate.LaunchElement> input) {
|
List<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();) {
|
||||||
|
@ -394,11 +395,10 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeLaunchElements(ILaunchConfigurationWorkingCopy configuration, ArrayList<LaunchElement> input) {
|
public static void storeLaunchElements(ILaunchConfigurationWorkingCopy configuration, List<LaunchElement> input) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
removeLaunchElements(configuration);
|
removeLaunchElements(configuration);
|
||||||
for (Iterator<LaunchElement> iterator = input.iterator(); iterator.hasNext();) {
|
for (LaunchElement el : input) {
|
||||||
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().toString());
|
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ACTION_PROP), el.getAction().toString());
|
||||||
|
|
|
@ -159,13 +159,17 @@ MultiLaunchConfigurationDelegate.Action.Delay=Delay
|
||||||
MultiLaunchConfigurationDelegate.Action.WaitingForTermination=Waiting for termination of
|
MultiLaunchConfigurationDelegate.Action.WaitingForTermination=Waiting for termination of
|
||||||
MultiLaunchConfigurationDelegate.Action.Delaying=Delaying next launch by {0} seconds
|
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.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.9=Seconds:
|
||||||
MultiLaunchConfigurationSelectionDialog.10=Enter valid number of seconds
|
MultiLaunchConfigurationSelectionDialog.10=Enter valid number of seconds
|
||||||
|
MultiLaunchConfigurationSelectionDialog.11=Select only one launch configuration
|
||||||
|
MultiLaunchConfigurationSelectionDialog.12=Add Launch Configuration
|
||||||
|
MultiLaunchConfigurationSelectionDialog.13=Edit Launch Configuration
|
||||||
|
MultiLaunchConfigurationSelectionDialog.14=Add one or more launch configurations to the launch group
|
||||||
|
MultiLaunchConfigurationSelectionDialog.15=Edit an existing entry in the launch group
|
||||||
MultiLaunchConfigurationTabGroup.1=Up
|
MultiLaunchConfigurationTabGroup.1=Up
|
||||||
MultiLaunchConfigurationTabGroup.2=Down
|
MultiLaunchConfigurationTabGroup.2=Down
|
||||||
MultiLaunchConfigurationTabGroup.3=Edit...
|
MultiLaunchConfigurationTabGroup.3=Edit...
|
||||||
|
@ -173,8 +177,6 @@ MultiLaunchConfigurationTabGroup.4=Add...
|
||||||
MultiLaunchConfigurationTabGroup.5=Remove
|
MultiLaunchConfigurationTabGroup.5=Remove
|
||||||
MultiLaunchConfigurationTabGroup.6=Name
|
MultiLaunchConfigurationTabGroup.6=Name
|
||||||
MultiLaunchConfigurationTabGroup.7=Mode
|
MultiLaunchConfigurationTabGroup.7=Mode
|
||||||
MultiLaunchConfigurationTabGroup.8=Select Launch Configuration
|
|
||||||
MultiLaunchConfigurationTabGroup.9=Edit Launch Configuration
|
|
||||||
MultiLaunchConfigurationTabGroup.10=Launches
|
MultiLaunchConfigurationTabGroup.10=Launches
|
||||||
MultiLaunchConfigurationTabGroup.11=seconds
|
MultiLaunchConfigurationTabGroup.11=seconds
|
||||||
MultiLaunchConfigurationTabGroup.12=Action
|
MultiLaunchConfigurationTabGroup.12=Action
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.eclipse.cdt.launch.internal.ui;
|
package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -65,12 +67,14 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
private ComboControlledStackComposite fStackComposite;
|
private ComboControlledStackComposite fStackComposite;
|
||||||
private Label fDelayAmountLabel;
|
private Label fDelayAmountLabel;
|
||||||
private Text fDelayAmountWidget; // in seconds
|
private Text fDelayAmountWidget; // in seconds
|
||||||
|
private boolean fForEditing; // true if dialog was opened to edit an entry, otherwise it was opened to add one
|
||||||
|
|
||||||
public MultiLaunchConfigurationSelectionDialog(Shell shell, String title, String initMode) {
|
public MultiLaunchConfigurationSelectionDialog(Shell shell, String initMode, boolean forEditing) {
|
||||||
super(shell);
|
super(shell);
|
||||||
LaunchConfigurationManager manager = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
|
LaunchConfigurationManager manager = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
|
||||||
launchGroups = manager.getLaunchGroups();
|
launchGroups = manager.getLaunchGroups();
|
||||||
mode = initMode;
|
mode = initMode;
|
||||||
|
fForEditing = forEditing;
|
||||||
fFilters = null;
|
fFilters = null;
|
||||||
setShellStyle(getShellStyle() | SWT.RESIZE);
|
setShellStyle(getShellStyle() | SWT.RESIZE);
|
||||||
emptyTypeFilter = new ViewerFilter() {
|
emptyTypeFilter = new ViewerFilter() {
|
||||||
|
@ -100,10 +104,14 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Control createDialogArea(Composite parent2) {
|
protected Control createDialogArea(Composite parent2) {
|
||||||
getShell().setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.0")); //$NON-NLS-1$
|
|
||||||
setTitle(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.1")); //$NON-NLS-1$
|
|
||||||
//setMessage("Select a Launch Configuration and a Launch Mode");
|
|
||||||
Composite comp = (Composite) super.createDialogArea(parent2);
|
Composite comp = (Composite) super.createDialogArea(parent2);
|
||||||
|
|
||||||
|
// title bar
|
||||||
|
getShell().setText(fForEditing ? LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.13") : LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.12")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
|
// dialog message area (not title bar)
|
||||||
|
setTitle(fForEditing ? LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.15") : LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.14")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
fStackComposite = new ComboControlledStackComposite(comp, SWT.NONE);
|
fStackComposite = new ComboControlledStackComposite(comp, SWT.NONE);
|
||||||
HashMap<String, ILaunchGroup> modes = new HashMap<String, ILaunchGroup>();
|
HashMap<String, ILaunchGroup> modes = new HashMap<String, ILaunchGroup>();
|
||||||
for (ILaunchGroup launchGroup : launchGroups) {
|
for (ILaunchGroup launchGroup : launchGroups) {
|
||||||
|
@ -114,15 +122,17 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
if (this.mode.equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE)) {
|
if (this.mode.equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE)) {
|
||||||
try {
|
try {
|
||||||
this.mode = "run"; //$NON-NLS-1$
|
this.mode = "run"; //$NON-NLS-1$
|
||||||
ILaunchConfiguration sel = getSelectedLaunchConfiguration();
|
ILaunchConfiguration[] configs = getSelectedLaunchConfigurations();
|
||||||
if (sel != null)
|
if (configs.length > 0) {
|
||||||
|
// we care only about the first selected element
|
||||||
for (Iterator<String> iterator = modes.keySet().iterator(); iterator.hasNext();) {
|
for (Iterator<String> iterator = modes.keySet().iterator(); iterator.hasNext();) {
|
||||||
String mode = iterator.next();
|
String mode = iterator.next();
|
||||||
if (sel.supportsMode(mode)) {
|
if (configs[0].supportsMode(mode)) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,13 +245,17 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
fDelayAmountWidget.setVisible(visible);
|
fDelayAmountWidget.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILaunchConfiguration getSelectedLaunchConfiguration() {
|
public ILaunchConfiguration[] getSelectedLaunchConfigurations() {
|
||||||
|
List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
|
||||||
if (fSelection != null && !fSelection.isEmpty()) {
|
if (fSelection != null && !fSelection.isEmpty()) {
|
||||||
Object firstElement = ((IStructuredSelection) fSelection).getFirstElement();
|
for (Iterator<?> iter = ((IStructuredSelection)fSelection).iterator(); iter.hasNext();) {
|
||||||
if (firstElement instanceof ILaunchConfiguration)
|
Object selection = iter.next();
|
||||||
return (ILaunchConfiguration) firstElement;
|
if (selection instanceof ILaunchConfiguration) {
|
||||||
|
configs.add((ILaunchConfiguration)selection);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return configs.toArray(new ILaunchConfiguration[configs.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMode() {
|
public String getMode() {
|
||||||
|
@ -256,8 +270,8 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
return actionParam;
|
return actionParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultiLaunchConfigurationSelectionDialog createDialog(Shell shell, String title, String groupId) {
|
public static MultiLaunchConfigurationSelectionDialog createDialog(Shell shell, String groupId, boolean forEditing) {
|
||||||
return new MultiLaunchConfigurationSelectionDialog(shell, title, groupId);
|
return new MultiLaunchConfigurationSelectionDialog(shell, groupId, forEditing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -305,12 +319,22 @@ 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;
|
boolean isValid = true;
|
||||||
if (getSelectedLaunchConfiguration() == null) {
|
if (getSelectedLaunchConfigurations().length < 1) {
|
||||||
setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.7")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.7")); //$NON-NLS-1$
|
||||||
isValid = false;
|
isValid = false;
|
||||||
} else {
|
} else {
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
if (fForEditing) {
|
||||||
|
// must have only one selection
|
||||||
|
if (getSelectedLaunchConfigurations().length > 1) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.11")); //$NON-NLS-1$
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
if (action == EPostLaunchAction.DELAY) {
|
if (action == EPostLaunchAction.DELAY) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -47,7 +48,7 @@ import org.eclipse.ui.PlatformUI;
|
||||||
*/
|
*/
|
||||||
public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||||
static class ContentProvider implements IStructuredContentProvider, ITreeContentProvider {
|
static class ContentProvider implements IStructuredContentProvider, ITreeContentProvider {
|
||||||
protected ArrayList<LaunchElement> input;
|
protected List<LaunchElement> input;
|
||||||
|
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
return getChildren(inputElement);
|
return getChildren(inputElement);
|
||||||
|
@ -59,27 +60,20 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
|
|
||||||
@SuppressWarnings("unchecked") // nothing we can do about this
|
@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 List<?>)
|
||||||
input = (ArrayList<LaunchElement>) newInput;
|
input = (List<LaunchElement>) newInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
if (parentElement == input)
|
return (parentElement == input) ? input.toArray() : null;
|
||||||
return input.toArray();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getParent(Object element) {
|
public Object getParent(Object element) {
|
||||||
if (element == input)
|
return (element == input) ? null : input;
|
||||||
return null;
|
|
||||||
return input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChildren(Object element) {
|
public boolean hasChildren(Object element) {
|
||||||
if (element == input)
|
return (element == input) ? (input.size() > 0) : false;
|
||||||
return input.size() > 0;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static class LabelProvider extends BaseLabelProvider implements ITableLabelProvider {
|
static class LabelProvider extends BaseLabelProvider implements ITableLabelProvider {
|
||||||
|
@ -213,7 +207,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
}
|
}
|
||||||
static class GroupLaunchTab extends AbstractLaunchConfigurationTab {
|
static class GroupLaunchTab extends AbstractLaunchConfigurationTab {
|
||||||
protected CheckboxTreeViewer treeViewer;
|
protected CheckboxTreeViewer treeViewer;
|
||||||
protected ArrayList<LaunchElement> input = new ArrayList<LaunchElement>();
|
protected List<LaunchElement> input = new ArrayList<LaunchElement>();
|
||||||
private String mode;
|
private String mode;
|
||||||
|
|
||||||
public GroupLaunchTab(String mode) {
|
public GroupLaunchTab(String mode) {
|
||||||
|
@ -245,23 +239,25 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
treeViewer.setInput(input);
|
treeViewer.setInput(input);
|
||||||
final ButtonComposite buts = new ButtonComposite(comp, SWT.NONE) {
|
final ButtonComposite buts = new ButtonComposite(comp, SWT.NONE) {
|
||||||
protected void addPressed() {
|
protected void addPressed() {
|
||||||
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog.createDialog(treeViewer
|
MultiLaunchConfigurationSelectionDialog dialog =
|
||||||
.getControl().getShell(), LaunchMessages.getString("MultiLaunchConfigurationTabGroup.8"), //$NON-NLS-1$
|
MultiLaunchConfigurationSelectionDialog.createDialog(
|
||||||
mode
|
treeViewer.getControl().getShell(), mode, false);
|
||||||
);
|
|
||||||
if (dialog.open() == Dialog.OK) {
|
if (dialog.open() == Dialog.OK) {
|
||||||
ILaunchConfiguration conf = dialog.getSelectedLaunchConfiguration();
|
ILaunchConfiguration[] configs = dialog.getSelectedLaunchConfigurations();
|
||||||
if (conf==null) return;
|
if (configs.length < 1)
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
return;
|
||||||
input.add(el);
|
for (ILaunchConfiguration config : configs) {
|
||||||
el.setIndex(input.size() - 1);
|
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
||||||
el.setEnabled(true);
|
input.add(el);
|
||||||
el.setName(conf.getName());
|
el.setIndex(input.size() - 1);
|
||||||
el.setData(conf);
|
el.setEnabled(true);
|
||||||
el.setMode(dialog.getMode());
|
el.setName(config.getName());
|
||||||
el.setAction(dialog.getAction(), dialog.getActionParam());
|
el.setData(config);
|
||||||
treeViewer.refresh(true);
|
el.setMode(dialog.getMode());
|
||||||
treeViewer.setChecked(el, el.isEnabled());
|
el.setAction(dialog.getAction(), dialog.getActionParam());
|
||||||
|
treeViewer.refresh(true);
|
||||||
|
treeViewer.setChecked(el, el.isEnabled());
|
||||||
|
}
|
||||||
updateWidgetEnablement();
|
updateWidgetEnablement();
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
@ -269,27 +265,29 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
protected void updateWidgetEnablement(){
|
protected void updateWidgetEnablement(){
|
||||||
downButton.setEnabled(isDownEnabled());
|
downButton.setEnabled(isDownEnabled());
|
||||||
upButton.setEnabled(isUpEnabled());
|
upButton.setEnabled(isUpEnabled());
|
||||||
int index = getSelIndex();
|
|
||||||
deleteButton.setEnabled(index>=0);
|
int selectionCount = getSelectionCount();
|
||||||
editButton.setEnabled(index>=0);
|
editButton.setEnabled(selectionCount == 1);
|
||||||
|
deleteButton.setEnabled(selectionCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void editPressed() {
|
protected void editPressed() {
|
||||||
int index = getSelIndex();
|
int index = getSingleSelectionIndex();
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index);
|
MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index);
|
||||||
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog.createDialog(treeViewer
|
MultiLaunchConfigurationSelectionDialog dialog =
|
||||||
.getControl().getShell(), LaunchMessages.getString("MultiLaunchConfigurationTabGroup.9"), //$NON-NLS-1$
|
MultiLaunchConfigurationSelectionDialog.createDialog(
|
||||||
el.getMode()
|
treeViewer.getControl().getShell(), el.getMode(), true);
|
||||||
);
|
|
||||||
dialog.setInitialSelection(el);
|
dialog.setInitialSelection(el);
|
||||||
if (dialog.open() == Dialog.OK) {
|
if (dialog.open() == Dialog.OK) {
|
||||||
ILaunchConfiguration conf = dialog.getSelectedLaunchConfiguration();
|
ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations();
|
||||||
if (conf==null) return;
|
if (confs.length < 0)
|
||||||
el.setName(conf.getName());
|
return;
|
||||||
el.setData(conf);
|
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.setName(confs[0].getName());
|
||||||
|
el.setData(confs[0]);
|
||||||
el.setMode(dialog.getMode());
|
el.setMode(dialog.getMode());
|
||||||
el.setAction(dialog.getAction(), dialog.getActionParam());
|
el.setAction(dialog.getAction(), dialog.getActionParam());
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
|
@ -298,27 +296,60 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void deletePressed() {
|
protected void deletePressed() {
|
||||||
int index = getSelIndex();
|
int[] indices = getMultiSelectionIndices();
|
||||||
if (index < 0)
|
if (indices.length < 1)
|
||||||
return;
|
return;
|
||||||
input.remove(index);
|
// need to delete from high to low
|
||||||
|
for (int i = indices.length - 1; i >= 0; i--) {
|
||||||
|
input.remove(indices[i]);
|
||||||
|
}
|
||||||
treeViewer.refresh(true);
|
treeViewer.refresh(true);
|
||||||
updateWidgetEnablement();
|
updateWidgetEnablement();
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getSelIndex() {
|
/**
|
||||||
|
* @return the index of the selection if a single item is
|
||||||
|
* selected. If zero or multiple are selected, -1 is
|
||||||
|
* returned
|
||||||
|
*/
|
||||||
|
private int getSingleSelectionIndex() {
|
||||||
StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
|
StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
|
||||||
if (sel.isEmpty())
|
if (sel.size() != 1)
|
||||||
return -1;
|
return -1;
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = ((MultiLaunchConfigurationDelegate.LaunchElement) sel
|
MultiLaunchConfigurationDelegate.LaunchElement el = ((MultiLaunchConfigurationDelegate.LaunchElement) sel
|
||||||
.getFirstElement());
|
.getFirstElement());
|
||||||
return input.indexOf(el);
|
return input.indexOf(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the indices of one or more selected items. Indices
|
||||||
|
* are always returned in ascending order
|
||||||
|
*/
|
||||||
|
private int[] getMultiSelectionIndices() {
|
||||||
|
StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
|
||||||
|
List<Integer> indices = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
|
||||||
|
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement)iter.next();
|
||||||
|
indices.add(input.indexOf(el));
|
||||||
|
|
||||||
|
}
|
||||||
|
int[] result = new int[indices.size()];
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
result[i] = indices.get(i);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSelectionCount() {
|
||||||
|
return ((StructuredSelection)treeViewer.getSelection()).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void downPressed() {
|
protected void downPressed() {
|
||||||
if (!isDownEnabled()) return;
|
if (!isDownEnabled()) return;
|
||||||
int index = getSelIndex();
|
int index = getSingleSelectionIndex();
|
||||||
|
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||||
input.set(index, input.get(index + 1));
|
input.set(index, input.get(index + 1));
|
||||||
|
@ -329,22 +360,17 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isDownEnabled() {
|
protected boolean isDownEnabled() {
|
||||||
int index = getSelIndex();
|
final int index = getSingleSelectionIndex();
|
||||||
if (index < 0 || index == input.size() - 1)
|
return (index >= 0) && (index != input.size() - 1);
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isUpEnabled(){
|
protected boolean isUpEnabled(){
|
||||||
int index = getSelIndex();
|
return getSingleSelectionIndex() > 0;
|
||||||
if (index <= 0)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void upPressed() {
|
protected void upPressed() {
|
||||||
if (!isUpEnabled()) return;
|
if (!isUpEnabled()) return;
|
||||||
int index = getSelIndex();
|
int index = getSingleSelectionIndex();
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
MultiLaunchConfigurationDelegate.LaunchElement x = input.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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue