diff options
author | Michael Rennie | 2006-11-30 18:53:33 +0000 |
---|---|---|
committer | Michael Rennie | 2006-11-30 18:53:33 +0000 |
commit | 757a351674ef24780abeb4fa7bf5c8a0572370d7 (patch) | |
tree | a552a8863fad0a5576a07080a4622fe8ce21ab9b | |
parent | 0e3e415599a2b484fde4153a513a74cdf0a1ef7e (diff) | |
download | eclipse.platform.debug-757a351674ef24780abeb4fa7bf5c8a0572370d7.tar.gz eclipse.platform.debug-757a351674ef24780abeb4fa7bf5c8a0572370d7.tar.xz eclipse.platform.debug-757a351674ef24780abeb4fa7bf5c8a0572370d7.zip |
Bug 157059
[launching] extensible launch options phase 6
25 files changed, 975 insertions, 554 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java index 02be939cc..4498528f8 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java @@ -89,6 +89,16 @@ public interface ILaunchConfiguration extends IAdaptable { public static final String ATTR_SOURCE_LOCATOR_MEMENTO = DebugPlugin.getUniqueIdentifier() + ".source_locator_memento"; //$NON-NLS-1$ /** + * Launch configuration attribute storing a list + * of preferred launchers for associated mode sets. + * This attribute is a list of launchers stored by mode set + * and relating to the id of the preferred launcher, which happens to be an <code>ILaunchDelegate</code> + * + * @since 3.3 + */ + public static final String ATTR_PREFERRED_LAUNCHERS = DebugPlugin.getUniqueIdentifier() + ".preferred_launchers"; //$NON-NLS-1$ + + /** * Returns whether the contents of this launch configuration are * equal to the contents of the given launch configuration. * @@ -345,6 +355,21 @@ public interface ILaunchConfiguration extends IAdaptable { public Set getModes() throws CoreException; /** + * Returns the preferred launch delegate that has been set on this configuration. + * @return this configuration's preferred launch delegate for the specified mode set, or + * <code>null</code> if one is not specified + * + * <p> + * <strong>EXPERIMENTAL</strong>. This method has been added as + * part of a work in progress. There is no guarantee that this API will + * remain unchanged during the 3.3 release cycle. Please do not use this API + * without consulting with the Platform/Debug team. + * </p> + * @since 3.3 + */ + public ILaunchDelegate getPreferredDelegate(Set modes) throws CoreException; + + /** * Returns the type of this launch configuration. This is a * handle-only method. * diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java index 36e7ee96e..254febf8d 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java @@ -195,6 +195,22 @@ public interface ILaunchConfigurationWorkingCopy extends ILaunchConfiguration, I public void setModes(Set modes); /** + * Set the preferred launch delegates' id for the given mode set. Passing in <code>null</code> as a delegate + * id will cause the mapping for the specified mode set (if any) to be removed + * @param modes the set of modes to set this delegate id for + * @param delegateId the id of the delegate to associate as preferred for the specified mode set + * + * <p> + * <strong>EXPERIMENTAL</strong>. This method has been added as + * part of a work in progress. There is no guarantee that this API will + * remain unchanged during the 3.3 release cycle. Please do not use this API + * without consulting with the Platform/Debug team. + * </p> + * @since 3.3 + */ + public void setPreferredLaunchDelegate(Set modes, String delegateId); + + /** * Adds the specified launch modes to this configuration's settings. * <p> * Setting launch modes on a configuration allows the configuration to diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchDelegate.java index cf480d75b..46f4562f7 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchDelegate.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchDelegate.java @@ -20,6 +20,8 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; * launch delegate contributed to the <code>org.eclipse.debug.core.launchDelegates</code> * extension point. * + * This interface is NOT to be implemented by clients + * * @since 3.3 * <p> * <strong>EXPERIMENTAL</strong>. This interface has been added as diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index b7d8b9724..ed2d980ce 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -624,16 +624,30 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "No launch delegate found, canceling launch and returning", null); //$NON-NLS-1$ throw new CoreException(status); } else { - ILaunchDelegate del = getType().getPreferredDelegate(modes); + ILaunchDelegate del = getPreferredDelegate(modes); + if(del == null) { + del = getType().getPreferredDelegate(modes); + } if(del == null) { IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); IStatus status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode}); if(status != null && status.isOK()) { - delegate = getType().getPreferredDelegate(modes).getDelegate(); + del = getPreferredDelegate(modes); + if(del == null) { + del = getType().getPreferredDelegate(modes); + } + if(del != null) { + delegate = del.getDelegate(); + } + else { + monitor.setCanceled(true); + status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Duplicate launcher detected, canceling launch and returning", null); //$NON-NLS-1$ + throw new CoreException(status); + } } else { monitor.setCanceled(true); - status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Duplicate launch tooling detected, canceling launch and returning", null); //$NON-NLS-1$ + status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Duplicate launcher detected, canceling launch and returning", null); //$NON-NLS-1$ throw new CoreException(status); } } @@ -777,6 +791,20 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig } return false; } + + /** + * @see org.eclipse.debug.core.ILaunchConfiguration#getPreferredDelegate(java.util.Set) + */ + public ILaunchDelegate getPreferredDelegate(Set modes) throws CoreException { + Map delegates = getAttribute(ILaunchConfiguration.ATTR_PREFERRED_LAUNCHERS, (Map)null); + if(delegates != null) { + String id = (String) delegates.get(modes.toString()); + if(id != null) { + return getLaunchManager().getLaunchDelegate(id); + } + } + return null; + } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java index 1542abef1..03405e8b4 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java @@ -17,6 +17,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -408,18 +409,18 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen /** * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setModes(java.util.Set) */ - public void setModes(Set options) { - getInfo().setAttribute(ATTR_LAUNCH_MODES, (options.size() > 0 ? options : null)); + public void setModes(Set modes) { + getInfo().setAttribute(ATTR_LAUNCH_MODES, (modes.size() > 0 ? modes : null)); setDirty(); } /** * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#addModes(java.util.Set) */ - public void addModes(Set options) { + public void addModes(Set modes) { try { Set opts = getModes(); - if(opts.addAll(options)) { + if(opts.addAll(modes)) { getInfo().setAttribute(ATTR_LAUNCH_MODES, opts); setDirty(); } @@ -611,5 +612,29 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types); } + /** + * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setPreferredLaunchDelegate(java.util.Set, java.lang.String) + */ + public void setPreferredLaunchDelegate(Set modes, String delegateId) { + if(modes != null) { + try { + Map delegates = getAttribute(ILaunchConfiguration.ATTR_PREFERRED_LAUNCHERS, (Map)null); + //copy map to avoid pointer issues + Map map = new HashMap(); + if(delegates != null) { + map.putAll(delegates); + } + if(delegateId == null) { + map.remove(modes.toString()); + } + else { + map.put(modes.toString(), delegateId); + } + setAttribute(ILaunchConfiguration.ATTR_PREFERRED_LAUNCHERS, map); + } + catch (CoreException ce) {DebugPlugin.log(ce);} + } + } + } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java index ee0619647..3049a29c3 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java @@ -206,4 +206,14 @@ public final class LaunchDelegate implements ILaunchDelegate { public String getPluginIdentifier() { return fElement.getContributor().getName(); } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if(obj == null) { + return false; + } + return obj instanceof ILaunchDelegate && getId() != null && getId().equals(((ILaunchDelegate)obj).getId()); + } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index 1e84630bf..3e20dca3f 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -1390,10 +1390,10 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe * without consulting with the Platform/Debug team. * </p> */ - public LaunchDelegate[] getLaunchDelegates() { + public ILaunchDelegate[] getLaunchDelegates() { initializeLaunchDelegates(); Collection col = fLaunchDelegates.values(); - return (LaunchDelegate[]) col.toArray(new LaunchDelegate[col.size()]); + return (ILaunchDelegate[]) col.toArray(new ILaunchDelegate[col.size()]); } /** @@ -1421,6 +1421,26 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe } /** + * This method returns the <code>ILaunchDelegate</code> instance corresponding to the id + * of the launch delegate specified + * @param id the id of the <code>ILaunchDelegate</code> to find + * @return the <code>ILaunchDelegate</code> or <code>null</code> if not found + * @since 3.3 + * EXPERIMENTAL + */ + public ILaunchDelegate getLaunchDelegate(String id) { + if(id != null) { + ILaunchDelegate[] delegates = getLaunchDelegates(); + for(int i = 0; i < delegates.length; i++) { + if(id.equals(delegates[i].getId())) { + return delegates[i]; + } + } + } + return null; + } + + /** * Initializes the listing of delegates available to the launching framework * * <p> @@ -2197,18 +2217,20 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe for(Iterator iter = preferred.keySet().iterator(); iter.hasNext();) { modes = (Set) iter.next(); delegate = (ILaunchDelegate) preferred.get(modes); - child = doc.createElement(DELEGATE); - child.setAttribute(ID, delegate.getId()); - child.setAttribute(TYPEID, types[i].getIdentifier()); - for(Iterator iter2 = modes.iterator(); iter2.hasNext();) { - modestr += iter2.next(); - if(iter2.hasNext()) { - modestr += ","; //$NON-NLS-1$ + if(delegate != null) { + child = doc.createElement(DELEGATE); + child.setAttribute(ID, delegate.getId()); + child.setAttribute(TYPEID, types[i].getIdentifier()); + for(Iterator iter2 = modes.iterator(); iter2.hasNext();) { + modestr += iter2.next(); + if(iter2.hasNext()) { + modestr += ","; //$NON-NLS-1$ + } } + child.setAttribute(MODES, modestr); + modestr = EMPTY_STRING; + root.appendChild(child); } - child.setAttribute(MODES, modestr); - modestr = EMPTY_STRING; - root.appendChild(child); } } } diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 265dc8a81..564252cd6 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -147,7 +147,7 @@ </page> <page category="org.eclipse.debug.ui.LaunchingPreferencePage" - class="org.eclipse.debug.internal.ui.preferences.LaunchDelegatesPreferencePage" + class="org.eclipse.debug.internal.ui.preferences.LaunchersPreferencePage" id="org.eclipse.debug.ui.LaunchDelegatesPreferencePage" name="%LaunchDelegatesPreferencePage.name"> <keywordReference diff --git a/org.eclipse.debug.ui/schema/launchConfigurationTabs.exsd b/org.eclipse.debug.ui/schema/launchConfigurationTabs.exsd index 2395a205e..f6be6028f 100644 --- a/org.eclipse.debug.ui/schema/launchConfigurationTabs.exsd +++ b/org.eclipse.debug.ui/schema/launchConfigurationTabs.exsd @@ -66,7 +66,7 @@ without consulting with the Platform/Debug team.</p> <attribute name="class" type="string" use="required"> <annotation> <documentation> - fully qualified name of the java class that implemnents <code>ILaunchConfigurationTab</code>. + fully qualified name of the java class that implements <code>ILaunchConfigurationTab</code>. </documentation> <appInfo> <meta.attribute kind="java" basedOn="org.eclipse.debug.ui.ILaunchConfigurationTab"/> diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java index 55a3c496f..b1436d34c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java @@ -99,8 +99,7 @@ public interface IDebugHelpContextIds { public static final String SELECT_DEFAULT_WORKINGSET_DIALOG = PREFIX + "select_breakpoint_workingset_dialog"; //$NON-NLS-1$ public static final String DELETE_ASSOCIATED_LAUNCH_CONFIGS_DIALOG = PREFIX + "delete_associated_launch_configs_dialog"; //$NON-NLS-1$ public static final String SELECT_LAUNCH_MODES_DIALOG = PREFIX + "select_launch_modes_dialog"; //$NON-NLS-1$ - public static final String SELECT_LAUNCH_DELEGATES_DIALOG = PREFIX + "select_launch_delegates_dialog"; //$NON-NLS-1$ - public static final String SELECT_DUPE_LAUNCH_DELEGATE_ACTION_DIALOG = PREFIX + "select_dupe_delegate_action_dialog"; //$NON-NLS-1$ + public static final String SELECT_LAUNCHERS_DIALOG = PREFIX + "select_launchers_dialog"; //$NON-NLS-1$ // Property pages public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java index 20e4d6528..7f095460f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java @@ -137,6 +137,12 @@ public interface IInternalDebugUIConstants { public static final String PREF_LAUNCH_PERSPECTIVES = IDebugUIConstants.PLUGIN_ID + ".PREF_LAUNCH_PERSPECTIVES"; //$NON-NLS-1$ /** + * Represents the empty string + * @since 3.3 + */ + public static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + /** * Preference for enabling/disabling launch configuration filtering based on project accessibilty status * * @since 3.2 @@ -263,21 +269,7 @@ public interface IInternalDebugUIConstants { * @since 3.1 */ public static final String PREF_MAX_DETAIL_LENGTH = IDebugUIConstants.PLUGIN_ID + ".max_detail_length"; //$NON-NLS-1$ - - /** - * Constant to describe the 'list' action for duplicate launch delegate resolution - * @since 3.3 - * EXPERIMENTAL - */ - public static final String DELEGATE_ACTION_ID_LIST = "list"; //$NON-NLS-1$ - - /** - * Constant to describe the 'dialog' action for duplicate delegate resolution - * @since 3.3 - * EXPERIMENTAL - */ - public static final String DELEGATE_ACTION_ID_DIALOG = "dialog"; //$NON-NLS-1$ - + /** * Font for Memory View * diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java index 4c97d1471..f2a2c3dc1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java @@ -15,6 +15,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; @@ -59,6 +60,30 @@ public class SWTUtil { } } + /** + * Creates a check box button using the parents' font + * @param parent the parent to add the button to + * @param label the label for the button + * @param image the image for the button + * @param checked the initial checked state of the button + * @return a new checked button set to the initial checked state + * @since 3.3 + */ + public static Button createCheckButton(Composite parent, String label, Image image, boolean checked) { + Button button = new Button(parent, SWT.CHECK); + button.setFont(parent.getFont()); + button.setSelection(checked); + if(image != null) { + button.setImage(image); + } + if(label != null) { + button.setText(label); + } + GridData gd = new GridData(); + button.setLayoutData(gd); + setButtonDimensionHint(button); + return button; + } /** * Creates and returns a new push button with the given @@ -166,6 +191,32 @@ public class SWTUtil { } /** + * Creates a new <code>CLabel</code> that will wrap at the specified width and has the specified image + * @param parent the parent to add this label to + * @param text the text for the label + * @param image the image for the label + * @param hspan the h span to take up in the parent + * @param wrapwidth the with to wrap at + * @return a new <code>CLabel</code> + * @since 3.3 + */ + public static CLabel createWrapCLabel(Composite parent, String text, Image image, int hspan, int wrapwidth) { + CLabel label = new CLabel(parent, SWT.NONE | SWT.WRAP); + label.setFont(parent.getFont()); + if(text != null) { + label.setText(text); + } + if(image != null) { + label.setImage(image); + } + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = hspan; + gd.widthHint = wrapwidth; + label.setLayoutData(gd); + return label; + } + + /** * Creates a wrapping label * @param parent the parent composite to add this label to * @param text the text to be displayed in the label diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractDebugSelectionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractDebugSelectionDialog.java new file mode 100644 index 000000000..b820ad954 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractDebugSelectionDialog.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.launchConfigurations; + +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.DefaultLabelProvider; +import org.eclipse.debug.internal.ui.SWTUtil; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; + +/** + * This class provides a general selection dialog class to be specialized for + * selections using a checkbox table viewer + * + * @since 3.3 + * EXPERIMENTAL + */ +public abstract class AbstractDebugSelectionDialog extends SelectionDialog { + + protected Table fTable = null; + protected CheckboxTableViewer fTableViewer = null; + + /** + * Constructor + * @param parentShell + */ + public AbstractDebugSelectionDialog(Shell parentShell) { + super(parentShell); + } + + /** + * returns the dialog settings area id + * @return the id of the dialog settings area + */ + protected abstract String getDialogSettingsId(); + + /** + * Returns the object to use as input for the viewer + * @return the object to use as input for the viewer + */ + protected abstract Object getViewerInput(); + + /** + * Returns the content provider for the viewer + * @return the content provider for the viewer + */ + protected IContentProvider getContentProvider() { + //by default return a simple array content provider + return new ArrayContentProvider(); + } + + /** + * Returns the label provider used by the viewer + * @return the label provider used in the viewer + */ + protected IBaseLabelProvider getLabelProvider() { + return new DefaultLabelProvider(); + } + + /** + * Returns the message for the viewer: i.e. Select Foo: + * @return the message for the viewer + */ + protected abstract String getTableViewerMessage(); + + /** + * Returns the help context id for this dialog + * @return the help context id for this dialog + */ + protected abstract String getHelpContextId(); + + /** + * This method allows custom controls to be added before the viewer + * @param parent the parent composite to add these custom controls to + */ + protected void addCustomHeaderControls(Composite parent) { + //do nothing by default + } + + /** + * This method allows custom controls to be added after the viewer + * @param parent the parent composite to add these controls to + */ + protected void addCustomFooterControls(Composite parent) { + //do nothing by default + } + + /** + * This method allows the newly created controls to be initialized, with this method being called from + * the createDialogArea method + */ + protected void initializeControls() { + //do nothing by default + } + + /** + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + initializeDialogUnits(parent); + Composite comp = (Composite) super.createDialogArea(parent); + addCustomHeaderControls(comp); + SWTUtil.createLabel(comp, getTableViewerMessage(), 1); + fTable = new Table(comp, SWT.BORDER | SWT.SINGLE | SWT.CHECK); + fTable.setLayoutData(new GridData(GridData.FILL_BOTH)); + fTableViewer = new CheckboxTableViewer(fTable); + fTableViewer.setLabelProvider(getLabelProvider()); + fTableViewer.setContentProvider(getContentProvider()); + fTableViewer.setInput(getViewerInput()); + fTableViewer.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + fTableViewer.setCheckedElements(new Object[] {event.getElement()}); + getButton(IDialogConstants.OK_ID).setEnabled(true); + } + }); + addCustomFooterControls(comp); + initializeControls(); + Dialog.applyDialogFont(comp); + PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, getHelpContextId()); + return comp; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings() + */ + protected IDialogSettings getDialogBoundsSettings() { + IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); + IDialogSettings section = settings.getSection(getDialogSettingsId()); + if (section == null) { + section = settings.addNewSection(getDialogSettingsId()); + } + return section; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() + */ + protected Point getInitialSize() { + IDialogSettings settings = getDialogBoundsSettings(); + if(settings != null) { + try { + int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$ + int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$ + if(width > 0 & height > 0) { + return new Point(width, height); + } + } + catch (NumberFormatException nfe) { + return new Point(450, 500); + } + } + return new Point(450, 500); + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java index 3f0fe075b..1a9ab61ba 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java @@ -72,8 +72,7 @@ public class CreateLaunchConfigurationAction extends AbstractLaunchConfiguration tabGroup.createTabs(dialog, dialog.getMode()); ILaunchConfigurationTab[] tabs = tabGroup.getTabs(); for (int i = 0; i < tabs.length; i++) { - ILaunchConfigurationTab tab = tabs[i]; - tab.setLaunchConfigurationDialog(dialog); + tabs[i].setLaunchConfigurationDialog(dialog); } tabGroup.setDefaults(wc); tabGroup.dispose(); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java index 66ae62ddb..c24daf06b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java @@ -48,18 +48,19 @@ public class DuplicateLaunchDelegatesStatusHandler implements IStatusHandler { HashSet modes = new HashSet(); modes.add(mode); modes.addAll(config.getModes()); - SelectLaunchDelegatesDialog sld = new SelectLaunchDelegatesDialog(shell, config.getType().getDelegates(modes)); - if(sld.open() == IDialogConstants.OK_ID) { - Object[] res = sld.getResult(); - if(res != null && res.length > 0) { - config.getType().setPreferredDelegate(modes, (ILaunchDelegate) res[0]); - } - else { - return Status.CANCEL_STATUS; - } + SelectLaunchersDialog sldd = new SelectLaunchersDialog(shell, + config.getType().getDelegates(modes), + config.getWorkingCopy(), + mode); + if(sldd.open() != IDialogConstants.OK_ID) { + return Status.CANCEL_STATUS; } //check that the delegate has been set - return (config.getType().getPreferredDelegate(modes) == null ? Status.CANCEL_STATUS : Status.OK_STATUS); + ILaunchDelegate delegate = config.getPreferredDelegate(modes); + if(delegate == null) { + delegate = config.getType().getPreferredDelegate(modes); + } + return (delegate == null ? Status.CANCEL_STATUS : Status.OK_STATUS); } } return Status.CANCEL_STATUS; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java index 403ea291c..d6a049758 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java @@ -175,7 +175,7 @@ public class LaunchConfigurationPresentationManager { } /** - * Returns the tab group for the given launch configutation, its type and the mode the dialog opened in + * Returns the tab group for the given launch configutation and the mode the dialog opened in * @param type the type of the configuration * @param config * @param mode @@ -195,7 +195,7 @@ public class LaunchConfigurationPresentationManager { /** * Returns the proxy elements for all contributed tabs for the specified tab group id * @param groupid the id of the tab group - * @param type the type the tab group is opened on + * @param config the config the tab group is opened on * @param mode the mode the associated launch dialog is opened on * @return the listing of all of the tab extensions or an empty array, never <code>null</code> * @@ -241,7 +241,10 @@ public class LaunchConfigurationPresentationManager { //filter to preferred delegate (if there is one) HashSet modes = (HashSet) config.getModes(); modes.add(mode); - ILaunchDelegate delegate = config.getType().getPreferredDelegate(modes); + ILaunchDelegate delegate = config.getPreferredDelegate(modes); + if(delegate == null) { + delegate = config.getType().getPreferredDelegate(modes); + } if(delegate != null) { if(tabs[i].getDelegateSet().contains(delegate.getId())) { set.add(tabs[i]); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java index 5193082f9..296b9d916 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java @@ -37,12 +37,10 @@ import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.StackLayout; @@ -67,7 +65,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPreferenceConstants; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.activities.WorkbenchActivityHelper; import com.ibm.icu.text.MessageFormat; @@ -289,10 +286,10 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { Composite linkComp = SWTUtil.createComposite(blComp, blComp.getFont(), 1, 1, GridData.FILL_HORIZONTAL); //a link for launch options - fOptionsLink = new Link(linkComp, SWT.NONE); - + fOptionsLink = new Link(linkComp, SWT.WRAP | SWT.BORDER); fOptionsLink.setFont(linkComp.getFont()); - gd = new GridData(GridData.BEGINNING); + gd = new GridData(SWT.LEFT); + gd.grabExcessHorizontalSpace = true; fOptionsLink.setLayoutData(gd); fOptionsLink.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { @@ -309,23 +306,17 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { modes.remove(getLaunchConfigurationDialog().getMode()); ILaunchConfigurationWorkingCopy wc = getWorkingCopy(); wc.setModes(modes); - refresh(); refreshStatus(); } } } - else if(hasDuplicateDelegates()) { - Set modes = new HashSet(); - modes.add(getLaunchConfigurationDialog().getMode()); - modes.addAll(getWorkingCopy().getModes()); - SelectLaunchDelegatesDialog sld = new SelectLaunchDelegatesDialog(getShell(), fTabType.getDelegates(modes)); - if(sld.open() == IDialogConstants.OK_ID) { - Object[] res = sld.getResult(); - if(res != null) { - fTabType.setPreferredDelegate(modes, (ILaunchDelegate) res[0]); - disposeExistingTabs(); - displayInstanceTabs(); - } + else if(hasMultipleDelegates()) { + SelectLaunchersDialog sldd = new SelectLaunchersDialog(getShell(), + getWorkingCopy().getType().getDelegates(getCurrentModeSet()), + getWorkingCopy(), + getLaunchConfigurationDialog().getMode()); + if(sldd.open() == IDialogConstants.OK_ID) { + displayInstanceTabs(true); } } } catch (CoreException ex) {} @@ -366,20 +357,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { } /** - * Simple method to create a spacer in the page - * - * @param composite the composite to add the spacer to - * @param columnSpan the amount of space for the spacer - * @since 3.2 - */ - protected void createSpacer(Composite composite, int columnSpan) { - Label label = new Label(composite, SWT.NONE); - GridData gd = new GridData(); - gd.horizontalSpan = columnSpan; - label.setLayoutData(gd); - } - - /** * Creates some help text for the tab group launch types * @param parent thep arent composite * @since 3.2 @@ -387,24 +364,20 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { private void createGettingStarted(Composite parent) { Font font = parent.getFont(); GridData gd = null; - createWrapLabel(parent, null, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1); - createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), - LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2); - createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), - LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6); - createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), - LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4); - createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), - LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8); - createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), - LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3); + int width = parent.getBounds().width - 30; + SWTUtil.createWrapLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1, 1, width); + SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 1, width); + SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), 1, width); + SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), 1, width); + SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width); + SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 1, width); - createSpacer(parent, 2); + SWTUtil.createHorizontalSpacer(parent, 2); Link link = new Link(parent, SWT.LEFT | SWT.WRAP); link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5); link.setFont(font); gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = parent.getBounds().width - 30; + gd.widthHint = width; link.setLayoutData(gd); link.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { @@ -413,22 +386,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { public void widgetDefaultSelected(SelectionEvent e) {} }); } - - /** - * Create a label on the given parent that wraps text. - * - * @param parent - * @param text - */ - private void createWrapLabel(Composite parent, Image image, String text) { - CLabel lbl = new CLabel(parent, SWT.NONE | SWT.WRAP); - lbl.setImage(image); - lbl.setFont(parent.getFont()); - lbl.setText(text); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = parent.getBounds().width - 30; - lbl.setLayoutData(gd); - } /** * Creates the tab folder for displaying config instances @@ -519,10 +476,7 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() */ public ISelection getSelection() { - if (getActiveTab() == null) { - return new StructuredSelection(); - } - return new StructuredSelection(getActiveTab()); + return new StructuredSelection(fWorkingCopy); } /** @@ -540,23 +494,100 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { // update error ticks CTabItem item = null; boolean error = false; + Image image = null; for (int i = 0; i < tabs.length; i++) { - tabs[i].isValid(getWorkingCopy()); - error = tabs[i].getErrorMessage() != null; + error = tabs[i].getErrorMessage() != null && !tabs[i].isValid(getWorkingCopy()); + image = tabs[i].getImage(); item = fTabFolder.getItem(i); - setTabIcon(item, error, tabs[i]); + if(error) { + item.setImage(DebugUIPlugin.getDefault().getLaunchConfigurationManager().getErrorTabImage(tabs[i])); + } + else { + item.setImage(image); + } } - if(!canLaunchWithModes()) { - fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13); + showLink(); + } + } + + /** + * Shows the link for either multiple launch delegates or bad launch mode combinations + * + * @since 3.3 + * + * EXPERIMENTAL + */ + private void showLink() { + String text = null; + if(!canLaunchWithModes()) { + text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13; + } + else if(hasMultipleDelegates()) { + ILaunchDelegate delegate = getPreferredDelegate(); + if(delegate != null) { + String name = delegate.getName(); + if(name == null) { + text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_15; + } + else { + text = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_16, new String[] {name}); + } } - else if(hasDuplicateDelegates()) { - fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_15); + else { + text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_17; } - fOptionsLink.setVisible(!canLaunchWithModes() || hasDuplicateDelegates()); - fOptionsLink.getParent().layout(); } + if(text != null) { + fOptionsLink.setText(text); + } + fOptionsLink.setVisible(!canLaunchWithModes() || hasMultipleDelegates()); + fOptionsLink.getParent().layout(); } - + + /** + * Returns the preferred launch delegate for the current launch configuration and mode set + * @return the preferred launch delegate + * + * @since 3.3 + * + * EXPERIMENTAL + */ + protected ILaunchDelegate getPreferredDelegate() { + ILaunchDelegate preferred = null; + ILaunchConfigurationWorkingCopy config = getWorkingCopy(); + if(config != null) { + try { + Set modes = getCurrentModeSet(); + preferred = config.getPreferredDelegate(modes); + if(preferred == null) { + preferred = config.getType().getPreferredDelegate(modes); + } + } + catch(CoreException ce) {DebugUIPlugin.log(ce);} + } + return preferred; + } + + /** + * Returns the listing of modes for the current config + * @return the listing of modes for the current config + * @since 3.3 + * + * EXPERIMENTAL + */ + private Set getCurrentModeSet() { + Set set = new HashSet(); + ILaunchConfigurationWorkingCopy config = getWorkingCopy(); + if(config != null) { + try { + set.addAll(config.getModes()); + set.add(getLaunchConfigurationDialog().getMode()); + } + catch(CoreException ce) {DebugUIPlugin.log(ce);} + } + return set; + } + /** * updates the button states */ @@ -565,20 +596,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { fApplyButton.setEnabled(dirty && canSave()); fRevertButton.setEnabled(dirty); } - - /** - * Set the specified tab item's icon to an error icon if <code>error</code> is true, - * or a transparent icon of the same size otherwise. - */ - private void setTabIcon(CTabItem tabItem, boolean error, ILaunchConfigurationTab tab) { - Image image = null; - if (error) { - image = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getErrorTabImage(tab); - } else { - image = tab.getImage(); - } - tabItem.setImage(image); - } /* (non-Javadoc) * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object) @@ -609,9 +626,10 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { fVisibleArea.setRedraw(false); if (fInput instanceof ILaunchConfiguration) { ILaunchConfiguration configuration = (ILaunchConfiguration)fInput; + boolean refreshtabs = !delegatesEqual(fWorkingCopy, configuration); fOriginal = configuration; fWorkingCopy = configuration.getWorkingCopy(); - displayInstanceTabs(); + displayInstanceTabs(refreshtabs); } else if (fInput instanceof ILaunchConfigurationType) { fDescription = getDescription((ILaunchConfigurationType)fInput); setNoInput(); @@ -652,12 +670,42 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { } /** + * Returns if the two configs are using the same <code>ILaunchDelegate</code> or not + * @param config1 + * @param config2 + * @return true if the configs are using the same <code>ILaunchDelegate</code> or false if they are not + * @since 3.3 + */ + protected boolean delegatesEqual(ILaunchConfiguration config1, ILaunchConfiguration config2) { + try { + if(config1 == null || config2 == null) { + return false; + } + Set modes = getCurrentModeSet(); + ILaunchDelegate d1 = config1.getPreferredDelegate(modes); + if(d1 == null) { + d1 = config1.getType().getPreferredDelegate(modes); + } + ILaunchDelegate d2 = config2.getPreferredDelegate(modes); + if(d2 == null) { + d2 = config2.getType().getPreferredDelegate(modes); + } + if(d1 != null) { + return d1.equals(d2); + } + } + catch(CoreException ce) {DebugUIPlugin.log(ce);} + return false; + } + + /** * Updates the visibility of controls based on the status provided * @param visible the visibility status to be applied to the controls */ private void updateVisibleControls(boolean visible) { fApplyButton.setVisible(visible); fRevertButton.setVisible(visible); + fOptionsLink.setVisible(visible); if(visible) { ((StackLayout)fTabPlaceHolder.getLayout()).topControl = fTabComposite; fTabComposite.layout(); @@ -673,26 +721,26 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { */ protected void setFocusOnName() { fNameWidget.setFocus(); - } /** * Displays tabs for the current working copy */ - protected void displayInstanceTabs() { + protected void displayInstanceTabs(boolean redrawTabs) { // Turn on initializing flag to ignore message updates fInitializingTabs = true; - ILaunchConfigurationType type = null; try { type = getWorkingCopy().getType(); - showInstanceTabsFor(type); - } catch (CoreException e) { + } + catch (CoreException e) { errorDialog(e); fInitializingTabs = false; return; } - + if(redrawTabs) { + showInstanceTabsFor(type); + } // show the name area updateVisibleControls(true); // Update the name field before to avoid verify error @@ -730,39 +778,46 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { * launch configuration type. */ private void showInstanceTabsFor(ILaunchConfigurationType configType) { - - // Don't do any work if the current tabs are for the current config type - if (fTabType != null && fTabType.equals(configType)) { - return; - } - // try to keep on same tab Class tabKind = null; if (getActiveTab() != null) { tabKind = getActiveTab().getClass(); } - // Build the new tabs ILaunchConfigurationTabGroup group = null; try { - group = createGroup(configType); + group = createGroup(); } catch (CoreException ce) { DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_Exception_occurred_creating_launch_configuration_tabs_27,ce); // return; } - - showTabsFor(group); + disposeExistingTabs(); fTabGroup = group; fTabType = configType; - - // select same tab as before, if possible ILaunchConfigurationTab[] tabs = getTabs(); + CTabItem tab = null; + String name = EMPTY_STRING; + Control control = null; + for (int i = 0; i < tabs.length; i++) { + tab = new CTabItem(fTabFolder, SWT.BORDER); + name = tabs[i].getName(); + if (name == null) { + name = LaunchConfigurationsMessages.LaunchConfigurationDialog_unspecified_28; + } + tab.setText(name); + tab.setImage(tabs[i].getImage()); + tabs[i].createControl(tab.getParent()); + control = tabs[i].getControl(); + if (control != null) { + tab.setControl(control); + } + } //set the default tab as the first one setActiveTab(tabs[0]); + // select same tab as before, if possible for (int i = 0; i < tabs.length; i++) { - ILaunchConfigurationTab tab = tabs[i]; - if (tab.getClass().equals(tabKind)) { - setActiveTab(tab); + if (tabs[i].getClass().equals(tabKind)) { + setActiveTab(tabs[i]); break; } } @@ -782,49 +837,19 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { String mode = fDialog.getMode(); description = LaunchConfigurationPresentationManager.getDefault().getDescription(configType, mode); } - if (description == null) + if (description == null) { description = EMPTY_STRING; + } return description; } /** - * Create the tabs in the configuration edit area for the given tab group. - */ - private void showTabsFor(ILaunchConfigurationTabGroup tabGroup) { - // Dispose the current tabs - disposeExistingTabs(); - - fTabGroup = tabGroup; - - // Create the Control for each tab - ILaunchConfigurationTab[] tabs = tabGroup.getTabs(); - CTabItem tab = null; - String name = EMPTY_STRING; - Control control = null; - for (int i = 0; i < tabs.length; i++) { - tab = new CTabItem(fTabFolder, SWT.BORDER); - name = tabs[i].getName(); - if (name == null) { - name = LaunchConfigurationsMessages.LaunchConfigurationDialog_unspecified_28; - } - tab.setText(name); - tab.setImage(tabs[i].getImage()); - tabs[i].createControl(tab.getParent()); - control = tabs[i].getControl(); - if (control != null) { - tab.setControl(control); - } - } - - } - - /** * Returns tab group for the given type of launch configuration. * Tabs are initialized to be contained in this dialog. * * @exception CoreException if unable to instantiate a tab group */ - protected ILaunchConfigurationTabGroup createGroup(final ILaunchConfigurationType configType) throws CoreException { + protected ILaunchConfigurationTabGroup createGroup() throws CoreException { // Use a final Object array to store the tab group and any exception that // results from the Runnable final Object[] finalArray = new Object[2]; @@ -869,8 +894,7 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { if (object instanceof ILaunchConfigurationTab) { ILaunchConfigurationTab[] tabs = getTabs(); for (int i = 0; i < tabs.length; i++) { - ILaunchConfigurationTab tab = tabs[i]; - if (tab.equals(object)) { + if (tabs[i].equals(object)) { fCurrentTabIndex = i; fTabFolder.setSelection(i); } @@ -1029,7 +1053,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { return false; } } - return true; } @@ -1053,9 +1076,7 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { try { ILaunchConfigurationWorkingCopy wc = getWorkingCopy(); if(wc != null) { - Set modes = wc.getModes(); - modes.add(getLaunchConfigurationDialog().getMode()); - return wc.getType().supportsModeCombination(modes); + return wc.getType().supportsModeCombination(getCurrentModeSet()); } } catch (CoreException e) { } @@ -1077,24 +1098,30 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { if(fInitializingTabs) { return false; } - try { - ILaunchConfiguration config = getWorkingCopy(); - if(config != null) { - Set modes = config.getModes(); - modes.add(getLaunchConfigurationDialog().getMode()); + ILaunchConfiguration config = getWorkingCopy(); + if(config != null) { + if(hasMultipleDelegates()) { + return getPreferredDelegate() == null; + } + } + return false; + } + + /** + * Determines if the currently showing launch configuration has multiple launch delegates for the same mode set, but does not care + * if there has been a default selected yet or not + * @return true if the current launch configuraiton has multiple launch delegates, false otherwise + */ + private boolean hasMultipleDelegates() { + ILaunchConfiguration config = getWorkingCopy(); + if(config != null) { + try { + Set modes = getCurrentModeSet(); ILaunchDelegate[] delegates = LaunchConfigurationManager.filterLaunchDelegates(fTabType, modes); - if(delegates.length > 1) { - ILaunchDelegate preferred = fTabType.getPreferredDelegate(modes); - if(preferred == null) { - return true; - } - else if(WorkbenchActivityHelper.filterItem(new LaunchDelegateContribution(preferred))) { - return true; - } - } + return delegates.length > 1; } + catch (CoreException ce) {DebugUIPlugin.log(ce);} } - catch(CoreException ce) {DebugUIPlugin.log(ce);} return false; } @@ -1141,30 +1168,14 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { return temp.toString(); } } - if(getWorkingCopy() != null) { - if(getWorkingCopy().isReadOnly()) { - return LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9; - } + if(getWorkingCopy().isReadOnly()) { + return LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9; } //EXPERIMENTAL if(!canLaunchWithModes()) { - try { - Set modes = getWorkingCopy().getModes(); - modes.add(getLaunchConfigurationDialog().getMode()); - List names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes); - return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_14, new String[]{names.toString()}); - } catch (CoreException e) { - return e.getMessage(); - } - } - if(hasDuplicateDelegates()) { - try { - Set modes = getWorkingCopy().getModes(); - modes.add(getLaunchConfigurationDialog().getMode()); - List names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes); - return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_16, new String[] {names.toString()}); - } - catch (CoreException e) {DebugUIPlugin.log(e);} + Set modes = getCurrentModeSet(); + List names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes); + return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_14, new String[]{names.toString()}); } return null; } @@ -1293,8 +1304,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { } } fCurrentTabIndex = fTabFolder.getSelectionIndex(); - SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection()); - fireSelectionChanged(event); } /** @@ -1342,7 +1351,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { if(fTabGroup != null) { fTabGroup.initializeFrom(fOriginal); fWorkingCopy = fOriginal.getWorkingCopy(); - refresh(); refreshStatus(); } } @@ -1366,11 +1374,12 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { */ public void setActiveTab(ILaunchConfigurationTab tab) { ILaunchConfigurationTab[] tabs = getTabs(); - for (int i = 0; i < tabs.length; i++) { - ILaunchConfigurationTab configurationTab = tabs[i]; - if (configurationTab.equals(tab)) { - setActiveTab(i); - return; + if(tabs != null) { + for (int i = 0; i < tabs.length; i++) { + if (tabs[i].getClass().equals(tab.getClass())) { + setActiveTab(i); + return; + } } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupWrapper.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupWrapper.java index 45355c1b9..16bb83dc9 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupWrapper.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupWrapper.java @@ -1,6 +1,7 @@ package org.eclipse.debug.internal.ui.launchConfigurations; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.eclipse.core.runtime.CoreException; @@ -30,6 +31,9 @@ public class LaunchConfigurationTabGroupWrapper implements ILaunchConfigurationT private ILaunchConfigurationTabGroup fGroup = null; private String fGroupId = null; + /** + * listing of tab extensions that we have to create + */ private List fTabs = null; private String fMode = null; private ILaunchConfiguration fConfig = null; @@ -38,6 +42,7 @@ public class LaunchConfigurationTabGroupWrapper implements ILaunchConfigurationT * Constructor * @param group the existing group to wrapper * @param groupId the string id of the associated tab group + * @param config the launch configuration this tab group is opened on */ public LaunchConfigurationTabGroupWrapper(ILaunchConfigurationTabGroup group, String groupId, ILaunchConfiguration config) { fGroup = group; @@ -60,9 +65,8 @@ public class LaunchConfigurationTabGroupWrapper implements ILaunchConfigurationT */ public void dispose() { if(fTabs != null) { - ILaunchConfigurationTab[] tabs = getTabs(); - for(int i = 0; i < tabs.length; i++) { - tabs[i].dispose(); + for(int i = 0; i < fTabs.size(); i++) { + ((ILaunchConfigurationTab)fTabs.get(i)).dispose(); } fTabs = null; } @@ -75,41 +79,24 @@ public class LaunchConfigurationTabGroupWrapper implements ILaunchConfigurationT if(fTabs == null) { try { fTabs = new ArrayList(); - ILaunchConfigurationTab[] tmp = fGroup.getTabs(); - for(int i = 0; i < tmp.length; i++) { - fTabs.add(tmp[i]); - } + //add the tab groups' tabs first (defaults) + fTabs.addAll(Arrays.asList(fGroup.getTabs())); + //last, add the extensions (if any) LaunchConfigurationTabExtension[] ext = LaunchConfigurationPresentationManager.getDefault().getTabExtensions(fGroupId, fConfig, fMode); //copy contributed into correct position or end if no id or id is not found - AbstractLaunchConfigurationTab alct = null; String id = null; - List item = null; for(int i = 0; i < ext.length; i++) { id = ext[i].getRelativeTabId(); if(id != null) { - //position specified, try to find it - boolean found = false; - for(int j = 0; j < tmp.length; j++) { - if(tmp[j] instanceof AbstractLaunchConfigurationTab) { - alct = (AbstractLaunchConfigurationTab) tmp[j]; - if(id.equals(alct.getId())) { - if(j != tmp.length-1) { - item = new ArrayList(); - item.add(ext[i].getTab()); - fTabs.addAll(j+1, item); - found = true; - break; - } - } - } + int idx = indexofTab(id); + if(idx > -1) { + fTabs.add(idx+1, ext[i].getTab()); } - if(!found) { - //id did not match any tabs, add it to the end + else { fTabs.add(ext[i].getTab()); } } else { - //no position specified, add it to the end fTabs.add(ext[i].getTab()); } } @@ -120,14 +107,33 @@ public class LaunchConfigurationTabGroupWrapper implements ILaunchConfigurationT } /** + * Returns the index of the tab matching the specified id + * @param id the id of the tab to find the index for + * @return the index of the tab specified by the id or -1 if not found + */ + private int indexofTab(String id) { + if(id != null) { + Object o = null; + for(int i = 0; i < fTabs.size(); i++) { + o = fTabs.get(i); + if(o instanceof AbstractLaunchConfigurationTab) { + if(id.equals(((AbstractLaunchConfigurationTab)o).getId())) { + return i; + } + } + } + } + return -1; + } + + /** * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ public void initializeFrom(ILaunchConfiguration configuration) { - if(fTabs == null) { - getTabs(); - } - for(int i = 0; i < fTabs.size(); i++) { - ((ILaunchConfigurationTab)fTabs.get(i)).initializeFrom(configuration); + if(fTabs != null) { + for(int i = 0; i < fTabs.size(); i++) { + ((ILaunchConfigurationTab)fTabs.get(i)).initializeFrom(configuration); + } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java index 8e8ed6432..83a0fd7a8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java @@ -101,6 +101,11 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc fLaunchGroup = launchGroup; } + /** + * Constructor + * @param launchGroup + * @param filters + */ public LaunchConfigurationView(LaunchGroupExtension launchGroup, ViewerFilter[] filters) { super(); fLaunchGroup = launchGroup; @@ -181,6 +186,7 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc fFilterAction = new FilterLaunchConfigurationAction(); setAction(FilterLaunchConfigurationAction.ID_FILTER_ACTION, fFilterAction); + } /** @@ -277,8 +283,7 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc /** * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration) */ - public void launchConfigurationChanged(ILaunchConfiguration configuration) { - } + public void launchConfigurationChanged(ILaunchConfiguration configuration) {} /** * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java index b0ea1f82a..b5f553bc5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java @@ -99,6 +99,7 @@ public class LaunchConfigurationsMessages extends NLS { public static String LaunchConfigurationTabGroupViewer_16; + public static String LaunchConfigurationTabGroupViewer_17; public static String LaunchConfigurationTabGroupViewer_9; public static String LaunchConfigurationTabGroupViewer_13; public static String PerspectiveManager_Error_1; @@ -173,25 +174,20 @@ public class LaunchConfigurationsMessages extends NLS { public static String LaunchConfigurationTabGroupViewer_6; public static String SaveScopeResourcesHandler_1; - public static String SaveScopeResourcesHandler_2; public static String SaveScopeResourcesHandler_3; public static String FavoritesDialog_8; public static String LaunchConfigurationsDialog_0; - public static String LaunchConfigurationsDialog_1; - public static String LaunchConfigurationsDialog_4; - + public static String LaunchConfigurationsDialog_5; + public static String LaunchConfigurationsDialog_7; public static String DeleteLaunchConfigurations_0; - public static String DeleteLaunchConfigurations_1; - public static String FilterLaunchConfigurationAction_0; - - public static String LaunchConfigurationsDialog_7; + public static String LaunchConfigurationTabGroupViewer_8; @@ -201,17 +197,18 @@ public class LaunchConfigurationsMessages extends NLS { public static String FilterDropDownMenuCreator_3; public static String FilterDropDownMenuCreator_4; - public static String LaunchConfigurationsDialog_5; public static String LaunchConfigurationsDialog_c_ancel; public static String CollapseAllLaunchConfigurationAction_0; public static String CollapseAllLaunchConfigurationAction_1; public static String CollapseAllLaunchConfigurationAction_2; - public static String SelectLaunchDelegatesDialog_0; - public static String SelectLaunchDelegatesDialog_1; - public static String SelectLaunchDelegatesDialog_2; - public static String SelectLaunchDelegatesDialog_3; + public static String SelectLaunchersDialog_0; + public static String SelectLaunchersDialog_1; + public static String SelectLaunchersDialog_2; + public static String SelectLaunchersDialog_3; + public static String SelectLaunchersDialog_4; + public static String SelectLaunchersDialog_5; public static String SelectLaunchOptionsDialog_2; public static String SelectLaunchOptionsDialog_3; public static String SelectLaunchOptionsDialog_4; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties index 72f075261..3782b35eb 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties @@ -56,8 +56,9 @@ LaunchConfigurationTabGroupViewer_8=- Press the 'Filter' button to configure fil LaunchConfigurationTabGroupViewer_9=The file associated with this launch configuration is read-only and cannot be modified.\n LaunchConfigurationTabGroupViewer_13=Select a supported <a>launch mode</a>. LaunchConfigurationTabGroupViewer_14=Mixed launch mode not supported: {0} -LaunchConfigurationTabGroupViewer_15=Select preferred <a>launch tooling</a> for this type of configuration. -LaunchConfigurationTabGroupViewer_16=There is duplicate launch tooling for the mixed mode: {0} +LaunchConfigurationTabGroupViewer_15=More than one launcher available - <a>Select other...</a> +LaunchConfigurationTabGroupViewer_16=Using {0} - <a>Select other...</a> +LaunchConfigurationTabGroupViewer_17=Multiple launchers exist - <a>Choose one...</a> LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations LaunchConfigurationDialog_Dele_te_14=De&lete @@ -70,7 +71,7 @@ LaunchConfigurationDialog_Launch_configuration_already_exists_with_this_name_12= LaunchConfigurationDialog_Launch_Configuration_Error_46=Launch Configuration Error LaunchConfigurationDialog_Launch_Configurations_18=Launch Configurations LaunchConfigurationDialog_Name_required_for_launch_configuration_11=Name required for launch configuration -LaunchConfigurationDialog_Ne_w_13=Ne&w +LaunchConfigurationDialog_Ne_w_13=Ne&w\t\t LaunchConfigurationDialog_No_33=No LaunchConfigurationEditDialog_0=Modify configuration and continue. LaunchConfigurationEditDialog_1=Con&tinue @@ -174,7 +175,9 @@ CollapseAllLaunchConfigurationAction_2=This action collapses all of the launch c SelectLaunchOptionsDialog_2=A plug-in that once provided the ability to launch the saved set of launch options for the current launch configuration is no longer available. As such, you must select a valid set of launch options that can be launched SelectLaunchOptionsDialog_3=Select Launch Mode SelectLaunchOptionsDialog_4=&Select a supported mode combination: -SelectLaunchDelegatesDialog_0=There is more than one launcher capable of launching the current configuration in the current mode. Please select which launcher you would like to use. -SelectLaunchDelegatesDialog_1=Select Preferred Launcher -SelectLaunchDelegatesDialog_2=Select &preferred launcher: -SelectLaunchDelegatesDialog_3=Description +SelectLaunchersDialog_0=Select Preferred Launcher +SelectLaunchersDialog_1=&Select preferred launcher: +SelectLaunchersDialog_2=This dialog allows you to specify which launcher to use when multiple launchers are available for a configuration and launch mode. +SelectLaunchersDialog_3=Enable configuration specific settings +SelectLaunchersDialog_4=<a href="ws">Change Workspace Settings...</a> +SelectLaunchersDialog_5=Description diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchDelegatesDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchDelegatesDialog.java deleted file mode 100644 index 92d6a0875..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchDelegatesDialog.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.eclipse.debug.internal.ui.launchConfigurations; - -import java.util.Arrays; - -import org.eclipse.debug.core.ILaunchDelegate; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.SWTUtil; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; - -import com.ibm.icu.text.MessageFormat; - -/** - * This dialog class enables users to select preferred launch tooling from a list of available tooling if there are - * duplicates for the current launch (config type and mode set) - * - * @since 3.3 - * - * EXPERIMENTAL - */ -public class SelectLaunchDelegatesDialog extends SelectionDialog { - - /** - * Builds labels for list control - */ - class DelegatesLabelProvider implements ILabelProvider { - public Image getImage(Object element) {return null;} - public String getText(Object element) { - if(element instanceof ILaunchDelegate) { - ILaunchDelegate ldp = (ILaunchDelegate) element; - String name = ldp.getName(); - if(name == null) { - name = ldp.getContributorName(); - } - return name; - } - return element.toString(); - } - public void addListener(ILabelProviderListener listener) {} - public void dispose() {} - public boolean isLabelProperty(Object element, String property) {return false;} - public void removeListener(ILabelProviderListener listener) {} - } - - private static final String SETTINGS_ID = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_DELEGATES_DIALOG"; //$NON-NLS-1$ - - private CheckboxTableViewer fTableViewer = null; - private Table fTable = null; - private ILaunchDelegate[] fDelegates = null; - private Text fDescriptionText = null; - private final String EMPTY_STRING = ""; //$NON-NLS-1$ - - /** - * Constructor - * @param parentShell the parent shell - * @param delegates the current delegates context - * - * @throws CoreException - */ - public SelectLaunchDelegatesDialog(Shell parentShell, ILaunchDelegate[] delegates) { - super(parentShell); - super.setMessage(MessageFormat.format(LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_0, new String[] {})); - super.setTitle(LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_1); - setShellStyle(getShellStyle() | SWT.RESIZE); - fDelegates = delegates; - } - - /** - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - initializeDialogUnits(parent); - Composite comp = (Composite) super.createDialogArea(parent); - SWTUtil.createLabel(comp, LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_2, 1); - fTable = new Table(comp, SWT.BORDER | SWT.SINGLE | SWT.CHECK); - fTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - fTableViewer = new CheckboxTableViewer(fTable); - fTableViewer.setLabelProvider(new DelegatesLabelProvider()); - fTableViewer.setContentProvider(new ArrayContentProvider()); - fTableViewer.setInput(fDelegates); - fTableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - fTableViewer.setAllChecked(false); - fTableViewer.setChecked(event.getElement(), true); - getButton(IDialogConstants.OK_ID).setEnabled(true); - } - }); - fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection ss = (IStructuredSelection) event.getSelection(); - if(ss != null && !ss.isEmpty()) { - fDescriptionText.setText(((ILaunchDelegate)ss.getFirstElement()).getDescription()); - } - else { - fDescriptionText.setText(EMPTY_STRING); - } - } - }); - Group group = SWTUtil.createGroup(comp, LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_3, 1, 1, GridData.FILL_BOTH); - fDescriptionText = SWTUtil.createText(group, SWT.WRAP | SWT.READ_ONLY, 1, GridData.FILL_BOTH); - fDescriptionText.setBackground(group.getBackground()); - Dialog.applyDialogFont(comp); - PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_DELEGATES_DIALOG); - return comp; - } - - /** - * @see org.eclipse.ui.dialogs.SelectionDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - - /** - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - Object[] o = fTableViewer.getCheckedElements(); - if(o.length > 0) { - setResult(Arrays.asList(o)); - } - super.okPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings() - */ - protected IDialogSettings getDialogBoundsSettings() { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section = settings.getSection(SETTINGS_ID); - if (section == null) { - section = settings.addNewSection(SETTINGS_ID); - } - return section; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() - */ - protected Point getInitialSize() { - IDialogSettings settings = getDialogBoundsSettings(); - if(settings != null) { - try { - int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$ - int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$ - if(width > 0 & height > 0) { - return new Point(width, height); - } - } - catch (NumberFormatException nfe) { - return new Point(350, 400); - } - } - return new Point(350, 400); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchModesDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchModesDialog.java index aa1182f2d..2a7de971d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchModesDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchModesDialog.java @@ -18,29 +18,16 @@ import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.SWTUtil; import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IBaseLabelProvider; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; /** * This class provides a dialog to present the user with a list of of viable launch options in the event @@ -52,7 +39,7 @@ import org.eclipse.ui.dialogs.SelectionDialog; * * EXPERIMENTAL */ -public class SelectLaunchModesDialog extends SelectionDialog { +public class SelectLaunchModesDialog extends AbstractDebugSelectionDialog { /** * Builds labels for list control @@ -70,10 +57,6 @@ public class SelectLaunchModesDialog extends SelectionDialog { public void removeListener(ILabelProviderListener listener) {} } - private static final String SETTINGS_ID = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_MODES_DIALOG"; //$NON-NLS-1$ - - private CheckboxTableViewer fTableViewer = null; - private Table fTable = null; private List fValidModes = null; /** @@ -101,31 +84,6 @@ public class SelectLaunchModesDialog extends SelectionDialog { } /** - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - initializeDialogUnits(parent); - Composite comp = (Composite) super.createDialogArea(parent); - SWTUtil.createLabel(comp, LaunchConfigurationsMessages.SelectLaunchOptionsDialog_4, 1); - fTable = new Table(comp, SWT.BORDER | SWT.SINGLE | SWT.CHECK); - fTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - fTableViewer = new CheckboxTableViewer(fTable); - fTableViewer.setLabelProvider(new OptionsLabelProvider()); - fTableViewer.setContentProvider(new ArrayContentProvider()); - fTableViewer.setInput(fValidModes.toArray()); - fTableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - fTableViewer.setAllChecked(false); - fTableViewer.setChecked(event.getElement(), true); - getButton(IDialogConstants.OK_ID).setEnabled(true); - } - }); - Dialog.applyDialogFont(comp); - PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_MODES_DIALOG); - return comp; - } - - /** * @see org.eclipse.ui.dialogs.SelectionDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { @@ -145,35 +103,38 @@ public class SelectLaunchModesDialog extends SelectionDialog { } /* (non-Javadoc) - * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings() + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getDialogSettingsId() */ - protected IDialogSettings getDialogBoundsSettings() { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section = settings.getSection(SETTINGS_ID); - if (section == null) { - section = settings.addNewSection(SETTINGS_ID); - } - return section; + protected String getDialogSettingsId() { + return IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_MODES_DIALOG"; //$NON-NLS-1$ } /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getLabelProvider() */ - protected Point getInitialSize() { - IDialogSettings settings = getDialogBoundsSettings(); - if(settings != null) { - try { - int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$ - int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$ - if(width > 0 & height > 0) { - return new Point(width, height); - } - } - catch (NumberFormatException nfe) { - return new Point(350, 400); - } - } - return new Point(350, 400); + protected IBaseLabelProvider getLabelProvider() { + return new OptionsLabelProvider(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getTableViewerMessage() + */ + protected String getTableViewerMessage() { + return LaunchConfigurationsMessages.SelectLaunchOptionsDialog_4; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerInput() + */ + protected Object getViewerInput() { + return fValidModes.toArray(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getHelpContextId() + */ + protected String getHelpContextId() { + return IDebugHelpContextIds.SELECT_LAUNCH_MODES_DIALOG; } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchersDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchersDialog.java new file mode 100644 index 000000000..8109bf139 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchersDialog.java @@ -0,0 +1,270 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.launchConfigurations; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchDelegate; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IDebugHelpContextIds; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.SWTUtil; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** + * Thsi dialog is used to select a preferred launcher, and alos provides access to the + * worspace defaults for preferred launchers + * + * @since 3.3 + * EXPERIMENTAL + */ +public class SelectLaunchersDialog extends AbstractDebugSelectionDialog { + + /** + * Builds labels for table control + */ + class DelegatesLabelProvider implements ILabelProvider { + public Image getImage(Object element) {return null;} + public String getText(Object element) { + if(element instanceof ILaunchDelegate) { + ILaunchDelegate ldp = (ILaunchDelegate) element; + String name = ldp.getName(); + if(name == null) { + name = ldp.getContributorName(); + } + return name; + } + return element.toString(); + } + public void addListener(ILabelProviderListener listener) {} + public void dispose() {} + public boolean isLabelProperty(Object element, String property) {return false;} + public void removeListener(ILabelProviderListener listener) {} + } + + private Text fDescriptionText = null; + private ILaunchDelegate[] fDelegates = null; + private Button fUseSystemLauncher = null; + private ILaunchConfigurationWorkingCopy fConfiguration = null; + private String fLaunchMode = null; + + /** + * Constructor + * @param parentShell + */ + public SelectLaunchersDialog(Shell parentShell, ILaunchDelegate[] delegates, ILaunchConfigurationWorkingCopy configuration, String launchmode) { + super(parentShell); + super.setTitle(LaunchConfigurationsMessages.SelectLaunchersDialog_0); + setShellStyle(getShellStyle() | SWT.RESIZE); + fDelegates = delegates; + fConfiguration = configuration; + fLaunchMode = launchmode; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getDialogSettingsId() + */ + protected String getDialogSettingsId() { + return IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCHERS_DIALOG"; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getHelpContextId() + */ + protected String getHelpContextId() { + return IDebugHelpContextIds.SELECT_LAUNCHERS_DIALOG; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getLabelProvider() + */ + protected IBaseLabelProvider getLabelProvider() { + return new DelegatesLabelProvider(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getTableViewerMessage() + */ + protected String getTableViewerMessage() { + return LaunchConfigurationsMessages.SelectLaunchersDialog_1; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerInput() + */ + protected Object getViewerInput() { + return fDelegates; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#addCustomHeaderControls(org.eclipse.swt.widgets.Composite) + */ + protected void addCustomHeaderControls(Composite parent) { + Label label = SWTUtil.createWrapLabel(parent, LaunchConfigurationsMessages.SelectLaunchersDialog_2, 1); + ((GridData)label.getLayoutData()).widthHint = 40; + SWTUtil.createVerticalSpacer(parent, 1); + fUseSystemLauncher = SWTUtil.createCheckButton(parent, LaunchConfigurationsMessages.SelectLaunchersDialog_3, null, true); + fUseSystemLauncher.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetSelected(SelectionEvent e) { + boolean checked = ((Button)e.widget).getSelection(); + fTable.setEnabled(checked); + resetDelegate(); + } + }); + Link link = new Link(parent, SWT.NONE); + link.setText(LaunchConfigurationsMessages.SelectLaunchersDialog_4); + GridData gd = new GridData(SWT.LEFT); + gd.horizontalIndent = 25; + link.setLayoutData(gd); + link.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetSelected(SelectionEvent e) { + SWTUtil.showPreferencePage("org.eclipse.debug.ui.LaunchDelegatesPreferencePage"); //$NON-NLS-1$ + if(!fUseSystemLauncher.getSelection()) { + resetDelegate(); + } + } + }); + SWTUtil.createVerticalSpacer(parent, 1); + } + + /** + * Returns the currently checked launch delegate + * @return the currently selected launch delegate or <code>null</code> if none are checked + */ + protected ILaunchDelegate getSelectedDelegate() { + Object[] checked = fTableViewer.getCheckedElements(); + if(checked.length > 0) { + return (ILaunchDelegate) checked[0]; + } + return null; + } + + /** + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + ILaunchDelegate delegate = null; + Set modes = getCurrentModeSet(); + if(fUseSystemLauncher.getSelection()) { + delegate = getSelectedDelegate(); + if(delegate != null) { + fConfiguration.setPreferredLaunchDelegate(modes, delegate.getId()); + } + } + else { + fConfiguration.setPreferredLaunchDelegate(modes, null); + } + if(fConfiguration.isDirty()) { + try { + fConfiguration.doSave(); + } + catch (CoreException e) {DebugUIPlugin.log(e);} + } + super.okPressed(); + } + + /** + * Resets the selected and checked delegate in the preferred launcher view part to be the one from the workspace + */ + private void resetDelegate() { + if(!fUseSystemLauncher.getSelection()) { + try { + ILaunchDelegate preferred = fConfiguration.getType().getPreferredDelegate(getCurrentModeSet()); + if(preferred != null) { + fTableViewer.setSelection(new StructuredSelection(preferred)); + fTableViewer.setCheckedElements(new Object[] {preferred}); + } + else { + fTableViewer.setSelection(new StructuredSelection()); + fTableViewer.setAllChecked(false); + } + } + catch (CoreException ce) {DebugUIPlugin.log(ce);} + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#addCustomFooterControls(org.eclipse.swt.widgets.Composite) + */ + protected void addCustomFooterControls(Composite parent) { + Group group = SWTUtil.createGroup(parent, LaunchConfigurationsMessages.SelectLaunchersDialog_5, 1, 1, GridData.FILL_BOTH); + fDescriptionText = SWTUtil.createText(group, SWT.WRAP | SWT.READ_ONLY, 1, GridData.FILL_BOTH); + fDescriptionText.setBackground(group.getBackground()); + } + + /** + * @return the complete set of modes that the associated launch configuration is concerned with + */ + protected Set getCurrentModeSet() { + Set modes = new HashSet(); + try { + modes = fConfiguration.getModes(); + modes.add(fLaunchMode); + } + catch (CoreException ce) {DebugUIPlugin.log(ce);} + return modes; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#initializeControls() + */ + protected void initializeControls() { + fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection ss = (IStructuredSelection) event.getSelection(); + if(ss != null && !ss.isEmpty()) { + fDescriptionText.setText(((ILaunchDelegate)ss.getFirstElement()).getDescription()); + } + else { + fDescriptionText.setText(IInternalDebugUIConstants.EMPTY_STRING); + } + } + }); + try { + ILaunchDelegate delegate = fConfiguration.getPreferredDelegate(getCurrentModeSet()); + boolean custom = delegate != null; + fUseSystemLauncher.setSelection(custom); + if(custom) { + fTableViewer.setSelection(new StructuredSelection(delegate)); + fTableViewer.setCheckedElements(new Object[] {delegate}); + } + else { + resetDelegate(); + fTable.setEnabled(false); + } + } + catch (CoreException ce) {DebugUIPlugin.log(ce);} + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchDelegatesPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java index 509cbcba0..3981af8d4 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchDelegatesPreferencePage.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java @@ -63,7 +63,7 @@ import org.eclipse.ui.model.WorkbenchViewerComparator; * * EXPERIMENTAL */ -public class LaunchDelegatesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { +public class LaunchersPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { /** * Class to collect and persist attributes to sufficiently describe a dupicate launch delegate @@ -148,7 +148,7 @@ public class LaunchDelegatesPreferencePage extends PreferencePage implements IWo /** * Constructor */ - public LaunchDelegatesPreferencePage() { + public LaunchersPreferencePage() { setTitle(DebugPreferencesMessages.LaunchDelegatesPreferencePage_0); } |