KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

41     protected void isEnabledFor(Object JavaDoc element, IBooleanRequestMonitor monitor) {
42         if (element instanceof IAdaptable) {
43             IAdaptable adaptable = (IAdaptable) element;
44             IAsynchronousDisconnectAdapter disconnect = (IAsynchronousDisconnectAdapter) adaptable.getAdapter(IAsynchronousDisconnectAdapter.class);
45             if (disconnect != null) {
46                 disconnect.canDisconnect(element, monitor);
47             } else {
48                 notSupported(monitor);
49             }
50         }
51     }
52
53     /*
54      * (non-Javadoc)
55      *
56      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getStatusMessage()
57      */

58     protected String JavaDoc getStatusMessage() {
59         return ActionMessages.DisconnectActionDelegate_Exceptions_occurred_attempting_to_disconnect__2;
60     }
61
62     /*
63      * (non-Javadoc)
64      *
65      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getErrorDialogMessage()
66      */

67     protected String JavaDoc getErrorDialogMessage() {
68         return ActionMessages.DisconnectActionDelegate_Disconnect_failed_1;
69     }
70
71     /*
72      * (non-Javadoc)
73      *
74      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getText()
75      */

76     public String JavaDoc getText() {
77         return ActionMessages.DisconnectAction_0;
78     }
79
80     /*
81      * (non-Javadoc)
82      *
83      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHelpContextId()
84      */

85     public String JavaDoc getHelpContextId() {
86         return "disconnect_action_context"; //$NON-NLS-1$
87
}
88
89     /*
90      * (non-Javadoc)
91      *
92      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getId()
93      */

94     public String JavaDoc getId() {
95         return "org.eclipse.debug.ui.debugview.toolbar.disconnect"; //$NON-NLS-1$
96
}
97
98     /*
99      * (non-Javadoc)
100      *
101      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getToolTipText()
102      */

103     public String JavaDoc getToolTipText() {
104         return ActionMessages.DisconnectAction_3;
105     }
106
107     /*
108      * (non-Javadoc)
109      *
110      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getDisabledImageDescriptor()
111      */

112     public ImageDescriptor getDisabledImageDescriptor() {
113         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DISCONNECT);
114     }
115
116     /*
117      * (non-Javadoc)
118      *
119      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHoverImageDescriptor()
120      */

121     public ImageDescriptor getHoverImageDescriptor() {
122         return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT);
123     }
124
125     /*
126      * (non-Javadoc)
127      *
128      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getImageDescriptor()
129      */

130     public ImageDescriptor getImageDescriptor() {
131         return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT);
132     }
133 }
134
Popular Tags