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 146333 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]
Updated patch with comments.
20090902_284363.patch (text/plain), 87.00 KB, created by
Pawel Piech
on 2009-09-02 18:19:57 EDT
(
hide
)
Description:
Updated patch with comments.
Filename:
MIME Type:
Creator:
Pawel Piech
Created:
2009-09-02 18:19:57 EDT
Size:
87.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 StepReturnCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java 16 Oct 2006 18:47:24 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+ > /** > * Step return action delegate. > * >Index: ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 DropToFrameCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 StepReturnCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java,v >retrieving revision 1.3 >diff -u -r1.3 UpdateActionsRequest.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java 5 Jan 2009 17:22:51 -0000 1.3 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java 2 Sep 2009 22:19:55 -0000 >@@ -12,7 +12,6 @@ > > import org.eclipse.debug.core.commands.IEnabledStateRequest; > import org.eclipse.debug.internal.core.commands.DebugCommandRequest; >-import org.eclipse.jface.action.IAction; > > /** > * Boolean collector that collects boolean results from a number of voters. >@@ -23,10 +22,10 @@ > */ > public class UpdateActionsRequest extends DebugCommandRequest implements IEnabledStateRequest { > >- private IAction[] fActions; >+ private IEnabledTarget[] fActions; > private boolean fEnabled = false; > >- public UpdateActionsRequest(Object[] elements, IAction[] actions) { >+ public UpdateActionsRequest(Object[] elements, IEnabledTarget[] actions) { > super(elements); > fActions = actions; > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java,v >retrieving revision 1.3 >diff -u -r1.3 ICommandParticipant.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java 27 Mar 2007 02:08:30 -0000 1.3 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java 2 Sep 2009 22:19:55 -0000 >@@ -15,7 +15,7 @@ > /** > * Adds function to a command on completion. > * >- * @since 3.3 >+ * @since 3.3. > */ > public interface ICommandParticipant { > >Index: ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java,v >retrieving revision 1.3 >diff -u -r1.3 DebugCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java 28 Nov 2006 17:59:38 -0000 1.3 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.swt.widgets.Event; >@@ -21,7 +22,7 @@ > /** > * Abstract base class for debug action delegates performing debug commands. > * >- * @since 3.3 >+ * @since 3.3. > */ > public abstract class DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { > >@@ -30,27 +31,16 @@ > */ > private DebugCommandAction fDebugAction; > >- /** >- * The underlying action for this delegate >- */ >- private IAction fWindowAction; >- >- /** >- * Whether this action has been initialized before it has been run >- * (ensures enablement state is up to date when lazily instantiated) >- */ >- private boolean fInitialized = false; >- >- public DebugCommandActionDelegate() { >+ protected void setAction(DebugCommandAction action) { >+ fDebugAction = action; > } >- >+ > /* > * (non-Javadoc) > * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() > */ > public void dispose() { > fDebugAction.dispose(); >- > } > > /* >@@ -58,7 +48,7 @@ > * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) > */ > public void init(IAction action) { >- fWindowAction = action; >+ fDebugAction.setAction(action); > } > > /* >@@ -74,14 +64,6 @@ > * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) > */ > public void run(IAction action) { >- synchronized (this) { >- if (!fInitialized) { >- try { >- wait(); >- } catch (InterruptedException e) { >- } >- } >- } > fDebugAction.run(); > } > >@@ -105,30 +87,4 @@ > protected DebugCommandAction getAction() { > return fDebugAction; > } >- >- protected void setAction(DebugCommandAction action) { >- fDebugAction = action; >- action.setDelegate(this); >- } >- >- public void setEnabled(boolean enabled) { >- synchronized (this) { >- if (!fInitialized) { >- fInitialized = true; >- notifyAll(); >- } >- } >- fWindowAction.setEnabled(enabled); >- } >- >- public void setChecked(boolean checked) { >- fWindowAction.setChecked(checked); >- } >- >- protected IAction getWindowAction() >- { >- return fWindowAction; >- } >- >- > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java >diff -N ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java 27 Mar 2007 02:08:30 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,269 +0,0 @@ >-/******************************************************************************* >- * 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 >- *******************************************************************************/ >- >-package org.eclipse.debug.internal.ui.commands.actions; >- >-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.action.Action; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.swt.widgets.Event; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.IWorkbenchWindow; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * Abstract base class for actions performing debug commands >- * >- * @since 3.3 >- */ >-public abstract class DebugCommandAction extends Action implements IDebugContextListener { >- >- /** >- * The window this action is working for. >- */ >- private IWorkbenchWindow fWindow; >- >- /** >- * The part this action is working for, or <code>null</code> if global to >- * a window. >- */ >- private IWorkbenchPart fPart; >- >- /** >- * Command service. >- */ >- private DebugCommandService fUpdateService; >- >- /** >- * Delegate this action is working for or <code>null</code> if none. >- */ >- private DebugCommandActionDelegate fDelegate; >- >- /** >- * Constructor >- */ >- public DebugCommandAction() { >- super(); >- String helpContextId = getHelpContextId(); >- if (helpContextId != null) >- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId); >- setEnabled(false); >- } >- >- /** >- * Set the current delegate >- * @param delegate >- */ >- public void setDelegate(DebugCommandActionDelegate delegate) { >- fDelegate = delegate; >- } >- >- /** >- * Executes this action on the given target object >- * >- * @param target the target to perform the action on >- */ >- protected boolean execute(Object[] targets) { >- return fUpdateService.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 command type this action executes. >- * >- * @return command class. >- */ >- abstract protected Class getCommandType(); >- >- /** >- * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) >- */ >- public void debugContextChanged(DebugContextEvent event) { >- fUpdateService.postUpdateCommand(getCommandType(), this); >- } >- >- /** >- * @see org.eclipse.jface.action.Action#setEnabled(boolean) >- */ >- public void setEnabled(boolean enabled) { >- super.setEnabled(enabled); >- if (fDelegate != null) { >- fDelegate.setEnabled(enabled); >- } >- } >- >- /** >- * Initializes this action for a specific part. >- * >- * @param part workbench part >- */ >- public void init(IWorkbenchPart part) { >- fPart = part; >- fWindow = part.getSite().getWorkbenchWindow(); >- fUpdateService = DebugCommandService.getService(fWindow); >- IDebugContextService service = getDebugContextService(); >- String partId = part.getSite().getId(); >- service.addDebugContextListener(this, partId); >- ISelection activeContext = service.getActiveContext(partId); >- if (activeContext != null) { >- fUpdateService.updateCommand(getCommandType(), this); >- } else { >- setEnabled(getInitialEnablement()); >- } >- } >- >- /** >- * Initializes the context action >- * @param window the window >- */ >- public void init(IWorkbenchWindow window) { >- fWindow = window; >- fUpdateService = DebugCommandService.getService(fWindow); >- IDebugContextService contextService = getDebugContextService(); >- contextService.addDebugContextListener(this); >- ISelection activeContext = contextService.getActiveContext(); >- if (activeContext != null) { >- fUpdateService.updateCommand(getCommandType(), this); >- } else { >- setEnabled(getInitialEnablement()); >- } >- } >- >- /** >- * 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; >- } >- >- /** >- * Returns the most recent selection >- * >- * @return structured selection >- */ >- protected ISelection getContext() { >- if (fPart != null) { >- getDebugContextService().getActiveContext(fPart.getSite().getId()); >- } >- return getDebugContextService().getActiveContext(); >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#run() >- */ >- public void run() { >- ISelection selection = getContext(); >- if (selection instanceof IStructuredSelection && isEnabled()) { >- IStructuredSelection ss = (IStructuredSelection) selection; >- boolean enabled = execute(ss.toArray()); >- // disable the action according to the command >- setEnabled(enabled); >- } >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) >- */ >- public void runWithEvent(Event event) { >- run(); >- } >- >- /** >- * Clean up when removing >- */ >- public void dispose() { >- IDebugContextService service = getDebugContextService(); >- if (fPart != null) { >- service.removeDebugContextListener(this, fPart.getSite().getId()); >- } else { >- service.removeDebugContextListener(this); >- } >- fWindow = null; >- fPart = null; >- } >- >- /** >- * Returns the context service this action linked to. >- * @return >- */ >- protected IDebugContextService getDebugContextService() { >- return DebugUITools.getDebugContextManager().getContextService(fWindow); >- } >- >- /** >- * @return The help context id for this action >- */ >- public abstract String getHelpContextId(); >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#getId() >- */ >- public abstract String getId(); >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#getText() >- */ >- public abstract String getText(); >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#getToolTipText() >- */ >- public abstract String getToolTipText(); >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor() >- */ >- public abstract ImageDescriptor getDisabledImageDescriptor(); >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#getHoverImageDescriptor() >- */ >- public abstract ImageDescriptor getHoverImageDescriptor(); >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.action.Action#getImageDescriptor() >- */ >- public abstract ImageDescriptor getImageDescriptor(); >- >- /** >- * Returns the delegate associated with this action or <code>null</code> >- * if none. >- * >- * @return delegate or <code>null</code> >- */ >- protected DebugCommandActionDelegate getDelegate() { >- return fDelegate; >- } >-} >Index: ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 SuspendCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java 16 Oct 2006 18:47:24 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+ > /** > * Suspend action delegate. > * >Index: ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java,v >retrieving revision 1.2 >diff -u -r1.2 ActionsUpdater.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java 27 Mar 2007 02:08:30 -0000 1.2 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java 2 Sep 2009 22:19:55 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.debug.internal.ui.commands.actions; > >-import org.eclipse.jface.action.IAction; > > /** > * Collects votes from handler update requests. >@@ -20,13 +19,13 @@ > */ > public class ActionsUpdater { > >- private IAction[] fActions; >+ private IEnabledTarget[] fActions; > private int fNumVoters; > private int fNumOfVotes = 0; > private boolean fDone = false; > private boolean fEnabled = true; > >- public ActionsUpdater(IAction[] actions, int numVoters) { >+ public ActionsUpdater(IEnabledTarget[] actions, int numVoters) { > fActions = actions; > fNumVoters = numVoters; > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 StepOverCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java 16 Oct 2006 18:47:24 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+ > /** > * Step over action delegate. > * >Index: ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java,v >retrieving revision 1.10 >diff -u -r1.10 TerminateAndRelaunchAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java 31 Mar 2009 20:46:21 -0000 1.10 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java 2 Sep 2009 22:19:55 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.debug.internal.ui.actions.ActionMessages; > import org.eclipse.debug.internal.ui.actions.RelaunchActionDelegate; > import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.debug.ui.contexts.DebugContextEvent; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; >@@ -30,37 +31,21 @@ > */ > public class TerminateAndRelaunchAction extends DebugCommandAction { > >- class Participant implements ICommandParticipant { >- >- private Object[] fTargets; >- >- public Participant(Object[] targets) { >- fTargets = targets; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant#requestDone(org.eclipse.debug.core.commands.IRequest) >- */ >- public void requestDone(IRequest request) { >- if (request.getStatus() == null || request.getStatus().isOK()) { >- DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { >- public void run() { >- // Must be run in the UI thread since the launch can require >- // prompting to proceed >- for (int i = 0; i < fTargets.length; i++) { >- ILaunch launch = RelaunchActionDelegate.getLaunch(fTargets[i]); >- RelaunchActionDelegate.relaunch(launch.getLaunchConfiguration(), launch.getLaunchMode()); >- } >- } >- }); >- } >- } >- >- } >+ public void postExecute(IRequest request, final Object[] targets) { >+ if (request.getStatus() == null || request.getStatus().isOK()) { >+ DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { >+ public void run() { >+ // Must be run in the UI thread since the launch can require >+ // prompting to proceed >+ for (int i = 0; i < targets.length; i++) { >+ ILaunch launch = RelaunchActionDelegate.getLaunch(targets[i]); >+ RelaunchActionDelegate.relaunch(launch.getLaunchConfiguration(), launch.getLaunchMode()); >+ } >+ } >+ }); >+ } >+ } > >- protected ICommandParticipant getCommandParticipant(Object[] targets) { >- return new Participant(targets); >- } > > protected Class getCommandType() { > return ITerminateHandler.class; >Index: ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 ResumeCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java 16 Oct 2006 18:47:24 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,17 +11,45 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandAction; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.IWorkbenchWindowActionDelegate; >+ > /** > * Resume action delegate. > * > * @since 3.3 > */ >-public class ResumeCommandActionDelegate extends DebugCommandActionDelegate { >+public class ResumeCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { > >- public ResumeCommandActionDelegate() { >- super(); >- setAction(new ResumeCommandAction()); >+ private DebugCommandAction fDebugAction = new ResumeCommandAction(); >+ >+ public void dispose() { >+ fDebugAction.dispose(); > } > >- >+ public void init(IWorkbenchWindow window) { >+ fDebugAction.init(window); >+ } >+ >+ public void run(IAction action) { >+ fDebugAction.run(); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // do nothing >+ } >+ >+ public void init(IAction action) { >+ fDebugAction.setAction(action); >+ >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java,v >retrieving revision 1.11 >diff -u -r1.11 ToggleStepFiltersAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java 31 May 2007 21:35:41 -0000 1.11 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java 2 Sep 2009 22:19:55 -0000 >@@ -19,7 +19,9 @@ > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; > import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.debug.ui.contexts.DebugContextEvent; >+import org.eclipse.jface.action.IAction; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.ui.IWorkbenchPart; >@@ -166,9 +168,9 @@ > if (event.getProperty().equals(StepFilterManager.PREF_USE_STEP_FILTERS)) { > boolean checked = DebugUITools.isUseStepFilters(); > setChecked(checked); >- DebugCommandActionDelegate delegate = getDelegate(); >- if (delegate != null) { >- delegate.setChecked(checked); >+ IAction action = getAction(); >+ if (action != null) { >+ action.setChecked(checked); > } > } > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java,v >retrieving revision 1.6 >diff -u -r1.6 TerminateAndRemoveAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java 2 Sep 2009 22:19:55 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >@@ -29,38 +30,6 @@ > */ > public class TerminateAndRemoveAction extends DebugCommandAction { > >- >- class TerminateAndRemoveParticipant implements ICommandParticipant { >- private Object[] fElements; >- >- TerminateAndRemoveParticipant(Object[] elements) { >- fElements = elements; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant#requestDone(org.eclipse.debug.core.commands.IRequest) >- */ >- public void requestDone(IRequest request) { >- IStatus status = request.getStatus(); >- if(status == null || status.isOK()) { >- for (int i = 0; i < fElements.length; i++) { >- Object element = fElements[i]; >- ILaunch launch= null; >- if (element instanceof ILaunch) { >- launch= (ILaunch) element; >- } else if (element instanceof IDebugElement) { >- launch= ((IDebugElement) element).getLaunch(); >- } else if (element instanceof IProcess) { >- launch= ((IProcess) element).getLaunch(); >- } >- if (launch != null) >- DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch); >- } >- } >- } >- >- } >- > public String getText() { > return ActionMessages.TerminateAndRemoveAction_0; > } >@@ -93,9 +62,24 @@ > return ITerminateHandler.class; > } > >- protected ICommandParticipant getCommandParticipant(Object[] targets) { >- return new TerminateAndRemoveParticipant(targets); >- } >+ protected void requestDone(Object[] elements, IRequest request) { >+ IStatus status = request.getStatus(); >+ if(status == null || status.isOK()) { >+ for (int i = 0; i < elements.length; i++) { >+ Object element = elements[i]; >+ ILaunch launch= null; >+ if (element instanceof ILaunch) { >+ launch= (ILaunch) element; >+ } else if (element instanceof IDebugElement) { >+ launch= ((IDebugElement) element).getLaunch(); >+ } else if (element instanceof IProcess) { >+ launch= ((IProcess) element).getLaunch(); >+ } >+ if (launch != null) >+ DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch); >+ } >+ } >+ } > > > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 StepIntoCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java,v >retrieving revision 1.8 >diff -u -r1.8 TerminateAllAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java 30 Apr 2009 20:23:13 -0000 1.8 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java 2 Sep 2009 22:19:55 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.StructuredSelection; >Index: ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 DisconnectCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -15,6 +15,7 @@ > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; > import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > /** > * Disconnect action. >Index: ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 SuspendCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 StepIntoCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java 16 Oct 2006 18:47:23 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+ > /** > * Step into action delegate. > * >Index: ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java,v >retrieving revision 1.13 >diff -u -r1.13 DebugCommandService.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java 5 Jan 2009 17:22:51 -0000 1.13 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java 2 Sep 2009 22:19:55 -0000 >@@ -24,7 +24,6 @@ > 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.action.Action; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -111,7 +110,7 @@ > * @param commandType > * @param monitor > */ >- public void postUpdateCommand(Class commandType, Action action) { >+ public void postUpdateCommand(Class commandType, IEnabledTarget action) { > synchronized (fCommandUpdates) { > Job.getJobManager().cancel(commandType); > List actions = (List) fCommandUpdates.get(commandType); >@@ -129,11 +128,11 @@ > * @param commandType > * @param requestMonitor > */ >- public void updateCommand(Class commandType, IAction action) { >+ public void updateCommand(Class commandType, IEnabledTarget action) { > ISelection context = fContextService.getActiveContext(); > if (context instanceof IStructuredSelection && !context.isEmpty()) { > Object[] elements = ((IStructuredSelection)context).toArray(); >- updateCommand(commandType, elements, new IAction[]{action}); >+ updateCommand(commandType, elements, new IEnabledTarget[]{action}); > } else { > action.setEnabled(false); > } >@@ -152,7 +151,7 @@ > Entry entry = (Entry) iterator.next(); > Class commandType = (Class)entry.getKey(); > List actions = (List) entry.getValue(); >- updateCommand(commandType, elements, (IAction[]) actions.toArray(new IAction[actions.size()])); >+ updateCommand(commandType, elements, (IEnabledTarget[]) actions.toArray(new IEnabledTarget[actions.size()])); > } > } else { > Iterator iterator = commands.values().iterator(); >@@ -174,7 +173,7 @@ > * @param elements elements to update for > * @param monitor status monitor > */ >- private void updateCommand(Class handlerType, Object[] elements, IAction[] actions) { >+ private void updateCommand(Class handlerType, Object[] elements, IEnabledTarget[] actions) { > if (elements.length == 1) { > // usual case - one element > Object element = elements[0]; >Index: ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 StepOverCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -15,6 +15,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 ResumeCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java,v >retrieving revision 1.6 >diff -u -r1.6 TerminateCommandAction.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java 31 May 2007 21:35:41 -0000 1.6 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java 2 Sep 2009 22:19:55 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.actions.ActionMessages; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >Index: ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java,v >retrieving revision 1.3 >diff -u -r1.3 ToggleStepFiltersCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java 30 Oct 2006 16:54:13 -0000 1.3 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -12,7 +12,7 @@ > package org.eclipse.debug.internal.ui.commands.actions; > > import org.eclipse.debug.ui.DebugUITools; >-import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.jface.action.IAction; > > /** > * Toggle step filters action delegate. >@@ -29,11 +29,8 @@ > setAction(new ToggleStepFiltersAction()); > } > >- /** >- * @see org.eclipse.debug.internal.ui.commands.actions.DebugCommandActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >- */ >- public void init(IWorkbenchWindow window) { >- super.init(window); >- setChecked(DebugUITools.isUseStepFilters()); >- } >+ public void init(IAction action) { >+ super.init(action); >+ action.setChecked(DebugUITools.isUseStepFilters()); >+ } > } >Index: ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java,v >retrieving revision 1.1 >diff -u -r1.1 TerminateCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java 16 Oct 2006 18:47:24 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java 2 Sep 2009 22:19:55 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+ > /** > * Terminate action delegate. > * >Index: ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java,v >retrieving revision 1.195 >diff -u -r1.195 LaunchView.java >--- ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java 6 May 2009 19:52:37 -0000 1.195 >+++ ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java 2 Sep 2009 22:19:55 -0000 >@@ -41,7 +41,6 @@ > import org.eclipse.debug.internal.ui.IDebugHelpContextIds; > import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction; > import org.eclipse.debug.internal.ui.actions.EditLaunchConfigurationAction; >-import org.eclipse.debug.internal.ui.commands.actions.DebugCommandAction; > import org.eclipse.debug.internal.ui.commands.actions.DisconnectCommandAction; > import org.eclipse.debug.internal.ui.commands.actions.DropToFrameCommandAction; > import org.eclipse.debug.internal.ui.commands.actions.ResumeCommandAction; >@@ -72,6 +71,7 @@ > import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.debug.ui.IDebugModelPresentation; > import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.debug.ui.actions.DebugCommandAction; > import org.eclipse.debug.ui.contexts.AbstractDebugContextProvider; > import org.eclipse.debug.ui.contexts.DebugContextEvent; > import org.eclipse.debug.ui.contexts.IDebugContextListener; >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,267 @@ >+/******************************************************************************* >+ * 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.core.IRequest; >+import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService; >+import org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant; >+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 used only by thedebugger 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 { >+ >+ /** >+ * The DebugCommandService is able to evaluate the command handler >+ * enablement in each workbench window separately, however the workbench >+ * command framework uses only a single handler instance for all windows. >+ * This IEnabledTarget implementation tracks enablement of the command >+ * for a given window. When the handler enablement is tested, the >+ * currently active window is used to determine which enabled target >+ * to use. >+ */ >+ private class EnabledTarget implements IEnabledTarget, IDebugContextListener { >+ boolean fEnabled = getInitialEnablement(); >+ IWorkbenchWindow fWindow; >+ >+ EnabledTarget(IWorkbenchWindow window) { >+ fWindow = window; >+ DebugCommandService.getService(fWindow).updateCommand(getCommandType(), this); >+ getContextService(fWindow).addDebugContextListener(this); >+ } >+ >+ public void setEnabled(boolean enabled) { >+ boolean oldEnabled = fEnabled; >+ fEnabled = enabled; >+ if (fEnabled != oldEnabled && fCurrentEnabledTarget == this) { >+ fireHandlerChanged(new HandlerEvent(DebugCommandHandler.this, true, false)); >+ } >+ } >+ >+ public void debugContextChanged(DebugContextEvent event) { >+ DebugCommandService.getService(fWindow).postUpdateCommand(getCommandType(), this); >+ } >+ >+ void dispose() { >+ if (isDisposed()) { >+ return; >+ } >+ getContextService(fWindow).removeDebugContextListener(this); >+ fWindow = null; >+ } >+ >+ boolean isDisposed() { >+ return fWindow == null; >+ } >+ } >+ >+ /** >+ * Window listener is used to make sure that the handler enablement >+ * is updated when the active workbench window is changed. >+ */ >+ private IWindowListener fWindowListener = 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) { >+ fCurrentEnabledTarget = (EnabledTarget)fEnabledTargetsMap.get(w); >+ fireHandlerChanged(new HandlerEvent(DebugCommandHandler.this, true, false)); >+ } >+ }; >+ >+ /** >+ * Map of enabled targets keyed by workbench window. >+ */ >+ private Map fEnabledTargetsMap = new WeakHashMap(); >+ >+ /** >+ * The current enabled target, based on the active >+ * workbench window. >+ */ >+ private EnabledTarget fCurrentEnabledTarget = null; >+ >+ /** >+ * The constructor adds the handler as the >+ */ >+ public DebugCommandHandler() { >+ super(); >+ PlatformUI.getWorkbench().addWindowListener(fWindowListener); >+ } >+ >+ public void setEnabled(Object evaluationContext) { >+ // This method is called with the current evaluation context >+ // just prior to the isEnabled() being called. Check the active >+ // window and update the current enabled target based on it >+ 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); >+ 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, final Object[] targets) { >+ DebugCommandService service = DebugCommandService.getService(window); >+ return service.executeCommand( >+ getCommandType(), targets, >+ new ICommandParticipant() { >+ public void requestDone(org.eclipse.debug.core.IRequest request) { >+ DebugCommandHandler.this.postExecute(request, targets); >+ } >+ }); >+ } >+ >+ /** >+ * This method is called after the completion of the execution of this >+ * command. Extending classes may override this method to perform additional >+ * operation after command execution. >+ * >+ * @param request The completed request object which was given the the >+ * debug command handler. >+ * @param targets Objects which were the targets of this action >+ */ >+ protected void postExecute(IRequest request, Object[] targets) { >+ // do nothing by default >+ } >+ >+ /** >+ * 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() { >+ PlatformUI.getWorkbench().removeWindowListener(fWindowListener); >+ for (Iterator itr = fEnabledTargetsMap.values().iterator(); itr.hasNext();) { >+ EnabledTarget target = (EnabledTarget)itr.next(); >+ if (!target.isDisposed()) { >+ target.dispose(); >+ } >+ } >+ fEnabledTargetsMap.clear(); >+ fCurrentEnabledTarget = null; >+ } >+} >Index: ui/org/eclipse/debug/internal/ui/commands/actions/IEnabledTarget.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/commands/actions/IEnabledTarget.java >diff -N ui/org/eclipse/debug/internal/ui/commands/actions/IEnabledTarget.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/IEnabledTarget.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.internal.ui.commands.actions; >+ >+/** >+ * >+ */ >+public interface IEnabledTarget { >+ public void setEnabled(boolean enabled); >+} >Index: ui/org/eclipse/debug/ui/actions/DebugCommandAction.java >=================================================================== >RCS file: ui/org/eclipse/debug/ui/actions/DebugCommandAction.java >diff -N ui/org/eclipse/debug/ui/actions/DebugCommandAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/ui/actions/DebugCommandAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,329 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+ >+package org.eclipse.debug.ui.actions; >+ >+import org.eclipse.debug.core.IRequest; >+import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService; >+import org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant; >+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.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * Abstract base class for re-targeting actions 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> >+ * This base class is an action which can be instantiated directly by views, >+ * etc. In order to contribute an action using an extension point, a class >+ * implementing {@link org.eclipse.ui.IActionDelegate} should be created first. >+ * The delegate should then use the <code>DebugCommandAction</code> implement >+ * the needed delegate functionality. <br> >+ * Note: <code>IDebugCommandHandler</code> command typically act on the active >+ * debug context as opposed to the active selection in view or window. The >+ * action delegate should ignore the active window selection, and instead allow >+ * the <code>DebugCommandAction</code> to update itself based on the active >+ * debug context. >+ * </p> >+ * >+ * @see org.eclipse.debug.core.commands.IDebugCommandHandler >+ * >+ * @since 3.6 This class was in the internal package >+ * <code>org.eclipse.debug.internal.ui.commands.actions</code> since 3.3. >+ */ >+public abstract class DebugCommandAction extends Action implements IDebugContextListener { >+ >+ private boolean fInitialized = false; >+ >+ /** >+ * The window this action is working for. >+ */ >+ private IWorkbenchWindow fWindow; >+ >+ /** >+ * The part this action is working for, or <code>null</code> if global to >+ * a window. >+ */ >+ private IWorkbenchPart fPart; >+ >+ /** >+ * Command service. >+ */ >+ private DebugCommandService fUpdateService; >+ >+ /** >+ * Delegate this action is working for or <code>null</code> if none. >+ */ >+ private IAction fAction; >+ >+ private IEnabledTarget fEnabledTarget = new IEnabledTarget() { >+ public void setEnabled(boolean enabled) { >+ DebugCommandAction.this.setEnabled(enabled); >+ } >+ }; >+ >+ /** >+ * Constructor >+ */ >+ public DebugCommandAction() { >+ super(); >+ String helpContextId = getHelpContextId(); >+ if (helpContextId != null) >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId); >+ setEnabled(false); >+ } >+ >+ /** >+ * Set the current delegate >+ * @param delegate >+ */ >+ public void setAction(IAction action) { >+ fAction = action; >+ fAction.setEnabled(isEnabled()); >+ } >+ >+ /** >+ * Executes this action on the given target object >+ * >+ * @param target the target to perform the action on >+ */ >+ private boolean execute(final Object[] targets) { >+ return fUpdateService.executeCommand( >+ getCommandType(), targets, >+ new ICommandParticipant() { >+ public void requestDone(org.eclipse.debug.core.IRequest request) { >+ DebugCommandAction.this.postExecute(request, targets); >+ } >+ }); >+ } >+ >+ /** >+ * This method is called after the completion of the execution of this >+ * command. Extending classes may override this method to perform additional >+ * operation after command execution. >+ * >+ * @param targets Objects which were the targets of this action >+ * @param request The completed request object which was given the the >+ * debug command handler. >+ */ >+ protected void postExecute(IRequest request, Object[] targets) { >+ // do nothing by default >+ } >+ >+ /** >+ * 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(); >+ >+ /** >+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) >+ */ >+ public void debugContextChanged(DebugContextEvent event) { >+ fUpdateService.postUpdateCommand(getCommandType(), fEnabledTarget); >+ } >+ >+ /** >+ * @see org.eclipse.jface.action.Action#setEnabled(boolean) >+ */ >+ public void setEnabled(boolean enabled) { >+ synchronized (this) { >+ if (!fInitialized) { >+ fInitialized = true; >+ notifyAll(); >+ } >+ } >+ super.setEnabled(enabled); >+ if (fAction != null) { >+ fAction.setEnabled(enabled); >+ } >+ } >+ >+ /** >+ * Initializes this action for a specific part. >+ * >+ * @param part workbench part >+ */ >+ public void init(IWorkbenchPart part) { >+ fPart = part; >+ fWindow = part.getSite().getWorkbenchWindow(); >+ fUpdateService = DebugCommandService.getService(fWindow); >+ IDebugContextService service = getDebugContextService(); >+ String partId = part.getSite().getId(); >+ service.addDebugContextListener(this, partId); >+ ISelection activeContext = service.getActiveContext(partId); >+ if (activeContext != null) { >+ fUpdateService.updateCommand(getCommandType(), fEnabledTarget); >+ } else { >+ setEnabled(getInitialEnablement()); >+ } >+ } >+ >+ /** >+ * Initializes the context action >+ * @param window the window >+ */ >+ public void init(IWorkbenchWindow window) { >+ fWindow = window; >+ fUpdateService = DebugCommandService.getService(fWindow); >+ IDebugContextService contextService = getDebugContextService(); >+ contextService.addDebugContextListener(this); >+ ISelection activeContext = contextService.getActiveContext(); >+ if (activeContext != null) { >+ fUpdateService.updateCommand(getCommandType(), fEnabledTarget); >+ } else { >+ setEnabled(getInitialEnablement()); >+ } >+ } >+ >+ /** >+ * 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; >+ } >+ >+ /** >+ * Returns the most recent selection >+ * >+ * @return structured selection >+ */ >+ private ISelection getContext() { >+ if (fPart != null) { >+ getDebugContextService().getActiveContext(fPart.getSite().getId()); >+ } >+ return getDebugContextService().getActiveContext(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#run() >+ */ >+ public void run() { >+ synchronized (this) { >+ if (!fInitialized) { >+ try { >+ wait(); >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ >+ ISelection selection = getContext(); >+ if (selection instanceof IStructuredSelection && isEnabled()) { >+ IStructuredSelection ss = (IStructuredSelection) selection; >+ boolean enabled = execute(ss.toArray()); >+ // disable the action according to the command >+ setEnabled(enabled); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) >+ */ >+ public void runWithEvent(Event event) { >+ run(); >+ } >+ >+ /** >+ * Clean up when removing >+ */ >+ public void dispose() { >+ IDebugContextService service = getDebugContextService(); >+ if (fPart != null) { >+ service.removeDebugContextListener(this, fPart.getSite().getId()); >+ } else { >+ service.removeDebugContextListener(this); >+ } >+ fWindow = null; >+ fPart = null; >+ } >+ >+ /** >+ * Returns the context service this action linked to. >+ * @return >+ */ >+ protected IDebugContextService getDebugContextService() { >+ return DebugUITools.getDebugContextManager().getContextService(fWindow); >+ } >+ >+ /** >+ * @return The help context id for this action >+ */ >+ public abstract String getHelpContextId(); >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#getId() >+ */ >+ public abstract String getId(); >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#getText() >+ */ >+ public abstract String getText(); >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#getToolTipText() >+ */ >+ public abstract String getToolTipText(); >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor() >+ */ >+ public abstract ImageDescriptor getDisabledImageDescriptor(); >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#getHoverImageDescriptor() >+ */ >+ public abstract ImageDescriptor getHoverImageDescriptor(); >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#getImageDescriptor() >+ */ >+ public abstract ImageDescriptor getImageDescriptor(); >+ >+ /** >+ * Returns the delegate associated with this action or <code>null</code> >+ * if none. >+ * >+ * @return delegate or <code>null</code> >+ */ >+ protected IAction getAction() { >+ return fAction; >+ } >+} >#P org.eclipse.debug.core >Index: core/org/eclipse/debug/internal/core/commands/DebugCommand.java >=================================================================== >RCS file: core/org/eclipse/debug/internal/core/commands/DebugCommand.java >diff -N core/org/eclipse/debug/internal/core/commands/DebugCommand.java >--- core/org/eclipse/debug/internal/core/commands/DebugCommand.java 5 Jan 2009 17:22:53 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,324 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2009 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 >- *******************************************************************************/ >-package org.eclipse.debug.internal.core.commands; >- >-import java.util.LinkedHashSet; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.core.runtime.jobs.IJobChangeEvent; >-import org.eclipse.core.runtime.jobs.IJobChangeListener; >-import org.eclipse.core.runtime.jobs.ISchedulingRule; >-import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.debug.core.DebugPlugin; >-import org.eclipse.debug.core.IRequest; >-import org.eclipse.debug.core.commands.IDebugCommandHandler; >-import org.eclipse.debug.core.commands.IDebugCommandRequest; >-import org.eclipse.debug.core.commands.IEnabledStateRequest; >-import org.eclipse.debug.internal.core.DebugOptions; >- >-/** >- * Common function for standard debug commands. >- * >- * @since 3.3 >- * >- */ >-public abstract class DebugCommand implements IDebugCommandHandler { >- >- /** >- * Job to update enabled state of action. >- */ >- class UpdateJob extends Job implements IJobChangeListener { >- >- /** >- * The request to update >- */ >- private IEnabledStateRequest request; >- >- /** >- * Whether this job has been run >- */ >- private boolean run = false; >- >- /** >- * Creates a new job to update the specified request >- * >- * @param stateRequest >- */ >- UpdateJob(IEnabledStateRequest stateRequest) { >- super(getEnablementTaskName()); >- request = stateRequest; >- setSystem(true); >- setRule(createUpdateSchedulingRule(request)); >- getJobManager().addJobChangeListener(this); >- } >- >- protected IStatus run(IProgressMonitor monitor) { >- run = true; >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.print("can execute command: " + DebugCommand.this); //$NON-NLS-1$ >- } >- if (monitor.isCanceled()) { >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println(" >> *CANCELED* <<"); //$NON-NLS-1$ >- } >- request.cancel(); >- } >- Object[] elements = request.getElements(); >- Object[] targets = new Object[elements.length]; >- if (!request.isCanceled()) { >- for (int i = 0; i < elements.length; i++) { >- targets[i] = getTarget(elements[i]); >- if (targets[i] == null) { >- request.setEnabled(false); >- request.cancel(); >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println(" >> false (no adapter)"); //$NON-NLS-1$ >- } >- } >- } >- if (monitor.isCanceled()) { >- request.cancel(); >- } >- } >- if (!request.isCanceled()) { >- targets = coalesce(targets); >- monitor.beginTask(getEnablementTaskName(), targets.length); >- try { >- boolean executable = isExecutable(targets, monitor, request); >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println(" >> " + executable); //$NON-NLS-1$ >- } >- request.setEnabled(executable); >- } catch (CoreException e) { >- request.setStatus(e.getStatus()); >- request.setEnabled(false); >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println(" >> ABORTED"); //$NON-NLS-1$ >- System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$ >- } >- } >- } >- monitor.setCanceled(request.isCanceled()); >- request.done(); >- monitor.done(); >- return Status.OK_STATUS; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) >- */ >- public boolean belongsTo(Object family) { >- return getUpdateJobFamily().equals(family); >- } >- >- public void aboutToRun(IJobChangeEvent event) { >- } >- >- public void awake(IJobChangeEvent event) { >- } >- >- public void done(IJobChangeEvent event) { >- if (event.getJob() == this) { >- if (!run) { >- request.cancel(); >- request.done(); >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println(" >> *CANCELED* <<" + DebugCommand.this); //$NON-NLS-1$ >- } >- } >- getJobManager().removeJobChangeListener(this); >- } >- } >- >- public void running(IJobChangeEvent event) { >- } >- >- public void scheduled(IJobChangeEvent event) { >- } >- >- public void sleeping(IJobChangeEvent event) { >- } >- >- } >- >- /** >- * Scheduling rule to serialize commands on an object >- */ >- class SerialPerObjectRule implements ISchedulingRule { >- >- private Object fObject = null; >- >- public SerialPerObjectRule(Object lock) { >- fObject = lock; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule) >- */ >- public boolean contains(ISchedulingRule rule) { >- return rule == this; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule) >- */ >- public boolean isConflicting(ISchedulingRule rule) { >- if (rule instanceof SerialPerObjectRule) { >- SerialPerObjectRule vup = (SerialPerObjectRule) rule; >- return fObject == vup.fObject; >- } >- return false; >- } >- >- } >- >- public boolean execute(final IDebugCommandRequest request) { >- Job job = new Job(getExecuteTaskName()) { >- protected IStatus run(IProgressMonitor monitor) { >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println("execute: " + DebugCommand.this); //$NON-NLS-1$ >- } >- Object[] elements = request.getElements(); >- Object[] targets = new Object[elements.length]; >- for (int i = 0; i < elements.length; i++) { >- targets[i]= getTarget(elements[i]); >- } >- targets = coalesce(targets); >- monitor.beginTask(getExecuteTaskName(), targets.length); >- try { >- doExecute(targets, monitor, request); >- } catch (CoreException e) { >- request.setStatus(e.getStatus()); >- if (DebugOptions.DEBUG_COMMANDS) { >- System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$ >- } >- } >- request.done(); >- monitor.setCanceled(request.isCanceled()); >- monitor.done(); >- return Status.OK_STATUS; >- } >- }; >- job.setSystem(true); >- job.schedule(); >- return isRemainEnabled(); >- } >- >- /** >- * Returns whether this command should remain enabled after execution is invoked. >- * >- * @return whether to remain enabled >- */ >- protected boolean isRemainEnabled() { >- return false; >- } >- >- public void canExecute(final IEnabledStateRequest request) { >- Job job = new UpdateJob(request); >- job.schedule(); >- } >- >- /** >- * Returns the name to use for jobs and progress monitor task names when checking >- * enabled state. >- * >- * @return task name >- */ >- protected String getEnablementTaskName() { >- // this is a system job name and does not need to be NLS'd >- return "Check Debug Command"; //$NON-NLS-1$ >- } >- >- /** >- * Returns the name to use for jobs and progress monitor task names when executing >- * a debug command >- * >- * @return task name >- */ >- protected String getExecuteTaskName() { >- // this is a system job name and does not need to be NLS'd >- return "Execute Debug Command"; //$NON-NLS-1$ >- } >- >- /** >- * Executes the actual operation. >- * >- * @param targets objects to perform on >- * @param request request >- */ >- protected abstract void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException; >- >- /** >- * Returns whether this command is executable. >- * >- * @param targets objects to check command for >- * @param monitor progress monitor >- * @param request request >- * @return whether this command can be executed >- */ >- protected abstract boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException; >- >- /** >- * Returns the appropriate command adapter from the given object. >- * >- * @param element object to obtain adapter from >- * @return adapter >- */ >- protected abstract Object getTarget(Object element); >- >- /** >- * Returns an adapter of the specified type for the given object or <code>null</code> >- * if none. The object itself is returned if it is an instance of the specified type. >- * >- * @param element element to retrieve adapter for >- * @param type adapter type >- * @return adapter or <code>null</code> >- */ >- protected Object getAdapter(Object element, Class type) { >- return DebugPlugin.getAdapter(element, type); >- } >- >- /** >- * Scheduling rule for updating command enabled state. >- * >- * @return scheduling rule or <code>null</code> >- */ >- protected ISchedulingRule createUpdateSchedulingRule(IDebugCommandRequest request) { >- return new SerialPerObjectRule(request.getElements()[0]); >- } >- >- private Object[] coalesce(Object[] objects) { >- if (objects.length == 1) { >- return objects; >- } else { >- LinkedHashSet set = new LinkedHashSet(objects.length); >- for (int i = 0; i < objects.length; i++) { >- set.add(objects[i]); >- } >- return set.toArray(); >- } >- } >- >- /** >- * Returns the job family for this command's "can execute" job. >- * >- * @return the job family for this command's "can execute" job >- */ >- protected abstract Object getUpdateJobFamily(); >- >-} >Index: core/org/eclipse/debug/internal/core/commands/ForEachCommand.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ForEachCommand.java,v >retrieving revision 1.1 >diff -u -r1.1 ForEachCommand.java >--- core/org/eclipse/debug/internal/core/commands/ForEachCommand.java 4 Jan 2007 15:37:08 -0000 1.1 >+++ core/org/eclipse/debug/internal/core/commands/ForEachCommand.java 2 Sep 2009 22:20:00 -0000 >@@ -13,6 +13,7 @@ > 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; > > /** >@@ -20,7 +21,7 @@ > * > * @since 3.3 > */ >-public abstract class ForEachCommand extends DebugCommand { >+public abstract class ForEachCommand 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) >Index: core/org/eclipse/debug/internal/core/commands/StepCommand.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java,v >retrieving revision 1.5 >diff -u -r1.5 StepCommand.java >--- core/org/eclipse/debug/internal/core/commands/StepCommand.java 29 May 2008 15:11:53 -0000 1.5 >+++ core/org/eclipse/debug/internal/core/commands/StepCommand.java 2 Sep 2009 22:20:00 -0000 >@@ -17,6 +17,7 @@ > import org.eclipse.core.runtime.IAdaptable; > 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.core.model.IStackFrame; > import org.eclipse.debug.core.model.IStep; >@@ -26,7 +27,7 @@ > * > * @since 3.3 > */ >-public abstract class StepCommand extends DebugCommand { >+public abstract class StepCommand extends AbstractDebugCommand { > > protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { > for (int i = 0; i < targets.length; i++) { >Index: buildnotes_platform-debug.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/buildnotes_platform-debug.html,v >retrieving revision 1.2143 >diff -u -r1.2143 buildnotes_platform-debug.html >--- buildnotes_platform-debug.html 29 Jun 2009 16:43:11 -0000 1.2143 >+++ buildnotes_platform-debug.html 2 Sep 2009 22:20:00 -0000 >@@ -11,6 +11,16 @@ > > <h2>Summary of API changes in 3.6</h2> > >+<h3>DebugCommandAction base class</h3> >+<p><strong>What is affected:</strong> >+<ul> >+ <li>Class addition: <code>org.eclipse.debug.ui.actions.DebugCommandAction</code> </li> >+ <li>Class addition: <code>org.eclipse.debug.ui.actions.DebugCommandHandler</code> </li> >+</ul> >+</p> >+<p><strong>Description:</strong>The <code>IDebugCommandHandler</code> interface allows debugger to implement debug action handlers which execute asynchronously. Most of the debugger actions user this interface to communicate with the debug model. However, debuggers which need to add their own asynchronous actions had to duplicate the debug framework actions which invoke the <code>IDebugCommandHandler</code> handlers. <code>DebugCommandAction</code> and <code>DebugCommandHandler</code> are base classes which can be extended by debuggers to implement new types of actions with asynchronous execution handlers.</p> >+<p><strong>Action required:</strong> This is a backwards compatible change. No action required. </p> >+ > <p> </p> > </body> > </html> >Index: core/org/eclipse/debug/core/commands/AbstractDebugCommand.java >=================================================================== >RCS file: core/org/eclipse/debug/core/commands/AbstractDebugCommand.java >diff -N core/org/eclipse/debug/core/commands/AbstractDebugCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ core/org/eclipse/debug/core/commands/AbstractDebugCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,322 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2009 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 >+ *******************************************************************************/ >+package org.eclipse.debug.core.commands; >+ >+import java.util.LinkedHashSet; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.IJobChangeEvent; >+import org.eclipse.core.runtime.jobs.IJobChangeListener; >+import org.eclipse.core.runtime.jobs.ISchedulingRule; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IRequest; >+import org.eclipse.debug.internal.core.DebugOptions; >+ >+/** >+ * Common function for standard debug commands. >+ * >+ * @since 3.6 This class was in the internal package >+ * <code>org.eclipse.debug.internal.core.commands</code> since 3.3. >+ * >+ */ >+public abstract class AbstractDebugCommand implements IDebugCommandHandler { >+ >+ /** >+ * Job to update enabled state of action. >+ */ >+ private class UpdateJob extends Job implements IJobChangeListener { >+ >+ /** >+ * The request to update >+ */ >+ private IEnabledStateRequest request; >+ >+ /** >+ * Whether this job has been run >+ */ >+ private boolean run = false; >+ >+ /** >+ * Creates a new job to update the specified request >+ * >+ * @param stateRequest >+ */ >+ UpdateJob(IEnabledStateRequest stateRequest) { >+ super(getEnablementTaskName()); >+ request = stateRequest; >+ setSystem(true); >+ setRule(createUpdateSchedulingRule(request)); >+ getJobManager().addJobChangeListener(this); >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ run = true; >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.print("can execute command: " + AbstractDebugCommand.this); //$NON-NLS-1$ >+ } >+ if (monitor.isCanceled()) { >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println(" >> *CANCELED* <<"); //$NON-NLS-1$ >+ } >+ request.cancel(); >+ } >+ Object[] elements = request.getElements(); >+ Object[] targets = new Object[elements.length]; >+ if (!request.isCanceled()) { >+ for (int i = 0; i < elements.length; i++) { >+ targets[i] = getTarget(elements[i]); >+ if (targets[i] == null) { >+ request.setEnabled(false); >+ request.cancel(); >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println(" >> false (no adapter)"); //$NON-NLS-1$ >+ } >+ } >+ } >+ if (monitor.isCanceled()) { >+ request.cancel(); >+ } >+ } >+ if (!request.isCanceled()) { >+ targets = coalesce(targets); >+ monitor.beginTask(getEnablementTaskName(), targets.length); >+ try { >+ boolean executable = isExecutable(targets, monitor, request); >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println(" >> " + executable); //$NON-NLS-1$ >+ } >+ request.setEnabled(executable); >+ } catch (CoreException e) { >+ request.setStatus(e.getStatus()); >+ request.setEnabled(false); >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println(" >> ABORTED"); //$NON-NLS-1$ >+ System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$ >+ } >+ } >+ } >+ monitor.setCanceled(request.isCanceled()); >+ request.done(); >+ monitor.done(); >+ return Status.OK_STATUS; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) >+ */ >+ public boolean belongsTo(Object family) { >+ return getUpdateJobFamily().equals(family); >+ } >+ >+ public void aboutToRun(IJobChangeEvent event) { >+ } >+ >+ public void awake(IJobChangeEvent event) { >+ } >+ >+ public void done(IJobChangeEvent event) { >+ if (event.getJob() == this) { >+ if (!run) { >+ request.cancel(); >+ request.done(); >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println(" >> *CANCELED* <<" + AbstractDebugCommand.this); //$NON-NLS-1$ >+ } >+ } >+ getJobManager().removeJobChangeListener(this); >+ } >+ } >+ >+ public void running(IJobChangeEvent event) { >+ } >+ >+ public void scheduled(IJobChangeEvent event) { >+ } >+ >+ public void sleeping(IJobChangeEvent event) { >+ } >+ >+ } >+ >+ /** >+ * Scheduling rule to serialize commands on an object >+ */ >+ private class SerialPerObjectRule implements ISchedulingRule { >+ >+ private Object fObject = null; >+ >+ public SerialPerObjectRule(Object lock) { >+ fObject = lock; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule) >+ */ >+ public boolean contains(ISchedulingRule rule) { >+ return rule == this; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule) >+ */ >+ public boolean isConflicting(ISchedulingRule rule) { >+ if (rule instanceof SerialPerObjectRule) { >+ SerialPerObjectRule vup = (SerialPerObjectRule) rule; >+ return fObject == vup.fObject; >+ } >+ return false; >+ } >+ >+ } >+ >+ public boolean execute(final IDebugCommandRequest request) { >+ Job job = new Job(getExecuteTaskName()) { >+ protected IStatus run(IProgressMonitor monitor) { >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println("execute: " + AbstractDebugCommand.this); //$NON-NLS-1$ >+ } >+ Object[] elements = request.getElements(); >+ Object[] targets = new Object[elements.length]; >+ for (int i = 0; i < elements.length; i++) { >+ targets[i]= getTarget(elements[i]); >+ } >+ targets = coalesce(targets); >+ monitor.beginTask(getExecuteTaskName(), targets.length); >+ try { >+ doExecute(targets, monitor, request); >+ } catch (CoreException e) { >+ request.setStatus(e.getStatus()); >+ if (DebugOptions.DEBUG_COMMANDS) { >+ System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$ >+ } >+ } >+ request.done(); >+ monitor.setCanceled(request.isCanceled()); >+ monitor.done(); >+ return Status.OK_STATUS; >+ } >+ }; >+ job.setSystem(true); >+ job.schedule(); >+ return isRemainEnabled(); >+ } >+ >+ /** >+ * Returns whether this command should remain enabled after execution is invoked. >+ * >+ * @return whether to remain enabled >+ */ >+ protected boolean isRemainEnabled() { >+ return false; >+ } >+ >+ public void canExecute(final IEnabledStateRequest request) { >+ Job job = new UpdateJob(request); >+ job.schedule(); >+ } >+ >+ /** >+ * Returns the name to use for jobs and progress monitor task names when checking >+ * enabled state. >+ * >+ * @return task name >+ */ >+ protected String getEnablementTaskName() { >+ // this is a system job name and does not need to be NLS'd >+ return "Check Debug Command"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns the name to use for jobs and progress monitor task names when executing >+ * a debug command >+ * >+ * @return task name >+ */ >+ protected String getExecuteTaskName() { >+ // this is a system job name and does not need to be NLS'd >+ return "Execute Debug Command"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Executes the actual operation. >+ * >+ * @param targets objects to perform on >+ * @param request request >+ */ >+ protected abstract void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException; >+ >+ /** >+ * Returns whether this command is executable. >+ * >+ * @param targets objects to check command for >+ * @param monitor progress monitor >+ * @param request request >+ * @return whether this command can be executed >+ */ >+ protected abstract boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException; >+ >+ /** >+ * Returns the appropriate command adapter from the given object. >+ * >+ * @param element object to obtain adapter from >+ * @return adapter >+ */ >+ protected abstract Object getTarget(Object element); >+ >+ /** >+ * Returns an adapter of the specified type for the given object or <code>null</code> >+ * if none. The object itself is returned if it is an instance of the specified type. >+ * >+ * @param element element to retrieve adapter for >+ * @param type adapter type >+ * @return adapter or <code>null</code> >+ */ >+ protected Object getAdapter(Object element, Class type) { >+ return DebugPlugin.getAdapter(element, type); >+ } >+ >+ /** >+ * Scheduling rule for updating command enabled state. >+ * >+ * @return scheduling rule or <code>null</code> >+ */ >+ protected ISchedulingRule createUpdateSchedulingRule(IDebugCommandRequest request) { >+ return new SerialPerObjectRule(request.getElements()[0]); >+ } >+ >+ private Object[] coalesce(Object[] objects) { >+ if (objects.length == 1) { >+ return objects; >+ } else { >+ LinkedHashSet set = new LinkedHashSet(objects.length); >+ for (int i = 0; i < objects.length; i++) { >+ set.add(objects[i]); >+ } >+ return set.toArray(); >+ } >+ } >+ >+ /** >+ * Returns the job family for this command's "can execute" job. >+ * >+ * @return the job family for this command's "can execute" job >+ */ >+ protected abstract Object getUpdateJobFamily(); >+ >+}
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