blob: 6156b207b775e0ab22341fbb2d6d71c42548b6a2 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2005 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.actions;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.ITerminate;
public class TerminateActionDelegate extends AbstractListenerActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
*/
protected void doAction(Object element) throws DebugException {
if (element instanceof ITerminate) {
((ITerminate)element).terminate();
}
}
/**
* @see AbstractDebugActionDelegate#isRunInBackground()
*/
protected boolean isRunInBackground() {
return true;
}
/**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
return element instanceof ITerminate && ((ITerminate)element).canTerminate();
}
/**
* @see AbstractDebugActionDelegate#getStatusMessage()
*/
protected String getStatusMessage() {
return ActionMessages.TerminateActionDelegate_Exceptions_occurred_attempting_to_terminate__2; //$NON-NLS-1$
}
/**
* @see AbstractDebugActionDelegate#getErrorDialogMessage()
*/
protected String getErrorDialogMessage() {
return ActionMessages.TerminateActionDelegate_Terminate_failed__1; //$NON-NLS-1$
}
/**
* @see AbstractDebugActionDelegate#getErrorDialogTitle()
*/
protected String getErrorDialogTitle() {
return ActionMessages.TerminateActionDelegate_Terminate_3; //$NON-NLS-1$
}
/**
* @see ListenerActionDelegate#doHandleDebugEvent(DebugEvent)
*/
protected void doHandleDebugEvent(DebugEvent event) {
if (event.getKind() == DebugEvent.TERMINATE || event.getKind() == DebugEvent.CREATE) {
update(getAction(), getSelection());
}
}
}