1 /*******************************************************************************2 * Copyright (c) 2006, 2007 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 *8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/11 package org.eclipse.debug.internal.core.commands;12 13 import org.eclipse.core.runtime.CoreException;14 import org.eclipse.core.runtime.IAdaptable;15 import org.eclipse.debug.core.commands.ITerminateHandler;16 import org.eclipse.debug.core.model.ITerminate;17 18 /**19 * Default terminate command for the standard debug model.20 * 21 * @since 3.322 */23 public class TerminateCommand extends ForEachCommand implements ITerminateHandler {24 25 protected Object getTarget(Object element) {26 if (element instanceof ITerminate) {27 return element;28 } else if (element instanceof IAdaptable) {29 return ((IAdaptable) element).getAdapter(ITerminate.class);30 }31 return null;32 }33 34 protected void execute(Object target) throws CoreException {35 ((ITerminate)target).terminate();36 }37 38 protected boolean isExecutable(Object target) {39 return ((ITerminate)target).canTerminate();40 }41 }42