Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/schema/launchShortcuts.exsd7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java10
3 files changed, 48 insertions, 9 deletions
diff --git a/org.eclipse.debug.ui/schema/launchShortcuts.exsd b/org.eclipse.debug.ui/schema/launchShortcuts.exsd
index 15d6eaf76..5d5f55472 100644
--- a/org.eclipse.debug.ui/schema/launchShortcuts.exsd
+++ b/org.eclipse.debug.ui/schema/launchShortcuts.exsd
@@ -110,6 +110,13 @@ appears in the run and/or debug cascade menus to launch the workbench selection
</documentation>
</annotation>
</attribute>
+ <attribute name="path" type="string">
+ <annotation>
+ <documentation>
+ an optional menu path used to group launch shortcuts in menus. Launch shortcuts are grouped alphabetically based on the &lt;code&gt;path&lt;/code&gt; attribute, and then sorted alphabetically within groups based on the &lt;code&gt;label&lt;/code&gt; attribute. When unspecified, a shortcut appears in the last group. This attribute was added in the 3.0.1 release.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
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 8e359cd25..7ba3d74fb 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
@@ -737,21 +737,43 @@ class ShortcutComparator implements Comparator {
* @see Comparator#compare(Object, Object)
*/
public int compare(Object a, Object b) {
- String labelA = ((LaunchShortcutExtension)a).getLabel();
- String labelB = ((LaunchShortcutExtension)b).getLabel();
+ LaunchShortcutExtension shorcutA = (LaunchShortcutExtension)a;
+ String labelA = shorcutA.getLabel();
+ String pathA = shorcutA.getMenuPath();
+ LaunchShortcutExtension shortcutB = (LaunchShortcutExtension)b;
+ String labelB = shortcutB.getLabel();
+ String pathB = shortcutB.getMenuPath();
- // null labels sort last (i.e. highest)
- if (labelA == labelB) {
- return 0;
+ // group by path, then sort by label
+ // a null path sorts last (i.e. highest)
+ if (nullOrEqual(pathA, pathB)) {
+ // null labels sort last (i.e. highest)
+ if (labelA == labelB) {
+ return 0;
+ }
+ if (labelA == null) {
+ return 1;
+ }
+ if (labelB == null) {
+ return -1;
+ }
+ return labelA.compareToIgnoreCase(labelB);
}
- if (labelA == null) {
+ // compare paths
+ if (pathA == null) {
return 1;
}
- if (labelB == null) {
+ if (pathB == null) {
return -1;
}
-
- return labelA.compareToIgnoreCase(labelB);
+ return pathA.compareToIgnoreCase(pathB);
+ }
+
+ private boolean nullOrEqual(String a, String b) {
+ if (a == null) {
+ return b == null;
+ }
+ return a.equals(b);
}
}
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 483bdedea..caa975fe1 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
@@ -358,6 +358,16 @@ public class LaunchShortcutExtension implements ILaunchShortcut, IPluginContribu
return fModes;
}
+ /**
+ * Returns the menu path attribute this shortcut, or <code>null</code> if none
+ *
+ * @return the menu path attribute this shortcut, or <code>null</code> if none
+ * @since 3.0.1
+ */
+ public String getMenuPath() {
+ return getConfigurationElement().getAttribute("path"); //$NON-NLS-1$
+ }
+
/*
* Only for debugging
* @see java.lang.Object#toString()

Back to the top