Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java146
1 files changed, 119 insertions, 27 deletions
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 fe6b175b2..70e1bb46e 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -72,28 +72,59 @@ public final class ContextRunner {
private LaunchingResourceManager fLRM = DebugUIPlugin.getDefault().getLaunchingResourceManager();
/**
- * Performs the context launching given the object context and the mode to launch in.
+ * Performs the context launching given the object context and the mode to
+ * launch in.
+ *
* @param group the launch group to launch using
+ * @deprecated use launch(ILaunchGroup, boolean)
*/
+ @Deprecated
public void launch(ILaunchGroup group) {
+ launch(group, false);
+ }
+
+ /**
+ * Performs the context launching given the object context and the mode to
+ * launch in.
+ *
+ * @param group the launch group to launch using
+ * @param isShift is Shift pressed (use <code>false</code> if no support for
+ * Shift)
+ */
+ public void launch(ILaunchGroup group, boolean isShift) {
IStructuredSelection selection = SelectedResourceManager.getDefault().getCurrentSelection();
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
- selectAndLaunch(resource, group, selection);
+ selectAndLaunch(resource, group, selection, isShift);
}
-
-
/**
* 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
+ * @return true if there was a last launch and it was launched, false
+ * otherwise
+ * @deprecated use launchLast(ILaunchGroup, boolean)
*/
+ @Deprecated
protected boolean launchLast(ILaunchGroup group) {
+ return launchLast(group, false);
+ }
+
+ /**
+ * This method launches the last configuration that was launched, if any.
+ *
+ * @param group the launch group to launch with
+ * @param isShift is Shift pressed (use <code>false</code> if no support for
+ * Shift)
+ * @return true if there was a last launch and it was launched, false
+ * otherwise
+ */
+ protected boolean launchLast(ILaunchGroup group, boolean isShift) {
ILaunchConfiguration config = null;
if(group != null) {
config = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(group.getIdentifier());
if(config != null) {
- launch(config, group.getMode());
+ launch(config, group.getMode(), isShift);
return true;
}
}
@@ -101,14 +132,31 @@ public final class ContextRunner {
}
/**
- * Prompts the user to select a way of launching the current resource, where a 'way'
- * is defined as a launch shortcut.
+ * Prompts the user to select a way of launching the current resource, where
+ * a 'way' is defined as a launch shortcut.
*
* @param resource the resource context
* @param group the launch group to launch with
* @param selection the current selection
+ * @deprecated use selectAndLaunch(IResource, ILaunchGroup,
+ * IStructuredSelection, boolean)
*/
+ @Deprecated
protected void selectAndLaunch(IResource resource, ILaunchGroup group, IStructuredSelection selection) {
+ selectAndLaunch(resource, group, selection, false);
+ }
+
+ /**
+ * Prompts the user to select a way of launching the current resource, where
+ * a 'way' is defined as a launch shortcut.
+ *
+ * @param resource the resource context
+ * @param group the launch group to launch with
+ * @param selection the current selection
+ * @param isShift is Shift pressed (use <code>false</code> if no support for
+ * Shift)
+ */
+ protected void selectAndLaunch(IResource resource, ILaunchGroup group, IStructuredSelection selection, boolean isShift) {
if(group != null) {
LaunchConfigurationManager lcm = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
String mode = group.getMode();
@@ -122,33 +170,33 @@ public final class ContextRunner {
//see if the context is a shared configuration
ILaunchConfiguration config = lcm.isSharedConfig(resource);
if(config != null) {
- launch(config, mode);
+ launch(config, mode, isShift);
return;
}
//get the configurations from the resource and participants
List<ILaunchConfiguration> configs = fLRM.getParticipatingLaunchConfigurations(selection, resource, shortcuts, mode);
int csize = configs.size();
if(csize == 1) {
- launch(configs.get(0), mode);
+ launch(configs.get(0), mode, isShift);
}
else if(csize < 1) {
int esize = shortcuts.size();
if(esize == 1) {
- launchShortcut(selection, shortcuts.get(0), mode);
+ launchShortcut(selection, shortcuts.get(0), mode, isShift);
}
else if(esize > 1) {
- showShortcutSelectionDialog(resource, shortcuts, mode, selection);
+ showShortcutSelectionDialog(resource, shortcuts, mode, selection, isShift);
}
else if(esize < 1) {
if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE)) {
- if(!launchLast(group)) {
+ if (!launchLast(group, isShift)) {
MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7);
}
} else {
if(resource != null) {
IProject project = resource.getProject();
if(project != null && !project.equals(resource)) {
- selectAndLaunch(project, group, new StructuredSelection(project));
+ selectAndLaunch(project, group, new StructuredSelection(project), isShift);
}
else {
String msg = ContextMessages.ContextRunner_7;
@@ -159,7 +207,7 @@ public final class ContextRunner {
}
}
else {
- if (!launchLast(group)) {
+ if (!launchLast(group, isShift)) {
MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7);
}
}
@@ -169,9 +217,9 @@ public final class ContextRunner {
else if(csize > 1){
config = lcm.getMRUConfiguration(configs, group, resource);
if(config != null) {
- launch(config, mode);
+ launch(config, mode, isShift);
} else {
- showConfigurationSelectionDialog(configs, mode);
+ showConfigurationSelectionDialog(configs, mode, isShift);
}
}
}
@@ -182,28 +230,36 @@ public final class ContextRunner {
*
* @param configuration configuration to launch
* @param mode launch mode identifier
+ * @param isShift is Shift pressed
*/
- private void launch(ILaunchConfiguration configuration, String mode) {
+ private void launch(ILaunchConfiguration configuration, String mode, boolean isShift) {
if (validateMode(configuration, mode)) {
- DebugUITools.launch(configuration, mode);
+ DebugUITools.launch(configuration, mode, isShift);
}
}
/**
- * Delegate method that calls the appropriate launch method on a <code>LaunchShortcutExtension</code> given
- * the current resource and selection context
+ * Delegate method that calls the appropriate launch method on a
+ * <code>LaunchShortcutExtension</code> given the current resource and
+ * selection context
+ *
* @param selection the current selection
* @param shortcut the shortcut that wants to launch
* @param mode the mode to launch in
+ * @param isShift is Shift pressed
*
* @since 3.4
*/
- private void launchShortcut(IStructuredSelection selection, LaunchShortcutExtension shortcut, String mode) {
+ private void launchShortcut(IStructuredSelection selection, LaunchShortcutExtension shortcut, String mode, boolean isShift) {
Object o = selection.getFirstElement();
+ // store if Shift was pressed to toggle terminate before launch
+ // preference
if(o instanceof IEditorPart) {
+ DebugUITools.storeLaunchToggleTerminate(o, isShift);
shortcut.launch((IEditorPart) o, mode);
}
else {
+ DebugUITools.storeLaunchToggleTerminate(selection, isShift);
shortcut.launch(selection, mode);
}
}
@@ -243,17 +299,34 @@ public final class ContextRunner {
}
/**
- * Presents the user with a dialog to pick the launch configuration to launch
- * and launches that configuration.
+ * Presents the user with a dialog to pick the launch configuration to
+ * launch and launches that configuration.
*
* @param configurations the listing of applicable configurations to present
* @param mode the mode
+ * @deprecated use
+ * showConfigurationSelectionDialog(List<ILaunchConfiguration>,
+ * String, boolean)
*/
+ @Deprecated
protected void showConfigurationSelectionDialog(List<ILaunchConfiguration> configurations, String mode) {
+ showConfigurationSelectionDialog(configurations, mode, false);
+ }
+
+ /**
+ * Presents the user with a dialog to pick the launch configuration to
+ * launch and launches that configuration.
+ *
+ * @param configurations the listing of applicable configurations to present
+ * @param mode the mode
+ * @param isShift is Shift pressed (use <code>false</code> if no support for
+ * Shift)
+ */
+ protected void showConfigurationSelectionDialog(List<ILaunchConfiguration> configurations, String mode, boolean isShift) {
LaunchConfigurationSelectionDialog lsd = new LaunchConfigurationSelectionDialog(DebugUIPlugin.getShell(), configurations);
if(lsd.open() == IDialogConstants.OK_ID) {
ILaunchConfiguration config = (ILaunchConfiguration) lsd.getResult()[0];
- launch(config, mode);
+ launch(config, mode, isShift);
}
}
@@ -265,15 +338,34 @@ public final class ContextRunner {
* @param shortcuts the list of applicable shortcuts
* @param mode the mode
* @param selection the current selection
+ * @deprecated use showShortcutSelectionDialog(IResource,
+ * List<LaunchShortcutExtension>, String,IStructuredSelection,
+ * boolean)
*/
+ @Deprecated
protected void showShortcutSelectionDialog(IResource resource, List<LaunchShortcutExtension> shortcuts, String mode, IStructuredSelection selection) {
+ showShortcutSelectionDialog(resource, shortcuts, mode, selection, false);
+ }
+
+ /**
+ * Presents a selection dialog to the user to pick a launch shortcut and
+ * launch using that shortcut.
+ *
+ * @param resource the resource context
+ * @param shortcuts the list of applicable shortcuts
+ * @param mode the mode
+ * @param selection the current selection
+ * @param isShift is Shift pressed (use <code>false</code> if no support for
+ * Shift)
+ */
+ protected void showShortcutSelectionDialog(IResource resource, List<LaunchShortcutExtension> shortcuts, String mode, IStructuredSelection selection, boolean isShift) {
LaunchShortcutSelectionDialog dialog = new LaunchShortcutSelectionDialog(shortcuts, resource, mode);
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
if(result.length > 0) {
LaunchShortcutExtension method = (LaunchShortcutExtension) result[0];
if(method != null) {
- launchShortcut(selection, method, mode);
+ launchShortcut(selection, method, mode, isShift);
}
}
}

Back to the top