1 11 package org.eclipse.debug.internal.ui.commands.actions; 12 13 import org.eclipse.debug.core.DebugPlugin; 14 import org.eclipse.debug.core.ILaunch; 15 import org.eclipse.debug.core.ILaunchManager; 16 import org.eclipse.debug.core.ILaunchesListener2; 17 import org.eclipse.debug.core.commands.ITerminateHandler; 18 import org.eclipse.debug.internal.ui.DebugPluginImages; 19 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 20 import org.eclipse.debug.internal.ui.actions.ActionMessages; 21 import org.eclipse.jface.resource.ImageDescriptor; 22 import org.eclipse.jface.viewers.ISelection; 23 import org.eclipse.jface.viewers.StructuredSelection; 24 import org.eclipse.ui.IWorkbenchPart; 25 26 31 public class TerminateAllAction extends DebugCommandAction implements ILaunchesListener2 { 32 33 protected ISelection getContext() { 34 return new StructuredSelection(getLaunchManager().getLaunches()); 35 } 36 37 public void contextActivated(ISelection context, IWorkbenchPart part) { 38 } 40 41 public void contextChanged(ISelection context, IWorkbenchPart part) { 42 } 44 45 public void dispose() { 46 getLaunchManager().removeLaunchListener(this); 47 super.dispose(); 48 } 49 50 public void init(IWorkbenchPart part) { 51 super.init(part); 52 ILaunchManager launchManager = getLaunchManager(); 53 launchManager.addLaunchListener(this); 54 setEnabled(launchManager.getLaunches().length > 0); 57 } 58 59 private ILaunchManager getLaunchManager() { 60 return DebugPlugin.getDefault().getLaunchManager(); 61 } 62 63 public String getHelpContextId() { 64 return "org.eclipse.debug.ui.terminate_all_action_context"; } 66 67 public String getId() { 68 return "org.eclipse.debug.ui.debugview.popupMenu.terminateAll"; } 70 71 public String getText() { 72 return ActionMessages.TerminateAllAction_2; 73 } 74 75 public String getToolTipText() { 76 return ActionMessages.TerminateAllAction_3; 77 } 78 79 public ImageDescriptor getDisabledImageDescriptor() { 80 return DebugPluginImages 81 .getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_ALL); 82 } 83 84 public ImageDescriptor getHoverImageDescriptor() { 85 return DebugPluginImages 86 .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL); 87 } 88 89 public ImageDescriptor getImageDescriptor() { 90 return DebugPluginImages 91 .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL); 92 } 93 94 protected Class getCommandType() { 95 return ITerminateHandler.class; 96 } 97 98 101 public void launchesTerminated(ILaunch[] launches) { 102 } 103 104 107 public void launchesAdded(ILaunch[] launches) { 108 setEnabled(true); 109 } 110 111 114 public void launchesChanged(ILaunch[] launches) { 115 } 116 117 120 public void launchesRemoved(ILaunch[] launches) { 121 setEnabled(getLaunchManager().getLaunches().length > 0); 122 } 123 } 124 | Popular Tags |