Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 145061 Details for
Bug 284363
Move DebugCommandAction to an API package
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch with DebugCommandHandler.
20090819_284363-handler.patch (text/plain), 17.02 KB, created by
Pawel Piech
on 2009-08-19 23:53:35 EDT
(
hide
)
Description:
Patch with DebugCommandHandler.
Filename:
MIME Type:
Creator:
Pawel Piech
Created:
2009-08-19 23:53:35 EDT
Size:
17.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java >=================================================================== >RCS file: ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java >diff -N ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,249 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 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: >+ * Wind River Systems - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.debug.ui.actions; >+ >+import java.util.Iterator; >+import java.util.Map; >+import java.util.WeakHashMap; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.HandlerEvent; >+import org.eclipse.core.expressions.IEvaluationContext; >+import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService; >+import org.eclipse.debug.internal.ui.commands.actions.IEnabledTarget; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.contexts.DebugContextEvent; >+import org.eclipse.debug.ui.contexts.IDebugContextListener; >+import org.eclipse.debug.ui.contexts.IDebugContextService; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.ISources; >+import org.eclipse.ui.IWindowListener; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.handlers.HandlerUtil; >+ >+/** >+ * Abstract base class for re-targeting command framework handlers, which >+ * delegate execution to {@link org.eclipse.debug.core.commands.IDebugCommandHandler} >+ * handlers. The specific type of <code>IDebugCommandHandler</code> is >+ * determined by the abstract {@link #getCommandType()} method. >+ * >+ * <p> Note: This class is not an implementation of the <code>IDebugCommandHandler</code> >+ * interface, which was somewhat unfortunately named. <code>IDebugCommandHandler</code> >+ * is an interface that is internal to the debugger plugins. This class implements >+ * {@link org.eclipse.core.commands.IHandler} interface and is to be used with the >+ * platform commands framework. </p> >+ * >+ * @see org.eclipse.debug.core.commands.IDebugCommandHandler >+ * @see org.eclipse.core.commands.IHandler >+ * >+ * @since 3.6 >+ */ >+public abstract class DebugCommandHandler extends AbstractHandler { >+ >+ private class EnabledTarget implements IEnabledTarget, IDebugContextListener, IWindowListener { >+ boolean fEnabled = getInitialEnablement(); >+ IWorkbenchWindow fWindow; >+ >+ EnabledTarget(IWorkbenchWindow window) { >+ fWindow = window; >+ DebugCommandService.getService(fWindow).updateCommand(getCommandType(), this); >+ getContextService(fWindow).addDebugContextListener(this); >+ PlatformUI.getWorkbench().addWindowListener(this); >+ } >+ >+ public void setEnabled(boolean enabled) { >+ boolean oldEnabled = fEnabled; >+ fEnabled = enabled; >+ if (fEnabled != oldEnabled) { >+ fireHandlerChanged(new HandlerEvent(DebugCommandHandler.this, true, false)); >+ } >+ } >+ >+ public void debugContextChanged(DebugContextEvent event) { >+ DebugCommandService.getService(fWindow).postUpdateCommand(getCommandType(), this); >+ } >+ >+ public void windowOpened(IWorkbenchWindow w) { >+ } >+ >+ public void windowDeactivated(IWorkbenchWindow w) { >+ } >+ >+ public void windowClosed(IWorkbenchWindow w) { >+ if (w.equals(fWindow)) { >+ dispose(); >+ } >+ } >+ >+ public void windowActivated(IWorkbenchWindow w) { >+ } >+ >+ void dispose() { >+ if (isDisposed()) { >+ return; >+ } >+ PlatformUI.getWorkbench().removeWindowListener(this); >+ getContextService(fWindow).removeDebugContextListener(this); >+ fWindow = null; >+ } >+ >+ boolean isDisposed() { >+ return fWindow == null; >+ } >+ } >+ >+ private Map fEnabledTargetsMap = new WeakHashMap(); >+ >+ private EnabledTarget fCurrentEnabledTarget = null; >+ >+ /** >+ * Constructor >+ */ >+ public DebugCommandHandler() { >+ super(); >+ PlatformUI.getWorkbench().addWindowListener(new IWindowListener() { >+ >+ public void windowOpened(IWorkbenchWindow w) { >+ } >+ >+ public void windowDeactivated(IWorkbenchWindow w) { >+ } >+ >+ public void windowClosed(IWorkbenchWindow w) { >+ EnabledTarget enabledTarget = (EnabledTarget)fEnabledTargetsMap.get(w); >+ if (enabledTarget != null) { >+ enabledTarget.dispose(); >+ } >+ } >+ >+ public void windowActivated(IWorkbenchWindow w) { >+ } >+ }); >+ } >+ >+ public void setEnabled(Object evaluationContext) { >+ fCurrentEnabledTarget = null; >+ >+ if (!(evaluationContext instanceof IEvaluationContext)) { >+ return; >+ } >+ IEvaluationContext context = (IEvaluationContext) evaluationContext; >+ Object _window = context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ if (_window instanceof IWorkbenchWindow) { >+ IWorkbenchWindow window = (IWorkbenchWindow)_window; >+ fCurrentEnabledTarget = getEnabledTarget(window); >+ } >+ } >+ >+ public boolean isEnabled() { >+ if (fCurrentEnabledTarget == null) { >+ return false; >+ } >+ return fCurrentEnabledTarget.fEnabled; >+ } >+ >+ private EnabledTarget getEnabledTarget(IWorkbenchWindow window) { >+ EnabledTarget target = (EnabledTarget)fEnabledTargetsMap.get(window); >+ if (target == null) { >+ target = new EnabledTarget(window); >+ DebugCommandService service = DebugCommandService.getService(window); >+ service.updateCommand(getCommandType(), target); >+ >+ DebugUITools.getDebugContextManager().getContextService(window).addDebugContextListener(target); >+ >+ fEnabledTargetsMap.put(window, target); >+ } >+ return target; >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); >+ if (window == null) { >+ throw new ExecutionException("No active workbench window."); >+ } >+ fCurrentEnabledTarget = getEnabledTarget(window); >+ >+ ISelection selection = getContextService(window).getActiveContext(); >+ if (selection instanceof IStructuredSelection && isEnabled()) { >+ IStructuredSelection ss = (IStructuredSelection) selection; >+ boolean enabledAfterExecute = execute(window, ss.toArray()); >+ >+ // enable/disable the action according to the command >+ fCurrentEnabledTarget.setEnabled(enabledAfterExecute); >+ } >+ >+ return null; >+ } >+ >+ private IDebugContextService getContextService(IWorkbenchWindow window) { >+ return DebugUITools.getDebugContextManager().getContextService(window); >+ } >+ >+ /** >+ * Executes this action on the given target object >+ * >+ * @param target the target to perform the action on >+ */ >+ private boolean execute(IWorkbenchWindow window, Object[] targets) { >+ DebugCommandService service = DebugCommandService.getService(window); >+ return service.executeCommand(getCommandType(), targets, getCommandParticipant(targets)); >+ } >+ >+ /** >+ * Creates and returns the command participant or <code>null</code>. >+ * >+ * @return command participant to use on command completion >+ */ >+ protected ICommandParticipant getCommandParticipant(Object[] targets) { >+ return null; >+ } >+ >+ /** >+ * Returns the {@link org.eclipse.debug.core.commands.IDebugCommandHandler} >+ * command handler that type this action executes. >+ * >+ * @return command class. >+ * >+ * @see org.eclipse.debug.core.commands.IDebugCommandHandler >+ */ >+ abstract protected Class getCommandType(); >+ >+ >+ /** >+ * Returns whether this action should be enabled when initialized >+ * and there is no active debug context. >+ * >+ * @return false, by default >+ */ >+ protected boolean getInitialEnablement() { >+ return false; >+ } >+ >+ >+ /** >+ * Clean up when removing >+ */ >+ public void dispose() { >+ for (Iterator itr = fEnabledTargetsMap.values().iterator(); itr.hasNext();) { >+ EnabledTarget target = (EnabledTarget)itr.next(); >+ if (!target.isDisposed()) { >+ target.dispose(); >+ } >+ } >+ fEnabledTargetsMap.clear(); >+ fCurrentEnabledTarget = null; >+ } >+} >#P org.eclipse.debug.examples.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.examples.ui/plugin.xml,v >retrieving revision 1.14 >diff -u -r1.14 plugin.xml >--- plugin.xml 31 Mar 2009 20:42:05 -0000 1.14 >+++ plugin.xml 20 Aug 2009 03:45:56 -0000 >@@ -216,6 +216,13 @@ > </adapter> > </factory> > --> >+ <factory >+ adaptableType="org.eclipse.debug.examples.core.pda.model.PDAStackFrame" >+ class="org.eclipse.debug.examples.ui.pda.commands.CommandAdapterFactory"> >+ <adapter >+ type="org.eclipse.debug.examples.ui.pda.commands.PopFrameDebugCommand"> >+ </adapter> >+ </factory> > </extension> > > <extension >@@ -335,6 +342,10 @@ > id="org.eclipse.debug.examples.ui.popCommand" > name="Pop"> > </command> >+ <command >+ id="org.eclipse.debug.examples.ui.popFrameCommand" >+ name="Pop Frame"> >+ </command> > </extension> > <extension > point="org.eclipse.ui.handlers"> >@@ -380,6 +391,10 @@ > </and> > </enabledWhen> > </handler> >+ <handler >+ class="org.eclipse.debug.examples.ui.pda.commands.PopFrameHandler" >+ commandId="org.eclipse.debug.examples.ui.popFrameCommand"> >+ </handler> > </extension> > <extension > point="org.eclipse.core.expressions.propertyTesters"> >@@ -427,5 +442,15 @@ > style="push"> > </command> > </menuContribution> >+ <menuContribution >+ locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=additions"> >+ <command >+ commandId="org.eclipse.debug.examples.ui.popFrameCommand" >+ disabledIcon="icons/full/dlcl16/pop.gif" >+ icon="icons/full/elcl16/pop.gif" >+ label="Pop Frame" >+ style="push"> >+ </command> >+ </menuContribution> > </extension> > </plugin> >Index: src/org/eclipse/debug/examples/ui/pda/commands/PopFrameHandler.java >=================================================================== >RCS file: src/org/eclipse/debug/examples/ui/pda/commands/PopFrameHandler.java >diff -N src/org/eclipse/debug/examples/ui/pda/commands/PopFrameHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/debug/examples/ui/pda/commands/PopFrameHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Wind River 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: >+ * Wind River Systems - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.examples.ui.pda.commands; >+ >+import org.eclipse.debug.ui.actions.DebugCommandHandler; >+ >+/** >+ * >+ */ >+public class PopFrameHandler extends DebugCommandHandler { >+ >+ protected Class getCommandType() { >+ return PopFrameDebugCommand.class; >+ } >+} >Index: src/org/eclipse/debug/examples/ui/pda/commands/CommandAdapterFactory.java >=================================================================== >RCS file: src/org/eclipse/debug/examples/ui/pda/commands/CommandAdapterFactory.java >diff -N src/org/eclipse/debug/examples/ui/pda/commands/CommandAdapterFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/debug/examples/ui/pda/commands/CommandAdapterFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 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 >+ * Bjorn Freeman-Benson - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.examples.ui.pda.commands; >+ >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.debug.examples.core.pda.model.PDAStackFrame; >+ >+ >+/** >+ * >+ * @since 3.6 >+ * >+ */ >+public class CommandAdapterFactory implements IAdapterFactory { >+ >+ private static PopFrameDebugCommand fgPopFrameDebugCommand = new PopFrameDebugCommand(); >+ >+ public Object getAdapter(Object adaptableObject, Class adapterType) { >+ if (PopFrameDebugCommand.class.equals(adapterType)) { >+ if (adaptableObject instanceof PDAStackFrame) { >+ return fgPopFrameDebugCommand; >+ } >+ } >+ return null; >+ } >+ >+ public Class[] getAdapterList() { >+ return new Class[]{PopFrameDebugCommand.class}; >+ } >+ >+} >Index: src/org/eclipse/debug/examples/ui/pda/commands/PopFrameDebugCommand.java >=================================================================== >RCS file: src/org/eclipse/debug/examples/ui/pda/commands/PopFrameDebugCommand.java >diff -N src/org/eclipse/debug/examples/ui/pda/commands/PopFrameDebugCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/debug/examples/ui/pda/commands/PopFrameDebugCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Wind River 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: >+ * Wind River Systems - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.examples.ui.pda.commands; >+ >+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; >+import org.eclipse.debug.examples.core.pda.model.PDAStackFrame; >+import org.eclipse.debug.examples.core.pda.model.PDAThread; >+ >+/** >+ * >+ */ >+public class PopFrameDebugCommand extends AbstractDebugCommand { >+ >+ protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { >+ for (int i = 0; i< targets.length; i++) { >+ PDAStackFrame frame = (PDAStackFrame)targets[i]; >+ ((PDAThread)frame.getThread()).popFrame(); >+ } >+ } >+ >+ protected Object getTarget(Object element) { >+ if (element instanceof PDAStackFrame) { >+ return element; >+ } >+ return null; >+ } >+ >+ protected Object getUpdateJobFamily() { >+ return PopFrameDebugCommand.class; >+ } >+ >+ protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) >+ throws CoreException >+ { >+ boolean enabled = true; >+ for (int i = 0; i< targets.length; i++) { >+ PDAStackFrame frame = (PDAStackFrame)targets[i]; >+ PDAThread thread = (PDAThread)frame.getThread(); >+ enabled = enabled && thread.canPopFrame() && thread.getTopStackFrame().equals(frame); >+ } >+ return enabled; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 284363
:
145005
|
145060
|
145061
|
145200
|
146333
|
146696