KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > DisconnectActionDelegate


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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;
12
13
14 import org.eclipse.debug.core.DebugEvent;
15 import org.eclipse.debug.core.DebugException;
16 import org.eclipse.debug.core.model.IDebugTarget;
17 import org.eclipse.debug.core.model.IDisconnect;
18
19 public class DisconnectActionDelegate extends AbstractListenerActionDelegate {
20
21     /**
22      * @see AbstractDebugActionDelegate#doAction(Object)
23      */

24     protected void doAction(Object JavaDoc element) throws DebugException {
25         if (element instanceof IDisconnect) {
26              ((IDisconnect) element).disconnect();
27         }
28     }
29     
30     /**
31      * @see AbstractDebugActionDelegate#isRunInBackground()
32      */

33     protected boolean isRunInBackground() {
34         return true;
35     }
36
37     /**
38      * @see AbstractDebugActionDelegate#isEnabledFor(Object)
39      */

40     protected boolean isEnabledFor(Object JavaDoc element) {
41         return element instanceof IDisconnect && ((IDisconnect) element).canDisconnect();
42     }
43         
44     /**
45      * @see AbstractDebugActionDelegate#getStatusMessage()
46      */

47     protected String JavaDoc getStatusMessage() {
48         return ActionMessages.DisconnectActionDelegate_Exceptions_occurred_attempting_to_disconnect__2; //$NON-NLS-1$
49
}
50
51     /**
52      * @see AbstractDebugActionDelegate#getErrorDialogMessage()
53      */

54     protected String JavaDoc getErrorDialogMessage() {
55         return ActionMessages.DisconnectActionDelegate_Disconnect_failed_1; //$NON-NLS-1$
56
}
57     
58     /**
59      * @see ListenerActionDelegate#doHandleDebugEvent(DebugEvent)
60      */

61     protected void doHandleDebugEvent(DebugEvent event) {
62         if (event.getKind() == DebugEvent.TERMINATE && event.getSource() instanceof IDebugTarget) {
63             update(getAction(), getSelection());
64         }
65     }
66 }
67
Popular Tags