diff options
author | Pawel Piech | 2010-04-29 22:45:45 +0000 |
---|---|---|
committer | Pawel Piech | 2010-04-29 22:45:45 +0000 |
commit | 718f11adefc98d386f0f312dc8883089dbb52308 (patch) | |
tree | 2c772226477aa7dce5c2c4846202d91f7a58929c /debug/org.eclipse.cdt.debug.ui/src/org/eclipse | |
parent | 9acd76c5b0af0f18e182db219ba58c3ec01ddd51 (diff) | |
download | org.eclipse.cdt-718f11adefc98d386f0f312dc8883089dbb52308.tar.gz org.eclipse.cdt-718f11adefc98d386f0f312dc8883089dbb52308.tar.xz org.eclipse.cdt-718f11adefc98d386f0f312dc8883089dbb52308.zip |
Bug 289526 - [debug view] Migrate the Restart feature to the new one, as supported by the platform
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org/eclipse')
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestartActionDelegate.java | 64 |
1 files changed, 56 insertions, 8 deletions
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 54576b726e0..34dae0eb789 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 @@ -1,43 +1,84 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. + * Copyright (c) 2004, 2010 QNX Software Systems 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: - * QNX Software Systems - Initial API and implementation + * QNX Software Systems - Initial API and implementation + * Navid Mehregani (TI) - Bug 289526 - Migrate the Restart feature to the new one, as supported by the platform + * Wind River Systems - Bug 289526 - Additional fixes *******************************************************************************/ 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.commands.IRestartHandler; import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.internal.ui.commands.actions.RestartCommandAction; +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchWindow; /** * The delegate of the "Restart" action. */ public class RestartActionDelegate extends AbstractListenerActionDelegate { + private RestartCommandAction fRestartCommandAction; + + @Override + public void init(IAction action) { + setAction(action); + } + /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(java.lang.Object) */ protected void doAction( Object element ) throws DebugException { - IRestart restartTarget = getRestartTarget( element ); - if ( restartTarget != null ) { - restartTarget.restart(); + IRestartHandler asynchronousRestartHandler = getAsynchronousRestartHandler( element ); + if (asynchronousRestartHandler!=null && fRestartCommandAction!=null ) { + fRestartCommandAction.run(); + } else { + IRestart restartTarget = getRestartTarget( element ); + if ( restartTarget != null ) { + restartTarget.restart(); + } + } } + @Override + public void init(IViewPart view) { + super.init(view); + fRestartCommandAction = new RestartCommandAction(); + fRestartCommandAction.setActionProxy(getAction()); + fRestartCommandAction.init(getView()); + } + + @Override + public void init(IWorkbenchWindow window) { + super.init(window); + fRestartCommandAction = new RestartCommandAction(); + fRestartCommandAction.setActionProxy(getAction()); + fRestartCommandAction.init(getWindow()); + } + /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#isEnabledFor(java.lang.Object) */ protected boolean isEnabledFor( Object element ) { - IRestart restartTarget = getRestartTarget( element ); - if ( restartTarget != null ) { - return checkCapability( restartTarget ); + IRestartHandler asynchronousRestartHandler = getAsynchronousRestartHandler( element ); + if (asynchronousRestartHandler!=null && fRestartCommandAction!=null) { + return fRestartCommandAction.isEnabled(); + } else { + IRestart restartTarget = getRestartTarget( element ); + if ( restartTarget != null ) { + return checkCapability( restartTarget ); + } } return false; } @@ -79,6 +120,13 @@ public class RestartActionDelegate extends AbstractListenerActionDelegate { return (IRestart)((IAdaptable)element).getAdapter( IRestart.class ); return getDefaultRestartTarget( element ); } + + protected IRestartHandler getAsynchronousRestartHandler( Object element ) { + if ( element instanceof IAdaptable ) + return (IRestartHandler)((IAdaptable)element).getAdapter( IRestartHandler.class ); + + return null; + } private IRestart getDefaultRestartTarget( Object element ) { if ( element instanceof IDebugElement ) { |