diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index b836bddb2f0..15af99f8a9d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -18,7 +18,9 @@ import java.util.HashSet; import java.util.List; import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager; +import org.eclipse.cdt.debug.core.command.CCommandAdapterFactory; import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService; +import org.eclipse.cdt.debug.core.model.IRestart; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.internal.core.DebugConfiguration; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; @@ -31,6 +33,7 @@ import org.eclipse.cdt.debug.internal.core.sourcelookup.SourceUtils; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IStatus; @@ -331,6 +334,7 @@ public class CDebugCorePlugin extends Plugin { public void start( BundleContext context ) throws Exception { super.start( context ); initializeCommonSourceLookupDirector(); + createCommandAdapterFactory(); createBreakpointListenersList(); createDisassemblyContextService(); setSessionManager( new SessionManager() ); @@ -349,6 +353,12 @@ public class CDebugCorePlugin extends Plugin { super.stop( context ); } + private void createCommandAdapterFactory() { + IAdapterManager manager= Platform.getAdapterManager(); + CCommandAdapterFactory actionFactory = new CCommandAdapterFactory(); + manager.registerAdapters(actionFactory, IRestart.class); + } + private void initializeCommonSourceLookupDirector() { if ( fCommonSourceLookupDirector == null ) { fCommonSourceLookupDirector = new CommonSourceLookupDirector(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java new file mode 100755 index 00000000000..5c0f666f6bd --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2006, 2010 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 + * Wind River Systems - copied to use in CDT + *******************************************************************************/ +package org.eclipse.cdt.debug.core.command; + +import org.eclipse.cdt.debug.core.model.IRestart; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.debug.core.commands.IRestartHandler; + +/** + * Adapter factory for debug commands. + * + * @see org.eclipse.debug.core.command + * + * @since 7.0 + * + */ +public class CCommandAdapterFactory implements IAdapterFactory { + private static IRestartHandler fgRestartCommand = new RestartCommand(); + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (IRestartHandler.class.equals(adapterType)) { + if (adaptableObject instanceof IRestart) { + return fgRestartCommand; + } + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + public Class[] getAdapterList() { + return new Class[] { + IRestartHandler.class + }; + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java new file mode 100755 index 00000000000..c2f3abfe277 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 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 + * Wind River Systems - copied to use in CDT + *******************************************************************************/ +package org.eclipse.cdt.debug.core.command; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.IRequest; +import org.eclipse.debug.core.commands.AbstractDebugCommand; +import org.eclipse.debug.core.commands.IEnabledStateRequest; + +/** + * A command that operates on each element individually. + *

+ * Note: copied from org.eclipse.debug.core.command.ForEachCommand. + *

+ * @since 7.0 + */ +public abstract class CForEachCommand extends AbstractDebugCommand { + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.core.commands.DebugCommand#doExecute(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.debug.core.IRequest) + */ + protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { + for (int i = 0; i < targets.length; i++) { + execute(targets[i]); + monitor.worked(1); + } + } + + protected abstract void execute(Object target) throws CoreException; + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.core.commands.DebugCommand#isExecutable(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.debug.core.commands.IEnabledStateRequest) + */ + protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException { + for (int i = 0; i < targets.length; i++) { + if (!isExecutable(targets[i])) { + return false; + } + monitor.worked(1); + } + return true; + } + + protected abstract boolean isExecutable(Object target); + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java new file mode 100755 index 00000000000..feef3bafd2d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2006, 2010 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 + * Wind River Systems - adopted to use for restart command + *******************************************************************************/ +package org.eclipse.cdt.debug.core.command; + +import org.eclipse.cdt.debug.core.model.IRestart; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.commands.IDebugCommandRequest; +import org.eclipse.debug.core.commands.IRestartHandler; + +/** + * Default restart command for CDI + * + * @since 7.0 + */ +public class RestartCommand extends CForEachCommand implements IRestartHandler { + + protected Object getTarget(Object element) { + return getAdapter(element, IRestart.class); + } + + protected void execute(Object target) throws CoreException { + ((IRestart)target).restart(); + } + + protected boolean isExecutable(Object target) { + return ((IRestart)target).canRestart(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest) + */ + protected Object getEnabledStateJobFamily(IDebugCommandRequest request) { + return IRestart.class; + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java index b9f9ea25c76..38cfd177bf2 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java @@ -14,10 +14,17 @@ package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.DebugException; /** - * Provides the ability to restart a debug target. + * Provides the ability to restart a debug target. + *

+ * Note: Debug elements which support restart should implement this interface. + * Adopting to this interface is not enough. + *

+ *

+ * Note 2: Debugger can also implement the asynchronous + * {@link org.eclipse.debug.core.commands.IRestartHandler}. + *

* - * @deprecated Use org.eclipse.debug.core.commands.IRestartHandler instead. IRestartHandler - * handles the call in an asynchronous fashion. + * @see org.eclipse.debug.core.commands.IRestartHandler */ public interface IRestart { diff --git a/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/restart.gif b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/restart.gif deleted file mode 100644 index a3c6fc5f825..00000000000 Binary files a/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/restart.gif and /dev/null differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/restart.gif b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/restart.gif deleted file mode 100644 index 5708b00dd2b..00000000000 Binary files a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/restart.gif and /dev/null differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 4ad0aecaa06..5fba69e1041 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -27,9 +27,6 @@ BreakpointActionPage.name=Breakpoint Action UI Page RunMenu.label=&Run DebugActionSet.label=C/C++ Debug -RestartAction.label=Restart -RestartAction.tooltip=Restart - DisassemblyViewAction.label=Go to address... DisassemblyViewAction.tooltip=Enter memory address for the assembly code diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 1853b0395c2..1ee1f7d9635 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -247,15 +247,6 @@ helpContextId="move_to_line_action_context" label="%GlobalMoveToLineAction.label" menubarPath="org.eclipse.ui.run/stepGroup"/> - - - - - - - - - - - - - - - -