Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java
new file mode 100644
index 000000000..cf01524ff
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.commands;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.model.IDisconnect;
+import org.eclipse.debug.internal.ui.commands.provisional.IDisconnectCommand;
+import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor;
+
+/**
+ * Default disconnect command for the standard debug model.
+ *
+ * @since 3.3
+ */
+public class DisconnectCommand extends DebugCommand implements IDisconnectCommand {
+
+ protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException {
+ return ((IDisconnect)target).canDisconnect();
+ }
+
+ protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException {
+ ((IDisconnect)target).disconnect();
+ }
+
+ protected Object getTarget(Object element) {
+ if (element instanceof IDisconnect) {
+ return element;
+ } else if (element instanceof IAdaptable) {
+ return ((IAdaptable) element).getAdapter(IDisconnect.class);
+ }
+ return null;
+ }
+}

Back to the top