diff options
author | Darin Wright | 2007-05-15 17:41:41 +0000 |
---|---|---|
committer | Darin Wright | 2007-05-15 17:41:41 +0000 |
commit | bb07a18b9b8dc70c59d776779b10f5edb510fb88 (patch) | |
tree | 354c8f0956e996175e4aba5f0fc4714980f8b9e7 /org.eclipse.debug.ui/ui/org | |
parent | 7910d3d0cce66de6d05325ea980504777eefe301 (diff) | |
download | eclipse.platform.debug-bb07a18b9b8dc70c59d776779b10f5edb510fb88.tar.gz eclipse.platform.debug-bb07a18b9b8dc70c59d776779b10f5edb510fb88.tar.xz eclipse.platform.debug-bb07a18b9b8dc70c59d776779b10f5edb510fb88.zip |
Bug 183509 [launching] Optimize launcher story for test driven development
Diffstat (limited to 'org.eclipse.debug.ui/ui/org')
9 files changed, 115 insertions, 58 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java index 064d3e016..5edd48771 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java @@ -26,7 +26,7 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer super(); } - /** + /* (non-Javadoc) * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ public void initializeDefaultPreferences() { @@ -49,9 +49,14 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_BREAKPOINTS, true); prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER, true); - //contextual launching preference page + /** + * Context launching preferences. Appear on the the Launching preference page + * + * @since 3.3.0 + */ prefs.setDefault(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, true); prefs.setDefault(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT, true); + prefs.setDefault(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE, false); //View Management preference page prefs.setDefault(IDebugUIConstants.PREF_MANAGE_VIEW_PERSPECTIVES, IDebugUIConstants.ID_DEBUG_PERSPECTIVE); 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 6ba06e4c9..faf69cec5 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 @@ -206,16 +206,25 @@ public interface IInternalDebugUIConstants { * Boolean preference indicating if contextual launch options should be visible * to the user rather than the "run as" menu. * - * @since 3.3 + * @since 3.3.0 * CONTEXTLAUNCHING */ public static final String PREF_USE_CONTEXTUAL_LAUNCH = IDebugUIConstants.PLUGIN_ID + ".UseContextualLaunch"; //$NON-NLS-1$ /** + * Boolean preference indicating that if the selected resource is not launchable, then we should + * launch the last configuration that was launched. + * + * @since 3.3.0 + * CONTEXTLAUNCHING + */ + public static final String PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE = IDebugUIConstants.PLUGIN_ID + ".LaunchLastIfNotLaunchable"; //$NON-NLS-1$ + + /** * Boolean preference indicating if we should always consider the parent project when * a selected context is not runnable * - * @since 3.3 + * @since 3.3.0 * CONTEXTLAUNCHING */ public static final String PREF_LAUNCH_PARENT_PROJECT = IDebugUIConstants.PLUGIN_ID + ".LaunchParentProject"; //$NON-NLS-1$ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java index 74c6bf37d..f247fb499 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java @@ -20,9 +20,6 @@ import org.eclipse.osgi.util.NLS; public class ContextMessages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.contextlaunching.ContextMessages"; //$NON-NLS-1$ public static String ContextRunner_0; - public static String ContextRunner_10; - public static String ContextRunner_11; - public static String ContextRunner_12; public static String ContextRunner_13; public static String ContextRunner_14; public static String ContextRunner_15; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties index 7e91c895f..cb30b7ba2 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties @@ -10,9 +10,6 @@ ############################################################################### ContextRunner_0=Unable To Launch ContextRunner_7=The selection cannot be launched, and there are no recent launches. -ContextRunner_10=There is no way to launch {0}\n\nWould you like to launch its project instead ({1})? -ContextRunner_11=Launch Project? -ContextRunner_12=&Always launch project if resource cannot be launched ContextRunner_13=The resource [{0}] is not accessible for launching ContextRunner_14=As... ContextRunner_15=... diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java index c55a9a2ae..52d192607 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java @@ -31,7 +31,6 @@ import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.ui.activities.WorkbenchActivityHelper; @@ -80,22 +79,33 @@ public final class ContextRunner { return; } //2. launch last if no resource + if(!launchLast(group)) { + //3. might be empty workspace try to get shortcuts + List shortcuts = getLaunchShortcutsForEmptySelection(); + if(!shortcuts.isEmpty()) { + showShortcutSelectionDialog(resource, shortcuts, group.getMode()); + } + else { + MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7); + } + } + } + + /** + * This method launches the last configuration that was launched, if any. + * @param group the launch group to launch with + * @return true if there was a last launch and it was launched, false otherwise + */ + protected boolean launchLast(ILaunchGroup group) { ILaunchConfiguration config = null; if(group != null) { config = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(group.getIdentifier()); } if(config != null) { DebugUITools.launch(config, group.getMode()); - return; - } - //3. might be empty workspace try to get shortcuts - List shortcuts = getLaunchShortcutsForEmptySelection(); - if(!shortcuts.isEmpty()) { - showShortcutSelectionDialog(resource, shortcuts, group.getMode()); - } - else { - MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7); + return true; } + return false; } /** @@ -158,28 +168,19 @@ public final class ContextRunner { return showShortcutSelectionDialog(resource, null, group.getMode()); } if(esize < 1) { - IProject project = resource.getProject(); - if(project != null && !project.equals(resource)) { - if(!DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT)) { - String msg = MessageFormat.format(ContextMessages.ContextRunner_10, new String[] {resource.getName(), project.getName()}); - MessageDialogWithToggle mdwt = new MessageDialogWithToggle(DebugUIPlugin.getShell(), - ContextMessages.ContextRunner_11, - null, - msg, - MessageDialog.QUESTION, - new String[] {IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL}, - 0, - ContextMessages.ContextRunner_12, - false); - if(mdwt.open() == IDialogConstants.YES_ID) { - DebugUIPlugin.getDefault().getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT, mdwt.getToggleState()); - selectAndLaunch(project, group); - } + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE)) { + if(launchLast(group)) { + return true; } else { - selectAndLaunch(project, group); + MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7); + return false; } } + IProject project = resource.getProject(); + if(project != null && !project.equals(resource)) { + selectAndLaunch(project, group); + } else { String msg = ContextMessages.ContextRunner_7; if(!resource.isAccessible()) { @@ -210,7 +211,9 @@ public final class ContextRunner { */ protected boolean showConfigurationSelectionDialog(List configurations, String mode) { LaunchConfigurationSelectionDialog lsd = new LaunchConfigurationSelectionDialog(DebugUIPlugin.getShell()); - lsd.setInput(configurations); + if(configurations != null) { + lsd.setInput(configurations); + } if(lsd.open() == IDialogConstants.OK_ID) { ILaunchConfiguration config = (ILaunchConfiguration) lsd.getResult()[0]; DebugUITools.launch(config, mode); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java index 0ab90803a..19c8770d4 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java @@ -108,6 +108,11 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo private HashMap fExtCache = new HashMap(); /** + * Constant denoting the empty string; + */ + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + /** * Provides a mouse tracker listener for the launching main toolbar */ private MouseTrackAdapter fMouseListener = new MouseTrackAdapter() { @@ -179,6 +184,14 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo } /** + * Returns if the the last launch configuration should be launched if the selected resource is not launchable and context launching is enabled + * @return true if the last launched should be launched, false otherwise + */ + protected boolean shouldLaunchLast() { + return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE); + } + + /** * Computes the current listing of labels for the given <code>IResource</code> context change or the * current launch history changed event */ @@ -242,6 +255,20 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo } /** + * Returns the label for the last launched configuration or and empty string if there was no last launch. + * @param group + * @return the name of the last launched configuration, altered with '(running)' if needed, or the empty + * string if there is no last launch. + */ + protected String getlastLaunchedLabel(ILaunchGroup group) { + ILaunchConfiguration config = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(group.getIdentifier()); + if(config != null) { + return appendLaunched(config); + } + return EMPTY_STRING; + } + + /** * Returns the label for the specified resource or the empty string, never <code>null</code> * @param resource * @param group @@ -251,9 +278,9 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo if(resource == null) { //no resource try last launch like the runner does if(group != null) { - ILaunchConfiguration config = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(group.getIdentifier()); - if(config != null) { - return appendLaunched(config); + String label = getlastLaunchedLabel(group); + if(!EMPTY_STRING.equals(label)) { + return label; } } //otherwise try to determine if there is a way to launch it @@ -262,7 +289,7 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo return ContextMessages.ContextRunner_14; } else { - return ""; //$NON-NLS-1$ + return EMPTY_STRING; } } LaunchConfigurationManager lcm = DebugUIPlugin.getDefault().getLaunchConfigurationManager(); @@ -297,14 +324,17 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo } int esize = exts.size(); if(esize == 0) { - IProject project = resource.getProject(); - if(project != null && !project.equals(resource)) { - if(shouldCheckParent()) { + if(shouldCheckParent()) { + IProject project = resource.getProject(); + if(project != null && !project.equals(resource)) { return getResourceLabel(project, group); } - else { - return ContextMessages.ContextRunner_15; - } + } + else if(shouldLaunchLast()) { + return getlastLaunchedLabel(group); + } + else { + return ContextMessages.ContextRunner_15; } } if(esize == 1) { @@ -418,7 +448,8 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)) { + if(event.getProperty().equals(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH) || + event.getProperty().equals(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE)) { if(isContextLaunchEnabled()) { windowActivated(DebugUIPlugin.getActiveWorkbenchWindow()); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java index c1d66834d..8cbed24a1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java @@ -83,6 +83,8 @@ public class DebugPreferencesMessages extends NLS { public static String LaunchingPreferencePage_38; public static String LaunchingPreferencePage_39; public static String LaunchingPreferencePage_4; + + public static String LaunchingPreferencePage_41; public static String LaunchingPreferencePage_5; public static String LaunchingPreferencePage_6; public static String LaunchingPreferencePage_7; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties index c7fa026ab..dcddd1945 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties @@ -78,9 +78,10 @@ LaunchingPreferencePage_34=Filter configurations in dele&ted or missing projects LaunchingPreferencePage_35=Migration LaunchingPreferencePage_36=General Options LaunchingPreferencePage_37=Always launch the previously launched appli&cation -LaunchingPreferencePage_38=Launch t&he selected resource or active editor -LaunchingPreferencePage_39=Always launch pro&ject if selected resource cannot be launched +LaunchingPreferencePage_38=Launch t&he selected resource or active editor. If not launchable: +LaunchingPreferencePage_39=Launch the associated pro&ject LaunchingPreferencePage_40=Launch Operation +LaunchingPreferencePage_41=La&unch the previously launched application ProcessPropertyPage_Command_Line__1=Co&mmand Line: ProcessPropertyPage_0=Run-&at time: diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java index dded5c056..681e55aa6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java @@ -39,11 +39,14 @@ import com.ibm.icu.text.MessageFormat; /** * A preference page for configuring launching preferences. + * + * @since 3.0.0 */ public class LaunchingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { private Button fUseContextLaunching; private Button fUseOldLaunching; + private Button fLaunchLastIfNotLaunchable; private Button fCheckParent; /** @@ -138,7 +141,7 @@ public class LaunchingPreferencePage extends FieldEditorPreferencePage implement * a nested check box * @param parent the parent to add this control to * - * @since 3.3 + * @since 3.3.0 * CONTEXTLAUNCHING */ private void createContextLaunchingControls(Composite parent) { @@ -148,7 +151,9 @@ public class LaunchingPreferencePage extends FieldEditorPreferencePage implement fUseContextLaunching.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { - fCheckParent.setEnabled(((Button)e.widget).getSelection()); + boolean enabled = ((Button)e.widget).getSelection(); + fCheckParent.setEnabled(enabled); + fLaunchLastIfNotLaunchable.setEnabled(enabled); } }); Composite space = SWTFactory.createComposite(group, 1, 1, GridData.FILL_HORIZONTAL); @@ -156,14 +161,18 @@ public class LaunchingPreferencePage extends FieldEditorPreferencePage implement gd.horizontalIndent = 10; GridLayout layout = (GridLayout) space.getLayout(); layout.marginHeight = 0; - fCheckParent = SWTFactory.createCheckButton(space, DebugPreferencesMessages.LaunchingPreferencePage_39, null, false, 1); + fCheckParent = SWTFactory.createRadioButton(space, DebugPreferencesMessages.LaunchingPreferencePage_39); + fLaunchLastIfNotLaunchable = SWTFactory.createRadioButton(space, DebugPreferencesMessages.LaunchingPreferencePage_41); //initialize the buttons boolean value = getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH); fUseOldLaunching.setSelection(!value); fUseContextLaunching.setSelection(value); - fCheckParent.setSelection(getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT)); + boolean enable = getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT); + fCheckParent.setSelection(enable); fCheckParent.setEnabled(value); + fLaunchLastIfNotLaunchable.setSelection(!enable); + fLaunchLastIfNotLaunchable.setEnabled(value); } /* (non-Javadoc) @@ -178,9 +187,11 @@ public class LaunchingPreferencePage extends FieldEditorPreferencePage implement boolean value = getPreferenceStore().getDefaultBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH); fUseOldLaunching.setSelection(!value); fUseContextLaunching.setSelection(value); - fCheckParent.setSelection(getPreferenceStore().getDefaultBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT)); + boolean parent = getPreferenceStore().getDefaultBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT); + fCheckParent.setSelection(parent); fCheckParent.setEnabled(value); - super.performDefaults(); + fLaunchLastIfNotLaunchable.setSelection(!parent); + fLaunchLastIfNotLaunchable.setEnabled(value); } /* (non-Javadoc) @@ -189,6 +200,7 @@ public class LaunchingPreferencePage extends FieldEditorPreferencePage implement public boolean performOk() { getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, fUseContextLaunching.getSelection()); getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT, fCheckParent.getSelection()); + getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE, fLaunchLastIfNotLaunchable.getSelection()); return super.performOk(); } |