1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +02:00

Allow clients to contribute IRestart adapters.

This commit is contained in:
Mikhail Khodjaiants 2006-03-29 19:35:01 +00:00
parent b3b077cfc3
commit 91f17114ea
2 changed files with 38 additions and 25 deletions

View file

@ -1,3 +1,7 @@
2006-03-29 Mikhail Khodjaiants
Allow clients to contribute IRestart adapters.
* RestartActionDelegate.java
2006-03-15 Mikhail Khodjaiants
An ICDebuggerPage adapter is added to retain compatibility with old extensions.
+ CDebuggerPageAdapter.java

View file

@ -11,32 +11,33 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.IRestart;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* The delegate of the "Restart" action.
*/
public class RestartActionDelegate extends AbstractListenerActionDelegate {
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(Object)
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(java.lang.Object)
*/
protected void doAction( Object element ) throws DebugException {
if ( element instanceof IRestart ) {
((IRestart)element).restart();
IRestart restartTarget = getRestartTarget( element );
if ( restartTarget != null ) {
restartTarget.restart();
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#isEnabledFor(Object)
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#isEnabledFor(java.lang.Object)
*/
protected boolean isEnabledFor( Object element ) {
if ( element instanceof IRestart ) {
return checkCapability( (IRestart)element );
IRestart restartTarget = getRestartTarget( element );
if ( restartTarget != null ) {
return checkCapability( restartTarget );
}
return false;
}
@ -45,29 +46,22 @@ public class RestartActionDelegate extends AbstractListenerActionDelegate {
return element.canRestart();
}
/**
* @see AbstractDebugActionDelegate#enableForMultiSelection()
*/
protected boolean enableForMultiSelection() {
return false;
}
/**
* @see AbstractDebugActionDelegate#getStatusMessage()
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#getStatusMessage()
*/
protected String getStatusMessage() {
return ActionMessages.getString( "RestartActionDelegate.0" ); //$NON-NLS-1$
}
/**
* @see AbstractDebugActionDelegate#getErrorDialogMessage()
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#getErrorDialogMessage()
*/
protected String getErrorDialogMessage() {
return ActionMessages.getString( "RestartActionDelegate.1" ); //$NON-NLS-1$
}
/**
* @see AbstractDebugActionDelegate#getErrorDialogTitle()
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#getErrorDialogTitle()
*/
protected String getErrorDialogTitle() {
return ActionMessages.getString( "RestartActionDelegate.2" ); //$NON-NLS-1$
@ -79,4 +73,19 @@ public class RestartActionDelegate extends AbstractListenerActionDelegate {
protected boolean isRunInBackground() {
return true;
}
protected IRestart getRestartTarget( Object element ) {
if ( element instanceof IAdaptable )
return (IRestart)((IAdaptable)element).getAdapter( IRestart.class );
return getDefaultRestartTarget( element );
}
private IRestart getDefaultRestartTarget( Object element ) {
if ( element instanceof IDebugElement ) {
IDebugTarget target = ((IDebugElement)element).getDebugTarget();
if ( target instanceof IRestart )
return (IRestart)target;
}
return null;
}
}