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

Unified Diff: editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/dialogs/CreateLaunchAction.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/internal/dialogs/CreateLaunchAction.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/dialogs/CreateLaunchAction.java (revision 15120)
+++ editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/dialogs/CreateLaunchAction.java (working copy)
@@ -21,74 +21,53 @@
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import java.util.Arrays;
-import java.util.Comparator;
-
/**
* An action used to create a new launch configuration.
*/
-public class CreateLaunchAction extends Action implements IWorkbenchWindowPulldownDelegate2,
- IMenuCreator {
- private Menu menu;
+class CreateLaunchAction extends Action implements IWorkbenchWindowActionDelegate {
+ //private Menu menu;
private ManageLaunchesDialog launchConfigurationDialog;
+ private ILaunchConfigurationType configType;
/**
* Create a new CreateLaunchAction.
*/
- public CreateLaunchAction(ManageLaunchesDialog launchConfigurationDialog) {
- super("Create new launch", IAction.AS_DROP_DOWN_MENU);
+ public CreateLaunchAction(ManageLaunchesDialog launchConfigurationDialog,
+ ILaunchConfigurationType configType) {
+ super("Create a new " + configType.getName());
this.launchConfigurationDialog = launchConfigurationDialog;
+ this.configType = configType;
- setImageDescriptor(DartDebugUIPlugin.getImageDescriptor("obj16/run_create.png"));
-
- setMenuCreator(this);
+ setImageDescriptor(new DecorationOverlayIcon(
+ DartDebugUIPlugin.getImage(DebugUITools.getDefaultImageDescriptor(configType)),
+ DartDebugUIPlugin.getImageDescriptor("ovr16/new.png"),
+ IDecoration.TOP_RIGHT));
}
@Override
public void dispose() {
- setMenu(null);
- }
- @Override
- public Menu getMenu(Control parent) {
- setMenu(new Menu(parent));
- fillMenu(menu);
- return menu;
}
@Override
- public Menu getMenu(Menu parent) {
- setMenu(new Menu(parent));
- fillMenu(menu);
- return menu;
- }
-
- @Override
public void init(IWorkbenchWindow window) {
}
@Override
public void run() {
-
+ create(configType);
}
@Override
@@ -98,28 +77,7 @@
@Override
public void runWithEvent(Event event) {
- if (((event.stateMask & SWT.MOD1) > 0) && (event.type != SWT.KeyDown)) {
- // The menu was opened.
- } else {
- // If the user clicked on the button, open the menu.
- Widget widget = event.widget;
-
- if (widget instanceof ToolItem) {
- ToolItem toolItem = (ToolItem) widget;
- Listener[] listeners = toolItem.getListeners(SWT.Selection);
- if (listeners.length > 0) {
- Listener listener = listeners[0]; // should be only one listener
- // send an event to the widget to open the menu
- // see CommandContributionItem.openDropDownMenu(Event)
- Event e = new Event();
- e.type = SWT.Selection;
- e.widget = widget;
- e.detail = 4; // dropdown detail
- e.y = toolItem.getBounds().height; // position menu
- listener.handleEvent(e);
- }
- }
- }
+ run();
}
@Override
@@ -133,6 +91,8 @@
null,
DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName("New launch"));
+ // TODO(devoncarew): init this launch config with a starting resource and name
+
wc.doSave();
launchConfigurationDialog.selectLaunchConfiguration(wc.getName());
@@ -145,41 +105,4 @@
}
}
- private void fillMenu(Menu menu) {
- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
-
- // Iterate through all the launch configuration types and add them to the pulldown menu.
- for (final ILaunchConfigurationType configType : sort(manager.getLaunchConfigurationTypes())) {
- Action launchAction = new Action(
- configType.getName(),
- DebugUITools.getDefaultImageDescriptor(configType)) {
- @Override
- public void run() {
- create(configType);
- }
- };
-
- new ActionContributionItem(launchAction).fill(menu, -1);
- }
- }
-
- private void setMenu(Menu inMenu) {
- if (menu != null) {
- menu.dispose();
- }
-
- menu = inMenu;
- }
-
- private ILaunchConfigurationType[] sort(ILaunchConfigurationType[] configs) {
- Arrays.sort(configs, new Comparator<ILaunchConfigurationType>() {
- @Override
- public int compare(ILaunchConfigurationType config1, ILaunchConfigurationType config2) {
- return config1.getName().compareToIgnoreCase(config2.getName());
- }
- });
-
- return configs;
- }
-
}

Powered by Google App Engine
This is Rietveld 408576698