KickJava   Java API By Example, From Geeks To Geeks.

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


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.IAsynchronousSuspendResumeAdapter;
18 import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor;
19 import org.eclipse.jface.resource.ImageDescriptor;
20
21 public class SuspendAction extends AbstractDebugContextAction {
22
23     /*
24      * (non-Javadoc)
25      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#doAction(java.lang.Object)
26      */

27     protected void doAction(Object JavaDoc element) {
28         if (element instanceof IAdaptable) {
29             IAdaptable adaptable = (IAdaptable) element;
30             IAsynchronousSuspendResumeAdapter suspendResumer = (IAsynchronousSuspendResumeAdapter) adaptable.getAdapter(IAsynchronousSuspendResumeAdapter.class);
31             if (suspendResumer != null)
32                 suspendResumer.suspend(element, new ActionRequestMonitor());
33         }
34     }
35
36     /*
37      * (non-Javadoc)
38      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#isEnabledFor(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor)
39      */

40     protected void isEnabledFor(Object JavaDoc element, IBooleanRequestMonitor monitor) {
41         if (element instanceof IAdaptable) {
42             IAdaptable adaptable = (IAdaptable) element;
43             IAsynchronousSuspendResumeAdapter suspendResumer = (IAsynchronousSuspendResumeAdapter) adaptable.getAdapter(IAsynchronousSuspendResumeAdapter.class);
44             if (suspendResumer != null) {
45                 suspendResumer.canSuspend(element, monitor);
46             } else {
47                 notSupported(monitor);
48             }
49         }
50         
51     }
52
53
54     protected String JavaDoc getStatusMessage() {
55         return ActionMessages.SuspendActionDelegate_Exceptions_occurred_attempting_to_suspend__2;
56     }
57
58     protected String JavaDoc getErrorDialogMessage() {
59         return ActionMessages.SuspendActionDelegate_Suspend_failed_1;
60     }
61
62     public String JavaDoc getText() {
63         return ActionMessages.SuspendAction_0;
64     }
65
66     public String JavaDoc getHelpContextId() {
67         return "suspend_action_context"; //$NON-NLS-1$
68
}
69
70     public String JavaDoc getId() {
71         return "org.eclipse.debug.ui.debugview.toolbar.suspend"; //$NON-NLS-1$
72
}
73
74     public String JavaDoc getToolTipText() {
75         return ActionMessages.SuspendAction_3;
76     }
77
78     public ImageDescriptor getDisabledImageDescriptor() {
79         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_SUSPEND);
80     }
81
82     public ImageDescriptor getHoverImageDescriptor() {
83         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_SUSPEND);
84     }
85
86     public ImageDescriptor getImageDescriptor() {
87         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_SUSPEND);
88     }
89 }
90
Popular Tags