diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui')
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/plugin.xml | 33 | ||||
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestartActionDelegate.java | 64 |
2 files changed, 74 insertions, 23 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 166ced8fd9b..1853b0395c2 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -372,12 +372,14 @@ </propertyTester> </extension> - - <extension + <!-- Bug 289526 [debug view] Migrate the Restart feature to the new one, as supported by the platform + Don't contribute this action to context menu if selection isn't an IRestart. Debug platform + already contributes it. --> + <extension point="org.eclipse.ui.popupMenus"> <viewerContribution targetID="org.eclipse.debug.ui.DebugView" - id="org.eclipse.cdt.debug.ui.debugview.popupMenu"> + id="org.eclipse.cdt.debug.ui.debugview.popupMenu2"> <action label="%RestartAction.label" icon="icons/elcl16/restart.gif" @@ -387,7 +389,20 @@ enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate"> <selection class="org.eclipse.cdt.debug.core.model.IRestart"/> + </action> + <visibility> + <objectClass name="org.eclipse.cdt.debug.core.model.IRestart"/> + </visibility> + </viewerContribution> + </extension> + + + <extension + point="org.eclipse.ui.popupMenus"> + <viewerContribution + targetID="org.eclipse.debug.ui.DebugView" + id="org.eclipse.cdt.debug.ui.debugview.popupMenu"> <action state="false" style="toggle" @@ -878,18 +893,6 @@ targetID="org.eclipse.debug.ui.DebugView" id="org.eclipse.cdt.debug.ui.debugview.toolbar"> <action - id="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate" - toolbarPath="threadGroup" - class="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate" - disabledIcon="icons/dlcl16/restart.gif" - enablesFor="1" - icon="icons/elcl16/restart.gif" - helpContextId="restart_action_context" - label="%RestartAction.label" - tooltip="%RestartAction.tooltip"> - <selection class="org.eclipse.cdt.debug.core.model.IRestart"/> - </action> - <action state="false" style="toggle" id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate" 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 ) { |