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 145060 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]
Correct and updated patch with refactored commands.
20090819_284363.patch (text/plain), 75.49 KB, created by
Pawel Piech
on 2009-08-19 23:47:45 EDT
(
hide
)
Description:
Correct and updated patch with refactored commands.
Filename:
MIME Type:
Creator:
Pawel Piech
Created:
2009-08-19 23:47:45 EDT
Size:
75.49 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 20 Aug 2009 03:45:27 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; >+ > /** > * 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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -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/ExecuteActionRequest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ExecuteActionRequest.java,v >retrieving revision 1.2 >diff -u -r1.2 ExecuteActionRequest.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ExecuteActionRequest.java 27 Mar 2007 02:08:30 -0000 1.2 >+++ ui/org/eclipse/debug/internal/ui/commands/actions/ExecuteActionRequest.java 20 Aug 2009 03:45:27 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.debug.internal.core.commands.DebugCommandRequest; > import org.eclipse.debug.internal.ui.DebugUIMessages; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.ui.actions.ICommandParticipant; > import org.eclipse.jface.dialogs.MessageDialog; > > /** >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 20 Aug 2009 03:45:27 -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: ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java >diff -N ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java 27 Mar 2007 02:08:30 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,23 +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.core.IRequest; >- >-/** >- * Adds function to a command on completion. >- * >- * @since 3.3 >- */ >-public interface ICommandParticipant { >- >- public void requestDone(IRequest request); >-} >Index: ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java >diff -N ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java 28 Nov 2006 17:59:38 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,134 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 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.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; >- >-/** >- * Abstract base class for debug action delegates performing debug commands. >- * >- * @since 3.3 >- */ >-public abstract class DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { >- >- /** >- *The real action for this delegate >- */ >- 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() { >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() >- */ >- public void dispose() { >- fDebugAction.dispose(); >- >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) >- */ >- public void init(IAction action) { >- fWindowAction = action; >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >- */ >- public void init(IWorkbenchWindow window) { >- fDebugAction.init(window); >- } >- >- /* >- * (non-Javadoc) >- * @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(); >- } >- >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) >- */ >- public void runWithEvent(IAction action, Event event) { >- run(action); >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >- */ >- public void selectionChanged(IAction action, ISelection s) { >- // do nothing >- } >- >- 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/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 20 Aug 2009 03:45:27 -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/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 20 Aug 2009 03:45:27 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; >+ > /** > * Suspend action delegate. > * >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 20 Aug 2009 03:45:27 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; >+ > /** > * 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 20 Aug 2009 03:45:27 -0000 >@@ -20,6 +20,8 @@ > 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.actions.ICommandParticipant; > import org.eclipse.debug.ui.contexts.DebugContextEvent; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; >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 20 Aug 2009 03:45:27 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; >+ > /** > * Resume action delegate. > * >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 20 Aug 2009 03:45:27 -0000 >@@ -19,6 +19,8 @@ > 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.actions.DebugCommandActionDelegate; > import org.eclipse.debug.ui.contexts.DebugContextEvent; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; >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 20 Aug 2009 03:45:27 -0000 >@@ -20,6 +20,8 @@ > 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.debug.ui.actions.ICommandParticipant; > import org.eclipse.jface.resource.ImageDescriptor; > > /** >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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; >+ > /** > * 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 20 Aug 2009 03:45:27 -0000 >@@ -21,10 +21,10 @@ > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.commands.IDebugCommandHandler; > import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.actions.ICommandParticipant; > 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 +111,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 +129,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 +152,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 +174,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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -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 20 Aug 2009 03:45:27 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.debug.internal.ui.commands.actions; > > import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; > import org.eclipse.ui.IWorkbenchWindow; > > /** >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 20 Aug 2009 03:45:27 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.debug.internal.ui.commands.actions; > >+import org.eclipse.debug.ui.actions.DebugCommandActionDelegate; >+ > /** > * Terminate action delegate. > * >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 20 Aug 2009 03:45:27 -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/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 20 Aug 2009 03:45:28 -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/ICommandParticipant.java >=================================================================== >RCS file: ui/org/eclipse/debug/ui/actions/ICommandParticipant.java >diff -N ui/org/eclipse/debug/ui/actions/ICommandParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/ui/actions/ICommandParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * Adds function to a command on completion. >+ * >+ * @since 3.6 This interface was in the internal package >+ * <code>org.eclipse.debug.internal.ui.commands.actions</code> since 3.3. >+ */ >+public interface ICommandParticipant { >+ >+ public void requestDone(IRequest request); >+} >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,287 @@ >+/******************************************************************************* >+ * 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.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.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 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. >+ * >+ * @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 { >+ >+ /** >+ * 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; >+ >+ 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 setDelegate(DebugCommandActionDelegate delegate) { >+ fDelegate = delegate; >+ } >+ >+ /** >+ * Executes this action on the given target object >+ * >+ * @param target the target to perform the action on >+ */ >+ private 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 {@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) { >+ 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(), 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() { >+ 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/ui/actions/DebugCommandActionDelegate.java >=================================================================== >RCS file: ui/org/eclipse/debug/ui/actions/DebugCommandActionDelegate.java >diff -N ui/org/eclipse/debug/ui/actions/DebugCommandActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/ui/actions/DebugCommandActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,135 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 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.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; >+ >+/** >+ * Abstract base class for debug action delegates performing debug commands. >+ * >+ * @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 DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { >+ >+ /** >+ *The real action for this delegate >+ */ >+ 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() { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() >+ */ >+ public void dispose() { >+ fDebugAction.dispose(); >+ >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) >+ */ >+ public void init(IAction action) { >+ fWindowAction = action; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void init(IWorkbenchWindow window) { >+ fDebugAction.init(window); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @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(); >+ } >+ >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) >+ */ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IAction action, ISelection s) { >+ // do nothing >+ } >+ >+ 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; >+ } >+ >+ >+} >#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 20 Aug 2009 03:45:30 -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 20 Aug 2009 03:45:30 -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: 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