From 4fe8f08266ae4b63ac800d5af4c1c274fba9e8d4 Mon Sep 17 00:00:00 2001 From: Darin Wright Date: Mon, 16 Oct 2006 18:47:27 +0000 Subject: Bug 160932 API for debug context and debug commands --- .../internal/ui/commands/DisconnectCommand.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java') 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; + } +} -- cgit v1.2.3