KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > commands > actions > TerminateAndRemoveAction


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
26  * Terminate and remove action.
27  *
28  * @since 3.3
29  */

30 public class TerminateAndRemoveAction extends DebugCommandAction {
31
32     
33     class TerminateAndRemoveParticipant implements ICommandParticipant {
34         private Object JavaDoc[] fElements;
35         
36         TerminateAndRemoveParticipant(Object JavaDoc[] elements) {
37             fElements = elements;
38         }
39         
40         /* (non-Javadoc)
41          * @see org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant#requestDone(org.eclipse.debug.core.commands.IRequest)
42          */

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 JavaDoc 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 JavaDoc getText() {
65         return ActionMessages.TerminateAndRemoveAction_0;
66     }
67
68     public String JavaDoc getHelpContextId() {
69         return "org.eclipse.debug.ui.terminate_and_remove_action_context"; //$NON-NLS-1$
70
}
71
72     public String JavaDoc getId() {
73         return "org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove"; //$NON-NLS-1$
74
}
75
76     public String JavaDoc 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 JavaDoc getCommandType() {
93         return ITerminateHandler.class;
94     }
95
96     protected ICommandParticipant getCommandParticipant(Object JavaDoc[] targets) {
97         return new TerminateAndRemoveParticipant(targets);
98     }
99
100     
101 }
102
Popular Tags