1 11 package org.eclipse.debug.internal.ui.actions; 12 13 14 import org.eclipse.debug.core.ILaunchConfiguration; 15 import org.eclipse.debug.internal.ui.DebugUIPlugin; 16 import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; 17 import org.eclipse.debug.ui.DebugUITools; 18 import org.eclipse.jface.action.IAction; 19 import org.eclipse.jface.viewers.ISelection; 20 import org.eclipse.jface.viewers.StructuredSelection; 21 import org.eclipse.swt.widgets.Event; 22 import org.eclipse.ui.IActionDelegate2; 23 import org.eclipse.ui.IWorkbenchWindow; 24 25 28 public abstract class ExecutionAction implements IActionDelegate2 { 29 30 private String fLaunchGroupIdentifier; 31 32 public ExecutionAction(String launchGroupIdentifier) { 33 fLaunchGroupIdentifier = launchGroupIdentifier; 34 } 35 36 39 public void runWithEvent(IAction action, Event event) { 40 run(action); 41 } 42 43 46 private void openLaunchConfigurationDialog() { 47 IWorkbenchWindow dwindow= DebugUIPlugin.getActiveWorkbenchWindow(); 48 if (dwindow == null) { 49 return; 50 } 51 DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), fLaunchGroupIdentifier); 52 } 53 54 protected LaunchConfigurationManager getLaunchConfigurationManager() { 55 return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); 56 } 57 58 61 protected abstract String getMode(); 62 63 66 public void dispose() { 67 } 68 69 72 public void init(IAction action) { 73 } 74 75 78 public void run(IAction action) { 79 ILaunchConfiguration configuration = getLaunchConfigurationManager().getLastLaunch(fLaunchGroupIdentifier); 80 if (configuration == null) { 81 openLaunchConfigurationDialog(); 82 } else { 83 DebugUITools.launch(configuration, getMode()); 84 } 85 } 86 87 90 public void selectionChanged(IAction action, ISelection selection) { 91 } 92 93 } 94 | Popular Tags |