Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Unified Diff: editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/DartRunAbstractAction.java

Issue 11420080: Several UI improvements to launching and the manage launches dialog. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/DartRunAbstractAction.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/DartRunAbstractAction.java (revision 14858)
+++ editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/launch/DartRunAbstractAction.java (working copy)
@@ -43,13 +43,30 @@
/**
* The abstract superclass of the run and debug actions.
*/
-public abstract class DartAbstractAction extends AbstractInstrumentedAction implements
+public abstract class DartRunAbstractAction extends AbstractInstrumentedAction implements
IWorkbenchWindowPulldownDelegate2, IMenuCreator {
+ private static class LaunchConfigComparator implements Comparator<ILaunchConfiguration> {
+ @Override
+ public int compare(ILaunchConfiguration o1, ILaunchConfiguration o2) {
+ DartLaunchConfigWrapper wrapper1 = new DartLaunchConfigWrapper(o1);
+ DartLaunchConfigWrapper wrapper2 = new DartLaunchConfigWrapper(o2);
+ long compare = wrapper2.getLastLaunchTime() - wrapper1.getLastLaunchTime();
+
+ if (compare < 0) {
+ return -1;
+ }
+
+ return compare == 0 ? 0 : 1;
+ }
+ }
+
+ private static final int MAX_MENU_LENGTH = 10;
+
private Menu menu;
protected IWorkbenchWindow window;
- public DartAbstractAction(IWorkbenchWindow window, String name, int flags) {
+ public DartRunAbstractAction(IWorkbenchWindow window, String name, int flags) {
super(name, flags);
this.window = window;
@@ -139,11 +156,17 @@
}
private void fillMenu(Menu menu) {
+ ILaunchConfiguration[] launches = LaunchUtils.getAllLaunchesArray();
- // Iterate through all the launch configurations and add them to the pulldown menu.
- for (final ILaunchConfiguration config : sort(LaunchUtils.getAllLaunchesArray())) {
+ Arrays.sort(launches, new LaunchConfigComparator());
+
+ int count = Math.min(launches.length, MAX_MENU_LENGTH);
+
+ for (int i = 0; i < count; i++) {
+ final ILaunchConfiguration config = launches[i];
+
Action launchAction = new Action(
- config.getName(),
+ LaunchUtils.getLongLaunchName(config),
DebugUITools.getDefaultImageDescriptor(config)) {
@Override
public void run() {
@@ -174,15 +197,4 @@
menu = inMenu;
}
- private ILaunchConfiguration[] sort(ILaunchConfiguration[] configs) {
- Arrays.sort(configs, new Comparator<ILaunchConfiguration>() {
- @Override
- public int compare(ILaunchConfiguration config1, ILaunchConfiguration config2) {
- return config1.getName().compareToIgnoreCase(config2.getName());
- }
- });
-
- return configs;
- }
-
}

Powered by Google App Engine
This is Rietveld 408576698