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 145200 Details for
Bug 284363
Move DebugCommandAction to an API package
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch eliminating command participant and delegate from API.
20090820_284363.patch (text/plain), 81.50 KB, created by
Pawel Piech
on 2009-08-20 18:12:22 EDT
(
hide
)
Description:
Patch eliminating command participant and delegate from API.
Filename:
MIME Type:
Creator:
Pawel Piech
Created:
2009-08-20 18:12:22 EDT
Size:
81.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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 22:08:21 -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 22:08:21 -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(); >+ >+} >#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 22:08:23 -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 20 Aug 2009 22:08:23 -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 22:08:23 -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 20 Aug 2009 22:08:23 -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 20 Aug 2009 22:08:23 -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 20 Aug 2009 22:08:23 -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 20 Aug 2009 22:08:23 -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 20 Aug 2009 22:08:23 -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 20 Aug 2009 22:08:23 -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/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 22:08:23 -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/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 22:08:23 -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; >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 22:08:23 -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 20 Aug 2009 22:08:23 -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 20 Aug 2009 22:08:23 -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 22:08:23 -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 22:08:23 -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 22:08:23 -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 22:08:23 -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 20 Aug 2009 22:08:23 -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/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 22:08:23 -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/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 22:08:23 -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/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 22:08:23 -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/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 22:08:23 -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/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 22:08:23 -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 20 Aug 2009 22:08:24 -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,250 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Wind River Systems - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.debug.ui.actions; >+ >+import java.util.Iterator; >+import java.util.Map; >+import java.util.WeakHashMap; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.HandlerEvent; >+import org.eclipse.core.expressions.IEvaluationContext; >+import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService; >+import org.eclipse.debug.internal.ui.commands.actions.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 is internal to the debugger plugins. This class implements >+ * {@link org.eclipse.core.commands.IHandler} interface and is to be used with the >+ * platform commands framework. </p> >+ * >+ * @see org.eclipse.debug.core.commands.IDebugCommandHandler >+ * @see org.eclipse.core.commands.IHandler >+ * >+ * @since 3.6 >+ */ >+public abstract class DebugCommandHandler extends AbstractHandler { >+ >+ private class EnabledTarget implements IEnabledTarget, IDebugContextListener, IWindowListener { >+ boolean fEnabled = getInitialEnablement(); >+ IWorkbenchWindow fWindow; >+ >+ EnabledTarget(IWorkbenchWindow window) { >+ fWindow = window; >+ DebugCommandService.getService(fWindow).updateCommand(getCommandType(), this); >+ getContextService(fWindow).addDebugContextListener(this); >+ PlatformUI.getWorkbench().addWindowListener(this); >+ } >+ >+ public void setEnabled(boolean enabled) { >+ boolean oldEnabled = fEnabled; >+ fEnabled = enabled; >+ if (fEnabled != oldEnabled) { >+ fireHandlerChanged(new HandlerEvent(DebugCommandHandler.this, true, false)); >+ } >+ } >+ >+ public void debugContextChanged(DebugContextEvent event) { >+ DebugCommandService.getService(fWindow).postUpdateCommand(getCommandType(), this); >+ } >+ >+ public void windowOpened(IWorkbenchWindow w) { >+ } >+ >+ public void windowDeactivated(IWorkbenchWindow w) { >+ } >+ >+ public void windowClosed(IWorkbenchWindow w) { >+ if (w.equals(fWindow)) { >+ dispose(); >+ } >+ } >+ >+ public void windowActivated(IWorkbenchWindow w) { >+ } >+ >+ void dispose() { >+ if (isDisposed()) { >+ return; >+ } >+ PlatformUI.getWorkbench().removeWindowListener(this); >+ getContextService(fWindow).removeDebugContextListener(this); >+ fWindow = null; >+ } >+ >+ boolean isDisposed() { >+ return fWindow == null; >+ } >+ } >+ >+ private Map fEnabledTargetsMap = new WeakHashMap(); >+ >+ private EnabledTarget fCurrentEnabledTarget = null; >+ >+ /** >+ * Constructor >+ */ >+ public DebugCommandHandler() { >+ super(); >+ PlatformUI.getWorkbench().addWindowListener(new IWindowListener() { >+ >+ public void windowOpened(IWorkbenchWindow w) { >+ } >+ >+ public void windowDeactivated(IWorkbenchWindow w) { >+ } >+ >+ public void windowClosed(IWorkbenchWindow w) { >+ EnabledTarget enabledTarget = (EnabledTarget)fEnabledTargetsMap.get(w); >+ if (enabledTarget != null) { >+ enabledTarget.dispose(); >+ } >+ } >+ >+ public void windowActivated(IWorkbenchWindow w) { >+ } >+ }); >+ } >+ >+ public void setEnabled(Object evaluationContext) { >+ fCurrentEnabledTarget = null; >+ >+ if (!(evaluationContext instanceof IEvaluationContext)) { >+ return; >+ } >+ IEvaluationContext context = (IEvaluationContext) evaluationContext; >+ Object _window = context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ if (_window instanceof IWorkbenchWindow) { >+ IWorkbenchWindow window = (IWorkbenchWindow)_window; >+ fCurrentEnabledTarget = getEnabledTarget(window); >+ } >+ } >+ >+ public boolean isEnabled() { >+ if (fCurrentEnabledTarget == null) { >+ return false; >+ } >+ return fCurrentEnabledTarget.fEnabled; >+ } >+ >+ private EnabledTarget getEnabledTarget(IWorkbenchWindow window) { >+ EnabledTarget target = (EnabledTarget)fEnabledTargetsMap.get(window); >+ if (target == null) { >+ target = new EnabledTarget(window); >+ DebugCommandService service = DebugCommandService.getService(window); >+ service.updateCommand(getCommandType(), target); >+ >+ DebugUITools.getDebugContextManager().getContextService(window).addDebugContextListener(target); >+ >+ fEnabledTargetsMap.put(window, target); >+ } >+ return target; >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); >+ if (window == null) { >+ throw new ExecutionException("No active workbench window."); >+ } >+ fCurrentEnabledTarget = getEnabledTarget(window); >+ >+ ISelection selection = getContextService(window).getActiveContext(); >+ if (selection instanceof IStructuredSelection && isEnabled()) { >+ IStructuredSelection ss = (IStructuredSelection) selection; >+ boolean enabledAfterExecute = execute(window, ss.toArray()); >+ >+ // enable/disable the action according to the command >+ fCurrentEnabledTarget.setEnabled(enabledAfterExecute); >+ } >+ >+ return null; >+ } >+ >+ private IDebugContextService getContextService(IWorkbenchWindow window) { >+ return DebugUITools.getDebugContextManager().getContextService(window); >+ } >+ >+ /** >+ * Executes this action on the given target object >+ * >+ * @param target the target to perform the action on >+ */ >+ private boolean execute(IWorkbenchWindow window, Object[] targets) { >+ DebugCommandService service = DebugCommandService.getService(window); >+ return service.executeCommand(getCommandType(), targets, getCommandParticipant(targets)); >+ } >+ >+ /** >+ * Creates and returns the command participant or <code>null</code>. >+ * >+ * @return command participant to use on command completion >+ */ >+ protected ICommandParticipant getCommandParticipant(Object[] targets) { >+ return null; >+ } >+ >+ /** >+ * Returns the {@link org.eclipse.debug.core.commands.IDebugCommandHandler} >+ * command handler that type this action executes. >+ * >+ * @return command class. >+ * >+ * @see org.eclipse.debug.core.commands.IDebugCommandHandler >+ */ >+ abstract protected Class getCommandType(); >+ >+ >+ /** >+ * Returns whether this action should be enabled when initialized >+ * and there is no active debug context. >+ * >+ * @return false, by default >+ */ >+ protected boolean getInitialEnablement() { >+ return false; >+ } >+ >+ >+ /** >+ * Clean up when removing >+ */ >+ public void dispose() { >+ for (Iterator itr = fEnabledTargetsMap.values().iterator(); itr.hasNext();) { >+ EnabledTarget target = (EnabledTarget)itr.next(); >+ if (!target.isDisposed()) { >+ target.dispose(); >+ } >+ } >+ fEnabledTargetsMap.clear(); >+ fCurrentEnabledTarget = null; >+ } >+} >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,308 @@ >+/******************************************************************************* >+ * 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. >+ * >+ * @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.requestDone(targets, request); >+ } >+ }); >+ } >+ >+ protected void requestDone(Object[] targets, IRequest request) { >+ // 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; >+ } >+}
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