KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > context > TerminateAction


1 /*******************************************************************************
2  * Copyright (c) 2006 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.actions.context;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.debug.internal.ui.DebugPluginImages;
15 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16 import org.eclipse.debug.internal.ui.actions.ActionMessages;
17 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousTerminateAdapter;
18 import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor;
19 import org.eclipse.jface.resource.ImageDescriptor;
20
21 public class TerminateAction extends AbstractDebugContextAction {
22
23     protected void doAction(final Object JavaDoc element) {
24         if (element instanceof IAdaptable) {
25             IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class);
26             if (adapter != null)
27                 adapter.terminate(element, new ActionRequestMonitor());
28         }
29     }
30
31
32
33     protected void isEnabledFor(Object JavaDoc element, IBooleanRequestMonitor monitor) {
34         if (element instanceof IAdaptable) {
35             IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class);
36             if (adapter != null) {
37                 adapter.canTerminate(element, monitor);
38             } else {
39                 notSupported(monitor);
40             }
41         }
42     }
43
44     protected String JavaDoc getStatusMessage() {
45         return ActionMessages.TerminateActionDelegate_Exceptions_occurred_attempting_to_terminate__2;
46     }
47
48     protected String JavaDoc getErrorDialogMessage() {
49         return ActionMessages.TerminateActionDelegate_Terminate_failed__1;
50     }
51
52     public String JavaDoc getText() {
53         return ActionMessages.TerminateAction_0;
54     }
55
56     public String JavaDoc getHelpContextId() {
57         return "terminate_action_context"; //$NON-NLS-1$
58
}
59
60     public String JavaDoc getId() {
61         return "org.eclipse.debug.ui.debugview.toolbar.terminate"; //$NON-NLS-1$
62
}
63
64     public String JavaDoc getToolTipText() {
65         return ActionMessages.TerminateAction_3;
66     }
67
68     public ImageDescriptor getDisabledImageDescriptor() {
69         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE);
70     }
71
72     public ImageDescriptor getHoverImageDescriptor() {
73         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_TERMINATE);
74     }
75
76     public ImageDescriptor getImageDescriptor() {
77         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_TERMINATE);
78     }
79 }
80
Popular Tags