Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html2
-rw-r--r--org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchConfigurationShortcuts.html67
-rw-r--r--org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchShortcuts.html78
-rw-r--r--org.eclipse.debug.ui/plugin.properties2
-rw-r--r--org.eclipse.debug.ui/plugin.xml2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java60
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchWithConfigurationAction.java60
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java97
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabExtension.java116
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java193
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java91
13 files changed, 521 insertions, 255 deletions
diff --git a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html
index cded6e553..dce0764d3 100644
--- a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html
+++ b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html
@@ -27,7 +27,7 @@ stepping, terminating, etc. <br>
<li><a href="org_eclipse_debug_ui_debugModelPresentations.html">org.eclipse.debug.ui.debugModelPresentations</a></li>
<li><a href="org_eclipse_debug_ui_launchConfigurationTabGroups.html">org.eclipse.debug.ui.launchConfigurationTabGroups</a></li>
<li><a href="org_eclipse_debug_ui_launchConfigurationTypeImages.html">org.eclipse.debug.ui.launchConfigurationTypeImages</a></li>
- <li><a href="org_eclipse_debug_ui_launchConfigurationShortcuts.html">org.eclipse.debug.ui.launchConfigurationShortcuts</a></li>
+ <li><a href="org_eclipse_debug_ui_launchShortcuts.html">org.eclipse.debug.ui.launchShortcuts</a></li>
</ul>
<p><a href="hglegal.htm"><img src="ngibmcpy.gif" alt="Copyright IBM Corp. 2000, 2001. All Rights Reserved."
diff --git a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchConfigurationShortcuts.html b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchConfigurationShortcuts.html
deleted file mode 100644
index d7d8001a8..000000000
--- a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchConfigurationShortcuts.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>README Launch Configuration Shortcuts Extension Point</title>
-</head>
-
-<body link="#0000FF" vlink="#800080">
-
-<h1 align="center">Launch Configuration Shortcuts</h1>
-
-<p><b><i>Identifier: </i></b>org.eclipse.debug.ui.launchConfigurationShortcuts</p>
-
-<p><b><i>Description: </i></b>This extension point provides a
-mechanism for specifying which launch configuration types have menu shortcuts present
-in the UI for creating a new launch configuration of that type.</p>
-
-<p><b><i>Configuration Markup:</i></b> </p>
-
-<pre>
-<tt>&nbsp;&nbsp; &lt;!ELEMENT shortcut (perspective)*</tt>&gt;
-<tt>&nbsp;&nbsp; &lt;!ATTLIST shortcut</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; configTypeID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
-</pre>
-
-<ul>
-<li><code>id</code> specifies a unique identifier for this launch configuration
- shortcut.</li>
-<li><code>configTypeID</code> specifies a launch configuration type id.</li>
-</ul>
-
-<pre>
-<tt>&nbsp;&nbsp; &lt;!ELEMENT perspective</tt>&gt;
-<tt>&nbsp;&nbsp; &lt;!ATTLIST perspective</tt>
-<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>&gt;
-</pre>
-
-<ul>
- <li><code>id</code> - the unique identifier of a perspective in which a menu shortcut for the
- specified launch configuration type will appear</li>
-</ul>
-
-<p><b><i>Examples:</i></b> </p>
-
-<p>The following is an example of a launch configuration shortcut extension point: </p>
-
-<pre>
-&lt;extension point="org.eclipse.debug.ui.launchConfigurationShortcuts
- &lt;shortcut
- id="com.example.ExampleLaunchConfigurationShortcut"
- configTypeID="com.example.ExampleLaunchConfigurationTypeIdentifier"&gt;
- &lt;perspective id="org.eclipse.jdt.ui.JavaPerspective"/&gt;
- &lt;perspective id="org.eclipse.debug.ui.DebugPerspective"/&gt;
- &lt;/shortcut&gt;
-&lt;/extension&gt;
-</pre>
-<p>In the above example, a menu shortcut will be shown for the launch configuration type
-with identifier <code>com.example.ExampleLaunchConfigurationTypeIdentifier</code> in the
-JavaPerspective and the DebugPerspective.
-</p>
-
-<p><a href="hglegal.htm"><img src="ngibmcpy.gif" alt="Copyright IBM Corp. 2000, 2001. All Rights Reserved."
-border="0" width="195" height="12"></a></p>
-</body>
-</html>
diff --git a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchShortcuts.html b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchShortcuts.html
new file mode 100644
index 000000000..f8bc44552
--- /dev/null
+++ b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_launchShortcuts.html
@@ -0,0 +1,78 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>README Launch Shortcuts Extension Point</title>
+</head>
+
+<body link="#0000FF" vlink="#800080">
+
+<h1 align="center">Launch Shortcuts</h1>
+
+<p><b><i>Identifier: </i></b>org.eclipse.debug.ui.launchShortcuts</p>
+
+<p><b><i>Description: </i></b>This extension point provides
+support for selection sensitive launching. Extensions register a shortcut which appears
+in the run and/or debug cascade menus to lanuch the workbench selection or active
+edtior.</p>
+
+<p><b><i>Configuration Markup:</i></b> </p>
+
+<pre>
+<tt>&nbsp;&nbsp; &lt;!ELEMENT shortcut (perspective)*</tt>&gt;
+<tt>&nbsp;&nbsp; &lt;!ATTLIST shortcut</tt>
+<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
+<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
+<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
+<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; label&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
+<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
+</pre>
+
+<ul>
+<li><code>id</code> specifies a unique identifier for this launch shortcut.</li>
+<li><code>modes</code> specifies a comma separated list of modes this shortcut supports.</li>
+<li><code>class</code> specifies the fully qualified name of a class which implements
+ <code>org.eclipse.debug.ui.ILaunchShortcut</code>.</li>
+<li><code>label</code> specifies a label used to render this shortcut.</li>
+<li><code>icon</code> specifies a plug-in relative path to an image used to render this
+ shortcut.</li>
+</ul>
+
+<pre>
+<tt>&nbsp;&nbsp; &lt;!ELEMENT perspective</tt>&gt;
+<tt>&nbsp;&nbsp; &lt;!ATTLIST perspective</tt>
+<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>&gt;
+</pre>
+
+<ul>
+ <li><code>id</code> - the unique identifier of a perspective in which a menu shortcut for the
+ this launch shortcut will appear</li>
+</ul>
+
+<p><b><i>Examples:</i></b> </p>
+
+<p>The following is an example of a launch shortcut extension point: </p>
+
+<pre>
+&lt;extension point="org.eclipse.debug.ui.launchShortcuts
+ &lt;shortcut
+ id="com.example.ExampleLaunchShortcutId"
+ modes="run,debug"
+ class="com.example.ExampleLaunchShortcutImpl"
+ label="Example Launch Shortcut"
+ icon="icons\example.gif"&gt;
+ &lt;perspective id="org.eclipse.jdt.ui.JavaPerspective"/&gt;
+ &lt;perspective id="org.eclipse.debug.ui.DebugPerspective"/&gt;
+ &lt;/shortcut&gt;
+&lt;/extension&gt;
+</pre>
+<p>In the above example, a launch shortcut will be shown in the run and debug cascade menus
+with the label "Example Launch Shortcut", in the
+JavaPerspective and the DebugPerspective.
+</p>
+
+<p><a href="hglegal.htm"><img src="ngibmcpy.gif" alt="Copyright IBM Corp. 2000, 2001. All Rights Reserved."
+border="0" width="195" height="12"></a></p>
+</body>
+</html>
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index a1561d5b3..46af53be7 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -37,7 +37,7 @@ EnableBreakpointsAction.label=&Enable
ExpressionView.name=Expressions
LaunchActionSet.label=Launch
LaunchConfigurationTabGroupExtensionName=Launch Configuration Tab Group
-LaunchConfigurationShortcutName=Launch Configuration Shortcut
+LaunchShortcutsName=Launch Shortcut
LaunchConfigurationTypeImageExtensionName=Launch Configuration Type Image
LaunchConfigurationTypePropertyPage.name=Launch Configuration Type
LaunchConfigurationTypesPreferencePage.name=Launch Configuration Types
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index f7fd740a9..842fbe213 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -23,7 +23,7 @@
<!-- Extension points -->
<extension-point id="debugModelPresentations" name="%DebugModelPresentationExtensionName"/>
-<extension-point id="launchConfigurationShortcuts" name="%LaunchConfigurationShortcutName"/>
+<extension-point id="launchShortcuts" name="%LaunchShortcutsName"/>
<extension-point id="launchConfigurationTabGroups" name="%LaunchConfigurationTabGroupExtensionName"/>
<extension-point id="launchConfigurationTypeImages" name="%LaunchConfigurationTypeImageExtensionName"/>
<extension-point id="debugActionGroups" name="%DebugActionGroupsExtensionName"/>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java
new file mode 100644
index 000000000..e80f3a934
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java
@@ -0,0 +1,60 @@
+package org.eclipse.debug.internal.ui.actions;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Launch shortcut action (proxy to a launch shortcut extension)
+ */
+public class LaunchShortcutAction extends Action {
+
+ private String fMode;
+ private LaunchShortcutExtension fShortcut;
+
+
+ /**
+ * Constructor for LaunchShortcutAction.
+ */
+ public LaunchShortcutAction(String mode, LaunchShortcutExtension shortcut) {
+ super(shortcut.getLabel(), shortcut.getImageDescriptor());
+ fMode = mode;
+ fShortcut = shortcut;
+ }
+
+
+
+ /**
+ * Runs with either the active editor or workbench selection.
+ *
+ * @see IAction#run()
+ */
+ public void run() {
+ IWorkbenchWindow wb = DebugUIPlugin.getActiveWorkbenchWindow();
+ if (wb != null) {
+ IWorkbenchPage page = wb.getActivePage();
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ fShortcut.launch(selection, fMode);
+ } else {
+ IEditorPart editor = page.getActiveEditor();
+ if (editor != null) {
+ fShortcut.launch(editor, fMode);
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchWithConfigurationAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchWithConfigurationAction.java
index e8d6835ff..698386a57 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchWithConfigurationAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchWithConfigurationAction.java
@@ -16,6 +16,8 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
@@ -104,61 +106,35 @@ public abstract class LaunchWithConfigurationAction extends Action implements IM
// Retrieve the current perspective and the registered shortcuts
String activePerspID = getActivePerspectiveID();
- Map shortcutMap = DebugUIPlugin.getLaunchConfigurationManager().getLaunchConfigurationShortcuts();
-
- // Look through the shortcut map and for each config type, see if the active perspective's
- // ID is listed. If it is, add a shortcut for creating a new configuration of that type
- // to the menu
- List configTypeList = new ArrayList(shortcutMap.keySet().size());
- Iterator keyIterator = shortcutMap.keySet().iterator();
- while (keyIterator.hasNext()) {
- String configTypeID = (String) keyIterator.next();
- List perspList = (List) shortcutMap.get(configTypeID);
- if ((perspList.contains(activePerspID)) || (perspList.contains("*"))) { //$NON-NLS-1$
- ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType(configTypeID);
- if (configType.supportsMode(getMode()) && configType.isPublic()) {
- configTypeList.add(configType);
- }
- }
- }
+ List shortcuts = LaunchConfigurationManager.getDefault().getLaunchShortcuts(activePerspID);
- // If NO configuration types listed the current perspective as a place to add a shortcut,
- // add shortcuts for ALL configuration types to avoid an empty cascading menu
- if (configTypeList.isEmpty()) {
- ILaunchConfigurationType[] allConfigTypes = getLaunchManager().getLaunchConfigurationTypes();
- for (int i = 0; i < allConfigTypes.length; i++) {
- ILaunchConfigurationType configType = allConfigTypes[i];
- if (configType.supportsMode(getMode()) && configType.isPublic()) {
- configTypeList.add(configType);
- }
- }
+ // If NO shortcuts are listed in the current perspective, add ALL shortcuts
+ // to avoid an empty cascading menu
+ if (shortcuts == null || shortcuts.isEmpty()) {
+ shortcuts = LaunchConfigurationManager.getDefault().getLaunchShortcuts();
}
// Sort the applicable config types alphabetically and add them to the menu
Menu menu= new Menu(parent);
int menuCount = 1;
- Collections.sort(configTypeList, new LaunchConfigurationTypeAlphabeticComparator());
- Iterator typeIterator = configTypeList.iterator();
- while (typeIterator.hasNext()) {
- ILaunchConfigurationType configType = (ILaunchConfigurationType) typeIterator.next();
- populateMenu(configType, menu, menuCount);
- menuCount++;
+ Iterator iter = shortcuts.iterator();
+ while (iter.hasNext()) {
+ LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next();
+ if (ext.getModes().contains(getMode())) {
+ populateMenu(ext, menu, menuCount);
+ menuCount++;
+ }
}
return menu;
}
/**
- * Add the configuration type to the menu.
+ * Add the shortcut to the menu.
*/
- protected void populateMenu(ILaunchConfigurationType configType, Menu menu, int menuCount) {
- OpenLaunchConfigurationsAction openAction = null;
- if (getMode().equals(ILaunchManager.DEBUG_MODE)) {
- openAction = new OpenDebugConfigurations(configType);
- } else {
- openAction = new OpenRunConfigurations(configType);
- }
- createMenuForAction(menu, openAction, menuCount);
+ protected void populateMenu(LaunchShortcutExtension ext, Menu menu, int menuCount) {
+ LaunchShortcutAction action = new LaunchShortcutAction(getMode(), ext);
+ createMenuForAction(menu, action, menuCount);
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
index 8fcb93d16..bd6e18a11 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
@@ -6,6 +6,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -96,14 +98,18 @@ public class LaunchConfigurationManager implements ILaunchListener,
* The list of registered implementors of <code>ILaunchHistoryChangedListener</code>
*/
protected List fLaunchHistoryChangedListeners = new ArrayList(3);
+
/**
- * The mapping of launch configuration type IDs to lists of perspectives.
- * A shortcut for bringing up the launch configuration dialog initialized to
- * the specified config type will appear in each specified perspective.
+ * Launch shortcuts
*/
- protected Map fLaunchConfigurationShortcuts;
+ private List fLaunchShortcuts = null;
/**
+ * Launch shortcuts, cached by perspective ids
+ */
+ private Map fLaunchShortcutsByPerspective = null;
+
+ /**
* Cache of launch configuration tab images with error overlays
*/
protected ImageRegistry fErrorImages = null;
@@ -138,7 +144,6 @@ public class LaunchConfigurationManager implements ILaunchListener,
}
DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
addLaunchHistoryListener(this);
- loadLaunchConfigurationShortcuts();
}
protected void setRunHistoryVector(Vector runHistory) {
@@ -181,7 +186,7 @@ public class LaunchConfigurationManager implements ILaunchListener,
ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
launchManager.removeLaunchListener(this);
launchManager.removeLaunchConfigurationListener(this);
- removeLaunchHistoryListener(this);
+ removeLaunchHistoryListener(this);
DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
}
@@ -785,36 +790,70 @@ public class LaunchConfigurationManager implements ILaunchListener,
}
/**
- * Load all registered extensions of the 'launch configuration shortcut' extension point.
+ * Load all registered extensions of the 'launch shortcut' extension point.
*/
- private void loadLaunchConfigurationShortcuts() {
+ private void loadLaunchShortcuts() {
// Get the configuration elements
IPluginDescriptor descriptor= DebugUIPlugin.getDefault().getDescriptor();
- IExtensionPoint extensionPoint= descriptor.getExtensionPoint(IDebugUIConstants.EXTENSION_POINT_LAUNCH_CONFIGURATION_SHORTCUTS);
+ IExtensionPoint extensionPoint= descriptor.getExtensionPoint(IDebugUIConstants.EXTENSION_POINT_LAUNCH_SHORTCUTS);
IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
// Load the configuration elements into a Map
- fLaunchConfigurationShortcuts = new HashMap(infos.length);
+ fLaunchShortcuts = new ArrayList(infos.length);
for (int i = 0; i < infos.length; i++) {
- IConfigurationElement configElement = infos[i];
- String configTypeID = configElement.getAttribute("configTypeID"); //$NON-NLS-1$
- IConfigurationElement[] children = configElement.getChildren("perspective"); //$NON-NLS-1$
- List perspChildren = new ArrayList(children.length);
- for (int j = 0; j < children.length; j++) {
- String perspID = children[j].getAttribute("id"); //$NON-NLS-1$
- perspChildren.add(perspID);
- }
- fLaunchConfigurationShortcuts.put(configTypeID, perspChildren);
+ LaunchShortcutExtension ext = new LaunchShortcutExtension(infos[i]);
+ fLaunchShortcuts.add(ext);
}
}
+
/**
- * Return a <code>Map</code> of launch configuration type IDs to <code>List</code>s of
- * perspective IDs. This map indicates which perspectives should have menu shortcuts present
- * for creating launch configurations of the listed configuration types.
+ * Returns all launch shortcuts
+ *
+ * @return all launch shortcuts
*/
- public Map getLaunchConfigurationShortcuts() {
- return fLaunchConfigurationShortcuts;
+ public List getLaunchShortcuts() {
+ if (fLaunchShortcuts == null) {
+ loadLaunchShortcuts();
+ }
+ return fLaunchShortcuts;
+ }
+
+ /**
+ * Returns all launch shortcuts defined for the given perspective,
+ * or <code>null</code> if none
+ *
+ * @param perpsective perspective identifier
+ * @return all launch shortcuts defined for the given perspective,
+ * or <code>null</code> if none
+ */
+ public List getLaunchShortcuts(String perpsective) {
+ if (fLaunchShortcutsByPerspective == null) {
+ Iterator shortcuts = getLaunchShortcuts().iterator();
+ fLaunchShortcutsByPerspective = new HashMap(10);
+ while (shortcuts.hasNext()) {
+ LaunchShortcutExtension ext = (LaunchShortcutExtension)shortcuts.next();
+ Iterator perspectives = ext.getPerspectives().iterator();
+ while (perspectives.hasNext()) {
+ String id = (String)perspectives.next();
+ List list = (List)fLaunchShortcutsByPerspective.get(id);
+ if (list == null) {
+ list = new ArrayList(4);
+ fLaunchShortcutsByPerspective.put(id, list);
+ }
+ list.add(ext);
+ }
+ }
+ // sort the lists
+ Iterator perspectives = fLaunchShortcutsByPerspective.keySet().iterator();
+ while (perspectives.hasNext()) {
+ String id = (String)perspectives.next();
+ List list = (List)fLaunchShortcutsByPerspective.get(id);
+ Collections.sort(list, new ShortcutComparator());
+ }
+ }
+ return (List)fLaunchShortcutsByPerspective.get(perpsective);
+
}
/**
@@ -887,3 +926,13 @@ public class LaunchConfigurationManager implements ILaunchListener,
}
}
+
+class ShortcutComparator implements Comparator {
+ /**
+ * @see Comparator#compare(Object, Object)
+ */
+ public int compare(Object a, Object b) {
+ return ((LaunchShortcutExtension)a).getLabel().compareTo(((LaunchShortcutExtension)b).getLabel());
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabExtension.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabExtension.java
deleted file mode 100644
index 688d6dd89..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabExtension.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.eclipse.debug.internal.ui.launchConfigurations;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.internal.core.LaunchManager;
-
-
-/**
- * Proxy to a launch configuration tab element
- */
-public class LaunchConfigurationTabExtension {
-
- /**
- * The configuration element defining this tab.
- */
- private IConfigurationElement fConfig;
-
- /**
- * Constructs a launch configuration tab extension based
- * on the given configuration element
- *
- * @param element the configuration element defining the
- * attribtues of this launch configuration tab extension
- * @return a new launch configuration tab extension
- */
- public LaunchConfigurationTabExtension(IConfigurationElement element) {
- setConfigurationElement(element);
- }
-
- /**
- * Sets the configuration element that defines the attributes
- * for this launch configuration tab extension.
- *
- * @param element configuration element
- */
- private void setConfigurationElement(IConfigurationElement element) {
- fConfig = element;
- }
-
- /**
- * Returns the configuration element that defines the attributes
- * for this launch configuration tab extension.
- *
- * @param configuration element that defines the attributes
- * for this launch configuration tab extension
- */
- protected IConfigurationElement getConfigurationElement() {
- return fConfig;
- }
-
- /**
- * Returns whether this tab applies to all launch configurations
- * or to only a specific type of launch configuration
- *
- * @return whether this tab applies to all launch configurations
- * or to only a specific type of launch configuration
- */
- public boolean isGeneric() {
- return getType() == null;
- }
-
- /**
- * Returns the type of launch configuration this tab is
- * intended for, or <code>null</code> if this tab is generic
- *
- * @return the type of launch configuration this tab is
- * intended for, or <code>null</code> if this tab is generic
- */
- public ILaunchConfigurationType getType() {
- String id = getTypeIdentifier();
- if (id == null) {
- return null;
- }
- return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(id);
- }
-
- /**
- * Returns the identifier of the type of launch configuration this
- * tab is intended for, or <code>null</code> if this tab is generic
- *
- * @return the identifier of the type of launch configuration this
- * tab is intended for, or <code>null</code> if this tab is generic
- */
- protected String getTypeIdentifier() {
- return getConfigurationElement().getAttribute("type"); //$NON-NLS-1$
- }
-
- /**
- * Returns the name of this tab
- *
- * @return the name of this tab, or <code>null</code> if not
- * specified
- */
- public String getName() {
- return getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- }
-
- /**
- * Returns the mode of this tab, or <code>null</code>
- * if mode independent.
- *
- * @return the mode of this tab, or <code>null</code>
- * if mode independent
- */
- public String getMode() {
- return getConfigurationElement().getAttribute("mode"); //$NON-NLS-1$
- }
-
-}
-
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 8beda7618..4f0140ec1 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
@@ -78,3 +78,5 @@ LaunchConfigurationPresentationManager.No_tab_group_defined_for_launch_configura
PerspectiveManager.Error_1=Error
PerspectiveManager.Unable_to_switch_perpsectives_as_specified_by_launch__{0}_4=Unable to switch perspectives as specified by launch: {0}
PerspectiveManager.Unable_to_switch_to_perspective__{0}_2=Unable to switch to perspective: {0}
+LaunchShortcutExtension.Error_4=Error
+LaunchShortcutExtension.Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
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
new file mode 100644
index 000000000..c784822a4
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
@@ -0,0 +1,193 @@
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.internal.core.LaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorPart;
+
+
+/**
+ * Proxy to a launch shortcut extention
+ */
+public class LaunchShortcutExtension implements ILaunchShortcut {
+
+ private ImageDescriptor fImageDescriptor = null;
+ private List fPerspectives = null;
+ private ILaunchShortcut fDelegate = null;
+ private Set fModes = null;
+
+ /**
+ * The configuration element defining this tab.
+ */
+ private IConfigurationElement fConfig;
+
+ /**
+ * Constructs a launch configuration tab extension based
+ * on the given configuration element
+ *
+ * @param element the configuration element defining the
+ * attribtues of this launch configuration tab extension
+ * @return a new launch configuration tab extension
+ */
+ public LaunchShortcutExtension(IConfigurationElement element) {
+ setConfigurationElement(element);
+ }
+
+ /**
+ * Sets the configuration element that defines the attributes
+ * for this extension.
+ *
+ * @param element configuration element
+ */
+ private void setConfigurationElement(IConfigurationElement element) {
+ fConfig = element;
+ }
+
+ /**
+ * Returns the configuration element that defines the attributes
+ * for this extension.
+ *
+ * @param configuration element that defines the attributes
+ * for this launch configuration tab extension
+ */
+ protected IConfigurationElement getConfigurationElement() {
+ return fConfig;
+ }
+
+ /**
+ * Returns the label of this shortcut
+ *
+ * @return the label of this shortcut, or <code>null</code> if not
+ * specified
+ */
+ public String getLabel() {
+ return getConfigurationElement().getAttribute("label"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the path of the icon for this shortcut, or <code>null</code>
+ * if none.
+ *
+ * @return the path of the icon for this shortcut, or <code>null</code>
+ * if none
+ */
+ protected String getIconPath() {
+ return getConfigurationElement().getAttribute("icon"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the image for this shortcut, or <code>null</code> if none
+ *
+ * @return the image for this shortcut, or <code>null</code> if none
+ */
+ public ImageDescriptor getImageDescriptor() {
+ if (fImageDescriptor == null) {
+ URL iconURL = getConfigurationElement().getDeclaringExtension().getDeclaringPluginDescriptor().getInstallURL();
+ String iconPath = getIconPath();
+ ImageDescriptor imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ try {
+ iconURL = new URL(iconURL, iconPath);
+ fImageDescriptor = ImageDescriptor.createFromURL(iconURL);
+ } catch (MalformedURLException e) {
+ DebugUIPlugin.log(e);
+ }
+ }
+ return fImageDescriptor;
+ }
+
+ /**
+ * Returns the perspectives this shortcut is registered for.
+ *
+ * @return list of Strings representing perspective identifiers
+ */
+ public List getPerspectives() {
+ if (fPerspectives == null) {
+ IConfigurationElement[] perspectives = getConfigurationElement().getChildren("perspective"); //$NON-NLS-1$
+ fPerspectives = new ArrayList(perspectives.length);
+ for (int i = 0; i < perspectives.length; i++) {
+ fPerspectives.add(perspectives[i].getAttribute("id")); //$NON-NLS-1$
+ }
+ }
+ return fPerspectives;
+ }
+
+ /**
+ * Returns this shortcut's delegate, or <code>null</code> if none
+ *
+ * @return this shortcut's delegate, or <code>null</code> if none
+ */
+ protected ILaunchShortcut getDelegate() {
+ if (fDelegate == null) {
+ try {
+ fDelegate = (ILaunchShortcut)fConfig.createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException e) {
+ DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.getString("LaunchShortcutExtension.Error_4"), LaunchConfigurationsMessages.getString("LaunchShortcutExtension.Unable_to_use_launch_shortcut_5"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return fDelegate;
+ }
+
+ /**
+ * @see ILaunchShortcut#launch(IEditorPart, String)
+ */
+ public void launch(IEditorPart editor, String mode) {
+ ILaunchShortcut shortcut = getDelegate();
+ if (shortcut != null) {
+ shortcut.launch(editor, mode);
+ }
+ }
+
+ /**
+ * @see ILaunchShortcut#launch(ISelection, String)
+ */
+ public void launch(ISelection selection, String mode) {
+ ILaunchShortcut shortcut = getDelegate();
+ if (shortcut != null) {
+ shortcut.launch(selection, mode);
+ }
+ }
+
+ /**
+ * Returns the set of modes this shortcut supports.
+ *
+ * @return the set of modes this shortcut supports
+ */
+ public Set getModes() {
+ if (fModes == null) {
+ String modes= getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$
+ if (modes == null) {
+ return new HashSet(0);
+ }
+ StringTokenizer tokenizer= new StringTokenizer(modes, ","); //$NON-NLS-1$
+ fModes = new HashSet(tokenizer.countTokens());
+ while (tokenizer.hasMoreTokens()) {
+ fModes.add(tokenizer.nextToken().trim());
+ }
+ }
+ return fModes;
+ }
+
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
index 1d3d666ac..21ddf9595 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
@@ -623,10 +623,10 @@ public interface IDebugUIConstants {
public static final String EXTENSION_POINT_LAUNCH_CONFIGURATION_TAB_GROUPS= "launchConfigurationTabGroups"; //$NON-NLS-1$
/**
- * Launch configuration shortcuts extension point identifier
- * (value <code>"launchConfigurationShortcuts"</code>).
+ * Launch shortcuts extension point identifier
+ * (value <code>"launchShortcuts"</code>).
*
* @since 2.0
*/
- public static final String EXTENSION_POINT_LAUNCH_CONFIGURATION_SHORTCUTS= "launchConfigurationShortcuts"; //$NON-NLS-1$
+ public static final String EXTENSION_POINT_LAUNCH_SHORTCUTS= "launchShortcuts"; //$NON-NLS-1$
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java
new file mode 100644
index 000000000..355cdf751
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ILaunchShortcut.java
@@ -0,0 +1,91 @@
+package org.eclipse.debug.ui;
+
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+
+Contributors:
+ IBM Corporation - Initial implementation
+**********************************************************************/
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * A launch shortcut is capable of launching a selection
+ * or active editor in the workbench. The delegate is responsible for
+ * interpretting the selection or active editor (if it applies), and launching
+ * an application. This may require creating a new launch configuration
+ * with default values, or re-using an existing launch configuration.
+ * <p>
+ * A launch shortcut is defined as an extension
+ * of type <code>org.eclipse.debug.ui.launchShortcuts</code>.
+ * A shortcut specifies the perspectives in which is should be available
+ * from the "Run/Debug" cascade menus.
+ * </p>
+ * <p>
+ * A launch shortcut extension is defined in <code>plugin.xml</code>.
+ * Following is an example definition of a launch shortcut extension.
+ * <pre>
+ * &lt;extension point="org.eclipse.debug.ui.launchShortcuts"&gt;
+ * &lt;launchShortcut
+ * id="com.example.ExampleLaunchShortcut"
+ * class="com.example.ExampleLaunchShortcutClass"
+ * label="Example Label"
+ * icon="\icons\exampleshortcut.gif"
+ * modes="run, debug"&gt;
+ * &lt;perspective id="com.example.perspectiveId1"/&gt;
+ * &lt;perspective id="com.example.perspectiveId2"/&gt;
+ * &lt;/launchShortcut&gt;
+ * &lt;/extension&gt;
+ * </pre>
+ * The attributes are specified as follows:
+ * <ul>
+ * <li><code>id</code> specifies a unique identifier for this launch shortcut.</li>
+ * <li><code>class</code> specifies a fully qualified name of a Java class
+ * that implements <code>ILanuchShortcut</code>.</li>
+ * <li><code>label</code> specifies a label used to render this shortcut.</li>
+ * <li><code>icon</code> specifies a plug-in relative path to an icon used to
+ * render this shortcut.</li>
+ * <li><code>modes</code> specifies a comma separated list of modes this shortcut
+ * supports.</li>
+ * <li><code>perspective</code> one or more perspective entries enumerate the
+ * perspectives that this shortcut is avilable in, from the run/debug cascade
+ * menus.</li>
+ * </ul>
+ * </p>
+ * @since 2.0
+ */
+public interface ILaunchShortcut {
+
+ /**
+ * Locates a launchable entity in the given selection and launches
+ * an application in the specified mode. This launch configuration
+ * shortcut is responsible for progress reporting as well
+ * as error handling, in the event that a launchable entity cannot
+ * be found, or launching fails.
+ *
+ * @param selection workbench selection
+ * @param mode one of the launch modes defined by the
+ * launch manager
+ * @see org.eclipse.debug.core.ILaunchManager
+ */
+ public void launch(ISelection selection, String mode);
+
+ /**
+ * Locates a launchable entity in the given active editor, and launches
+ * an application in the specified mode. This launch configuration
+ * shortcut is responsible for progress reporting as well as error
+ * handling, in the event that a launchable entity cannot be found,
+ * or launching fails.
+ *
+ * @param editor the active editor in the workbench
+ * @param mode one of the launch modes defined by the launch
+ * manager
+ * @see org.eclipse.debug.core.ILaunchManager
+ */
+ public void launch(IEditorPart editor, String mode);
+}

Back to the top