1 11 package org.eclipse.debug.internal.ui.commands.actions; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.debug.core.DebugPlugin; 15 import org.eclipse.debug.core.ILaunch; 16 import org.eclipse.debug.core.IRequest; 17 import org.eclipse.debug.core.commands.ITerminateHandler; 18 import org.eclipse.debug.core.model.IDebugElement; 19 import org.eclipse.debug.core.model.IProcess; 20 import org.eclipse.debug.internal.ui.DebugPluginImages; 21 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 22 import org.eclipse.debug.internal.ui.actions.ActionMessages; 23 import org.eclipse.jface.resource.ImageDescriptor; 24 25 30 public class TerminateAndRemoveAction extends DebugCommandAction { 31 32 33 class TerminateAndRemoveParticipant implements ICommandParticipant { 34 private Object [] fElements; 35 36 TerminateAndRemoveParticipant(Object [] elements) { 37 fElements = elements; 38 } 39 40 43 public void requestDone(IRequest request) { 44 IStatus status = request.getStatus(); 45 if(status == null || status.isOK()) { 46 for (int i = 0; i < fElements.length; i++) { 47 Object element = fElements[i]; 48 ILaunch launch= null; 49 if (element instanceof ILaunch) { 50 launch= (ILaunch) element; 51 } else if (element instanceof IDebugElement) { 52 launch= ((IDebugElement) element).getLaunch(); 53 } else if (element instanceof IProcess) { 54 launch= ((IProcess) element).getLaunch(); 55 } 56 if (launch != null) 57 DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch); 58 } 59 } 60 } 61 62 } 63 64 public String getText() { 65 return ActionMessages.TerminateAndRemoveAction_0; 66 } 67 68 public String getHelpContextId() { 69 return "org.eclipse.debug.ui.terminate_and_remove_action_context"; } 71 72 public String getId() { 73 return "org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove"; } 75 76 public String getToolTipText() { 77 return ActionMessages.TerminateAndRemoveAction_3; 78 } 79 80 public ImageDescriptor getDisabledImageDescriptor() { 81 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_AND_REMOVE); 82 } 83 84 public ImageDescriptor getHoverImageDescriptor() { 85 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); 86 } 87 88 public ImageDescriptor getImageDescriptor() { 89 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); 90 } 91 92 protected Class getCommandType() { 93 return ITerminateHandler.class; 94 } 95 96 protected ICommandParticipant getCommandParticipant(Object [] targets) { 97 return new TerminateAndRemoveParticipant(targets); 98 } 99 100 101 } 102 | Popular Tags |