Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2004-11-12 19:32:34 +0000
committerDarin Wright2004-11-12 19:32:34 +0000
commitd9f876e51eedf394cbea67fbda2ae5dda87a4c80 (patch)
tree13270981aea77760c0d0b4263b02c835392267ce /org.eclipse.debug.ui
parent3cde69448bb1747db1532f39d0eba023ff5c115c (diff)
downloadeclipse.platform.debug-d9f876e51eedf394cbea67fbda2ae5dda87a4c80.tar.gz
eclipse.platform.debug-d9f876e51eedf394cbea67fbda2ae5dda87a4c80.tar.xz
eclipse.platform.debug-d9f876e51eedf394cbea67fbda2ae5dda87a4c80.zip
Bug 29581 - Launch shortcut hotkeys
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java2
5 files changed, 63 insertions, 3 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index f0ecca8f3..098145ff5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -358,6 +358,8 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener {
SelectedResourceManager.getDefault();
}
});
+ // forces launch shortcuts to be intialized so their key-bindings work
+ getLaunchConfigurationManager().getLaunchShortcuts();
}
protected IProcess getProcessFromInput(Object input) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
index caa975fe1..c6f0277ef 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
@@ -30,11 +31,20 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.Pair;
+import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPluginContribution;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.AbstractHandler;
+import org.eclipse.ui.commands.ExecutionException;
+import org.eclipse.ui.commands.HandlerSubmission;
+import org.eclipse.ui.commands.IHandler;
+import org.eclipse.ui.commands.IWorkbenchCommandSupport;
+import org.eclipse.ui.commands.Priority;
import org.osgi.framework.Bundle;
@@ -52,6 +62,38 @@ public class LaunchShortcutExtension implements ILaunchShortcut, IPluginContribu
private Expression fStandardLaunchExpr = null;
/**
+ * Command handler for launch shortcut key binding.
+ */
+ private class LaunchCommandHandler extends AbstractHandler {
+ // the shortcut to invoke
+ private LaunchShortcutExtension fShortcut;
+ private String fMode;
+
+ /**
+ * Constructs a new command handler for the given shortcut
+ *
+ * @param shortcut
+ */
+ public LaunchCommandHandler(LaunchShortcutExtension shortcut, String mode) {
+ fShortcut = shortcut;
+ fMode = mode;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.commands.IHandler#execute(java.util.Map)
+ */
+ public Object execute(Map parameterValuesByName) throws ExecutionException {
+ LaunchShortcutAction action = new LaunchShortcutAction(fMode, fShortcut);
+ if (action.isEnabled()) {
+ action.run();
+ } else {
+ fShortcut.launch(new StructuredSelection(), fMode);
+ }
+ return null;
+ }
+ }
+
+ /**
* The configuration element defining this tab.
*/
private IConfigurationElement fConfig;
@@ -67,9 +109,25 @@ public class LaunchShortcutExtension implements ILaunchShortcut, IPluginContribu
*/
public LaunchShortcutExtension(IConfigurationElement element) {
setConfigurationElement(element);
+ registerLaunchCommandHandlers();
}
/**
+ * Registers command handlers for launch shortcut key bindings
+ */
+ private void registerLaunchCommandHandlers() {
+ Iterator modes = getModes().iterator();
+ IWorkbenchCommandSupport commandSupport = PlatformUI.getWorkbench().getCommandSupport();
+ while (modes.hasNext()) {
+ String mode = (String) modes.next();
+ String id = getId() + "." + mode; //$NON-NLS-1$
+ IHandler handler = new LaunchCommandHandler(this, mode);
+ HandlerSubmission submission = new HandlerSubmission(null, null, null, id, handler, Priority.MEDIUM);
+ commandSupport.addHandlerSubmission(submission);
+ }
+ }
+
+ /**
* Sets the configuration element that defines the attributes
* for this extension.
*
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
index 59737f2b6..71a9be64c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
@@ -260,7 +260,7 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, I
*/
private void populateMenuItem(String mode, LaunchShortcutExtension ext, Menu menu, int accelerator) {
LaunchShortcutAction action = new LaunchShortcutAction(mode, ext);
- action.setActionDefinitionId(ext.getId());
+ action.setActionDefinitionId(ext.getId() + "." + mode); //$NON-NLS-1$
String helpContextId = ext.getHelpContextId();
if (helpContextId != null) {
WorkbenchHelp.setHelp(action, helpContextId);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java
index 2627d3651..5aa8f341d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java
@@ -187,7 +187,7 @@ public class LaunchAsAction extends Action implements IMenuCreator, IWorkbenchWi
*/
private void populateMenu(LaunchShortcutExtension ext, Menu menu, int menuCount) {
LaunchShortcutAction action = new LaunchShortcutAction(getMode(), ext);
- action.setActionDefinitionId(ext.getId());
+ action.setActionDefinitionId(ext.getId() + "." + getMode()); //$NON-NLS-1$
String helpContextId = ext.getHelpContextId();
if (helpContextId != null) {
WorkbenchHelp.setHelp(action, helpContextId);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
index 2e920b390..9ea5acd0f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
@@ -218,7 +218,7 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork
*/
private void populateMenuItem(String mode, LaunchShortcutExtension ext, Menu menu, int accelerator) {
LaunchShortcutAction action = new LaunchShortcutAction(mode, ext);
- action.setActionDefinitionId(ext.getId());
+ action.setActionDefinitionId(ext.getId() + "." + mode); //$NON-NLS-1$
String helpContextId = ext.getHelpContextId();
if (helpContextId != null) {
WorkbenchHelp.setHelp(action, helpContextId);

Back to the top