diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index c5e3283ef3f..8adfb010396 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestartActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestartActionDelegate.java index b7706ac6457..387cd690038 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestartActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestartActionDelegate.java @@ -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; + } }