1 11 package org.eclipse.debug.internal.ui.actions.context; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.debug.core.DebugPlugin; 15 import org.eclipse.debug.core.ILaunch; 16 import org.eclipse.debug.core.model.IDebugElement; 17 import org.eclipse.debug.core.model.IProcess; 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.debug.internal.ui.actions.provisional.IAsynchronousTerminateAdapter; 22 import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; 23 import org.eclipse.jface.resource.ImageDescriptor; 24 25 public class TerminateAndRemoveAction extends AbstractDebugContextAction { 26 27 28 class TerminateAndRemoveMonitor extends ActionRequestMonitor { 29 private Object fElement; 30 TerminateAndRemoveMonitor(Object element) { 31 fElement = element; 32 } 33 public void done() { 34 if(getStatus() == null) { 35 ILaunch launch= null; 36 37 if (fElement instanceof ILaunch) { 38 launch= (ILaunch) fElement; 39 } else if (fElement instanceof IDebugElement) { 40 launch= ((IDebugElement) fElement).getLaunch(); 41 } else if (fElement instanceof IProcess) { 42 launch= ((IProcess) fElement).getLaunch(); 43 } 44 if (launch != null) 45 DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch); 46 } 47 super.done(); 48 } 49 50 } 51 protected void doAction(Object element) { 52 if (element instanceof IAdaptable) { 53 IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class); 54 if (adapter != null) 55 adapter.terminate(element, new TerminateAndRemoveMonitor(element)); 56 } 57 } 58 59 60 protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { 61 if (element instanceof IAdaptable) { 62 IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class); 63 if (adapter != null) { 64 adapter.canTerminate(element, monitor); 65 } else { 66 notSupported(monitor); 67 } 68 } 69 70 } 71 72 protected String getStatusMessage() { 73 return ActionMessages.TerminateAndRemoveActionDelegate_Exceptions_occurred_attempting_to_terminate_and_remove_2; 74 } 75 76 protected String getErrorDialogMessage() { 77 return ActionMessages.TerminateAndRemoveActionDelegate_Terminate_and_remove_failed_1; 78 } 79 80 public String getText() { 81 return ActionMessages.TerminateAndRemoveAction_0; 82 } 83 84 public String getHelpContextId() { 85 return "terminate_and_remove_action_context"; } 87 88 public String getId() { 89 return "org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove"; } 91 92 public String getToolTipText() { 93 return ActionMessages.TerminateAndRemoveAction_3; 94 } 95 96 public ImageDescriptor getDisabledImageDescriptor() { 97 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_AND_REMOVE); 98 } 99 100 public ImageDescriptor getHoverImageDescriptor() { 101 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); 102 } 103 104 public ImageDescriptor getImageDescriptor() { 105 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); 106 } 107 108 } 109 | Popular Tags |