1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 21:05:37 +02:00

Bugzilla 276397: Group Launch: selection dialog's OK button disabled when editing an entry. Also, addressed other issues mentioned in the bugzilla entry.

This commit is contained in:
John Cortell 2009-05-14 23:16:50 +00:00
parent afdcaeb52e
commit 352aaaa924
3 changed files with 77 additions and 33 deletions

View file

@ -158,6 +158,7 @@ MultiLaunchConfigurationSelectionDialog.1=Select a Launch Configuration and a La
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:
MultiLaunchConfigurationTabGroup.1=Up MultiLaunchConfigurationTabGroup.1=Up
MultiLaunchConfigurationTabGroup.2=Down MultiLaunchConfigurationTabGroup.2=Down
MultiLaunchConfigurationTabGroup.3=Edit... MultiLaunchConfigurationTabGroup.3=Edit...

View file

@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
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;
@ -38,6 +39,8 @@ 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.Tree;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.dialogs.PatternFilter;
@ -54,6 +57,7 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
private boolean isDefaultMode; private boolean isDefaultMode;
private ViewerFilter emptyTypeFilter; private ViewerFilter emptyTypeFilter;
private IStructuredSelection fInitialSelection; private IStructuredSelection fInitialSelection;
private ComboControlledStackComposite fStackComposite;
public MultiLaunchConfigurationSelectionDialog(Shell shell, String title, String initMode) { public MultiLaunchConfigurationSelectionDialog(Shell shell, String title, String initMode) {
super(shell); super(shell);
@ -93,21 +97,20 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
setTitle(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.1")); //$NON-NLS-1$ setTitle(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.1")); //$NON-NLS-1$
//setMessage("Select a Launch Configuration and a Launch Mode"); //setMessage("Select a Launch Configuration and a Launch Mode");
Composite comp = (Composite) super.createDialogArea(parent2); Composite comp = (Composite) super.createDialogArea(parent2);
ComboControlledStackComposite scomp = new ComboControlledStackComposite(comp, SWT.NONE); fStackComposite = new ComboControlledStackComposite(comp, SWT.NONE);
HashMap modes = new HashMap(); HashMap<String, ILaunchGroup> modes = new HashMap<String, ILaunchGroup>();
for (int i = 0; i < launchGroups.length; i++) { for (ILaunchGroup launchGroup : launchGroups) {
ILaunchGroup g = launchGroups[i]; if (!modes.containsKey(launchGroup.getMode())) {
if (!modes.containsKey(g.getMode())) { modes.put(launchGroup.getMode(), launchGroup);
modes.put(g.getMode(), g);
} }
} }
if (this.mode.equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE)) { //$NON-NLS-1$ 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 sel = getSelectedLaunchConfiguration();
if (sel != null) if (sel != null)
for (Iterator iterator = modes.keySet().iterator(); iterator.hasNext();) { for (Iterator<String> iterator = modes.keySet().iterator(); iterator.hasNext();) {
String mode = (String) iterator.next(); String mode = iterator.next();
if (sel.supportsMode(mode)) { if (sel.supportsMode(mode)) {
this.mode = mode; this.mode = mode;
break; break;
@ -116,49 +119,51 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
} catch (Exception e) { } catch (Exception e) {
} }
} }
for (Iterator iterator = modes.keySet().iterator(); iterator.hasNext();) { for (Iterator<String> iterator = modes.keySet().iterator(); iterator.hasNext();) {
String mode = (String) iterator.next(); String mode = iterator.next();
ILaunchGroup g = (ILaunchGroup) modes.get(mode); ILaunchGroup launchGroup = modes.get(mode);
LaunchConfigurationFilteredTree fTree = new LaunchConfigurationFilteredTree(scomp.getStackParent(), SWT.MULTI LaunchConfigurationFilteredTree fTree = new LaunchConfigurationFilteredTree(fStackComposite.getStackParent(), SWT.MULTI
| SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), g, fFilters); | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), launchGroup, fFilters);
String label = mode; String label = mode;
scomp.addItem(label, fTree); fStackComposite.addItem(label, fTree);
fTree.createViewControl(); fTree.createViewControl();
ViewerFilter[] filters = fTree.getViewer().getFilters(); ViewerFilter[] filters = fTree.getViewer().getFilters();
for (int i = 0; i < filters.length; i++) { for (ViewerFilter viewerFilter : filters) {
ViewerFilter viewerFilter = filters[i];
if (viewerFilter instanceof LaunchGroupFilter) { if (viewerFilter instanceof LaunchGroupFilter) {
fTree.getViewer().removeFilter(viewerFilter); fTree.getViewer().removeFilter(viewerFilter);
} }
} }
fTree.getViewer().addFilter(emptyTypeFilter); fTree.getViewer().addFilter(emptyTypeFilter);
fTree.getViewer().addSelectionChangedListener(this); fTree.getViewer().addSelectionChangedListener(this);
if (g.getMode().equals(this.mode)) { if (launchGroup.getMode().equals(this.mode)) {
scomp.setSelection(label); fStackComposite.setSelection(label);
} }
if (fInitialSelection!=null) { if (fInitialSelection!=null) {
fTree.getViewer().setSelection(fInitialSelection, true); fTree.getViewer().setSelection(fInitialSelection, true);
} }
} }
scomp.setLabelText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.4")); //$NON-NLS-1$ fStackComposite.setLabelText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.4")); //$NON-NLS-1$
scomp.pack(); fStackComposite.pack();
Rectangle bounds = scomp.getBounds(); Rectangle bounds = fStackComposite.getBounds();
// adjust size // adjust size
GridData data = ((GridData) scomp.getLayoutData()); GridData data = ((GridData) fStackComposite.getLayoutData());
if (data == null) { if (data == null) {
data = new GridData(GridData.FILL_BOTH); data = new GridData(GridData.FILL_BOTH);
scomp.setLayoutData(data); fStackComposite.setLayoutData(data);
} }
data.heightHint = Math.max(convertHeightInCharsToPixels(15), bounds.height); data.heightHint = Math.max(convertHeightInCharsToPixels(15), bounds.height);
data.widthHint = Math.max(convertWidthInCharsToPixels(40), bounds.width); data.widthHint = Math.max(convertWidthInCharsToPixels(40), bounds.width);
scomp.getCombo().addSelectionListener(new SelectionAdapter() { fStackComposite.getCombo().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
mode = ((Combo) e.widget).getText(); mode = ((Combo) e.widget).getText();
} }
}); });
// Use default checkbox // "Use default mode" checkbox. Use a parent composite to provide consistent left-side padding
Button checkBox = new Button(comp, SWT.CHECK); Composite checkboxComp = new Composite(comp, SWT.NONE);
checkboxComp.setLayout(new GridLayout(1, false));
checkboxComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button checkBox = new Button(checkboxComp, SWT.CHECK);
checkBox.setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.5")); //$NON-NLS-1$ checkBox.setText(LaunchMessages.getString("MultiLaunchConfigurationSelectionDialog.5")); //$NON-NLS-1$
checkBox.addSelectionListener(new SelectionAdapter() { checkBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -176,7 +181,7 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
comp.setLayout(new GridLayout(2, false)); comp.setLayout(new GridLayout(2, 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("Post launch action:"); 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.POST_LAUNCH_CONTINUE);
combo.add(LaunchElement.POST_LAUNCH_WAIT_FOR_TERM); combo.add(LaunchElement.POST_LAUNCH_WAIT_FOR_TERM);
@ -199,10 +204,7 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
} }
public String getMode() { public String getMode() {
if (isDefaultMode) return isDefaultMode ? MultiLaunchConfigurationDelegate.DEFAULT_MODE : mode;
return MultiLaunchConfigurationDelegate.DEFAULT_MODE; //$NON-NLS-1$
else
return mode;
} }
public String getAction(){ public String getAction(){
@ -213,9 +215,46 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
return new MultiLaunchConfigurationSelectionDialog(shell, title, groupId); return new MultiLaunchConfigurationSelectionDialog(shell, title, groupId);
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) { public void selectionChanged(SelectionChangedEvent event) {
fSelection = event.getSelection();
// This listener gets called for a selection change in the launch
// configuration viewer embedded in the dialog. Problem is, there are
// numerous viewers--one for each platform debug ILaunchGroup (run,
// debug, profile). These viewers are stacked, so only one is ever
// visible to the user. During initialization, we get a selection change
// notification for every viewer. We need to ignore all but the one that
// matters--the visible one.
Tree topTree = null;
final Control topControl = fStackComposite.getTopControl();
if (topControl instanceof FilteredTree) {
final TreeViewer viewer = ((FilteredTree)topControl).getViewer();
if (viewer != null) {
topTree = viewer.getTree();
}
}
if (topTree == null) {
return;
}
boolean selectionIsForVisibleViewer = false;
final Object src = event.getSource();
if (src instanceof Viewer) {
final Viewer viewer = (Viewer)src;
final Control viewerControl = viewer.getControl();
if (viewerControl == topTree) {
selectionIsForVisibleViewer = true;
}
}
if (!selectionIsForVisibleViewer) {
return;
}
fSelection = event.getSelection();
validate(); validate();
} }

View file

@ -118,4 +118,8 @@ public class ComboControlledStackComposite extends Composite {
layout.topControl = (Control) tabMap.get(label); layout.topControl = (Control) tabMap.get(label);
getStackParent().layout(); getStackParent().layout();
} }
public Control getTopControl() {
return layout != null ? layout.topControl : null;
}
} }