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 20531 Details for
Bug 80323
Make global step actions retargettable
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
ui-80323.patch (text/plain), 17.29 KB, created by
Darin Wright
on 2005-04-29 17:05:26 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2005-04-29 17:05:26 EDT
Size:
17.29 KB
patch
obsolete
>Index: plugin.xml >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/plugin.xml,v >retrieving revision 1.327 >diff -u -r1.327 plugin.xml >--- plugin.xml 26 Apr 2005 21:47:27 -0000 1.327 >+++ plugin.xml 29 Apr 2005 21:02:14 -0000 >@@ -186,7 +186,7 @@ > <action > id="org.eclipse.debug.ui.actions.StepOver" > hoverIcon="icons/full/elcl16/stepover_co.gif" >- class="org.eclipse.debug.internal.ui.actions.StepOverActionDelegate" >+ class="org.eclipse.debug.internal.ui.actions.StepOverRetargetAction" > definitionId="org.eclipse.debug.ui.commands.StepOver" > disabledIcon="icons/full/dlcl16/stepover_co.gif" > icon="icons/full/elcl16/stepover_co.gif" >Index: ui/org/eclipse/debug/internal/ui/actions/LaunchViewRetargetAction.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/actions/LaunchViewRetargetAction.java >diff -N ui/org/eclipse/debug/internal/ui/actions/LaunchViewRetargetAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/actions/LaunchViewRetargetAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,409 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 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.actions; >+ >+import java.util.Iterator; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IAdapterManager; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IDebugEventSetListener; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IPartListener; >+import org.eclipse.ui.IPartService; >+import org.eclipse.ui.ISelectionListener; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchPartSite; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.IWorkbenchWindowActionDelegate; >+ >+/** >+ * A retargettable action that operates in conjuction with the selection in the >+ * debug veiw. >+ * >+ * @since 3.1 >+ */ >+public abstract class LaunchViewRetargetAction implements IWorkbenchWindowActionDelegate, IActionDelegate2, IPartListener, ISelectionListener, IDebugEventSetListener { >+ >+ private IWorkbenchWindow fWindow = null; >+ private IWorkbenchPart fActivePart = null; >+ private ISelection fActivePartSelection = null; >+ private IWorkbenchPart fDebugview; >+ private ISelection fDebugViewSelection = null; >+ private IAction fAction = null; >+ private UpdateJob fUpdateJob = new UpdateJob(); >+ private RunJob fRunJob = new RunJob(); >+ >+ /** >+ * Job to update action enablement. >+ */ >+ class UpdateJob extends Job { >+ public UpdateJob() { >+ super("Update Action Enablement"); >+ setSystem(true); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IStatus run(IProgressMonitor monitor) { >+ doUpdate(); >+ return Status.OK_STATUS; >+ } >+ } >+ >+ class RunJob extends Job { >+ private Object[] targets; >+ >+ public RunJob() { >+ super("Run Action"); >+ setSystem(true); >+ } >+ >+ protected void configure(Object[] t) { >+ targets = t; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IStatus run(IProgressMonitor monitor) { >+ for (int i = 0; i < targets.length; i++) { >+ Object target = targets[i]; >+ if (canPerformAction(target)) { >+ try { >+ performAction(target); >+ } catch (CoreException e) { >+ return e.getStatus(); >+ } >+ } >+ } >+ return Status.OK_STATUS; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() >+ */ >+ public void dispose() { >+ DebugPlugin.getDefault().removeDebugEventListener(this); >+ fWindow.getPartService().removePartListener(this); >+ fWindow.getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); >+ fDebugview = null; >+ fDebugViewSelection = null; >+ fActivePart = null; >+ fActivePartSelection = null; >+ fWindow = null; >+ fAction = null; >+ fUpdateJob.cancel(); >+ fUpdateJob = null; >+ fRunJob.cancel(); >+ fRunJob = null; >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void init(IWorkbenchWindow window) { >+ this.fWindow = window; >+ IPartService partService = window.getPartService(); >+ partService.addPartListener(this); >+ IWorkbenchPart part = partService.getActivePart(); >+ if (part != null) { >+ partActivated(part); >+ } >+ window.getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); >+ DebugPlugin.getDefault().addDebugEventListener(this); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) >+ */ >+ public synchronized final void run(IAction action) { >+ if (action.isEnabled()) { >+ action.setEnabled(false); >+ fRunJob.schedule(); >+ } >+ } >+ >+ /** >+ * Updates this action based on current settings. >+ */ >+ protected final void update() { >+ fUpdateJob.schedule(); >+ } >+ >+ /** >+ * Performs the specific breakpoint toggling. >+ * >+ * @param target the target to operate on >+ * @throws CoreException if an exception occurrs >+ */ >+ protected abstract void performAction(Object target) throws CoreException; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IAction action, ISelection selection) { >+ fAction.setEnabled(false); >+ fActivePartSelection = selection; >+ update(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IWorkbenchPart part, ISelection selection) { >+ fDebugview = part; >+ fAction.setEnabled(false); >+ fDebugViewSelection = selection; >+ update(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) >+ */ >+ public void init(IAction action) { >+ fAction = action; >+ } >+ >+ /* (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); >+ } >+ >+ /** >+ * Udpates the enablement of this action based on the given part and selection, >+ * and returns whether this action is now enabled. >+ * >+ * @param part part in which to resolve a target adapter or <code>null</code> >+ * @param selection selection in the given part or <code>null</code> >+ */ >+ protected synchronized void update(IWorkbenchPart part, ISelection selection) { >+ IAction action = getAction(); >+ if (action == null) { >+ return; >+ } >+ Object adapter = null; >+ if (part != fDebugview) { >+ adapter = getAdapter(part); >+ } >+ if (adapter == null && selection instanceof IStructuredSelection) { >+ IStructuredSelection ss = (IStructuredSelection) selection; >+ boolean enabled = false; >+ if (!ss.isEmpty()) { >+ enabled = true; >+ Iterator iterator = ss.iterator(); >+ while (iterator.hasNext() && enabled) { >+ Object object = iterator.next(); >+ adapter = getAdapter(object); >+ enabled = adapter != null && canPerformAction(adapter); >+ } >+ } >+ action.setEnabled(enabled); >+ if (enabled) { >+ fRunJob.configure(ss.toArray()); >+ } >+ } else { >+ if (adapter != null) { >+ action.setEnabled(canPerformAction(adapter)); >+ if (action.isEnabled()) { >+ fRunJob.configure(new Object[]{adapter}); >+ } >+ } else { >+ action.setEnabled(false); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void partActivated(IWorkbenchPart part) { >+ fActivePart = part; >+ } >+ >+ /** >+ * Returns the currently active part or <code>null</code> if none. >+ * >+ * @return the currently active part or <code>null</code> if none >+ */ >+ protected IWorkbenchPart getActivePart() { >+ return fActivePart; >+ } >+ >+ /** >+ * Returns this delegate's action or <code>null</code> if none. >+ * >+ * @return this delegate's action or <code>null</code> if none >+ */ >+ protected IAction getAction() { >+ return fAction; >+ } >+ >+ /** >+ * Returns the window this action is installed in or <code>null</code>. >+ * >+ * @return the window this action is installed in or <code>null</code> >+ */ >+ protected IWorkbenchWindow getWindow() { >+ return fWindow; >+ } >+ >+ /** >+ * Returns the target adapter applicable to the given object or <code>null</code> >+ * if none. >+ * >+ * @param object object to retrieve target adapter for >+ * @return the target adapter applicable to the given object or <code>null</code> >+ * if none >+ */ >+ protected Object getAdapter(Object object) { >+ Object adapter = null; >+ if (isInstanceOfAdapterClass(object)) { >+ adapter = object; >+ } else if (object instanceof IAdaptable) { >+ IAdaptable adaptable = (IAdaptable)object; >+ adapter = adaptable.getAdapter(getAdapterClass()); >+ if (adapter == null) { >+ IAdapterManager adapterManager = Platform.getAdapterManager(); >+ if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { //$NON-NLS-1$ >+ adapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); //$NON-NLS-1$ >+ } >+ } >+ } >+ return adapter; >+ } >+ >+ /** >+ * Returns whether the given object is an instance of the adapter this >+ * action is looking for. >+ * >+ * @param object object >+ * @return whether the given object is an instance of the adapter this >+ * action is looking for >+ */ >+ protected abstract boolean isInstanceOfAdapterClass(Object object); >+ >+ /** >+ * Returns the type of adapter (target) this action works on. >+ * >+ * @return the type of adapter this action works on >+ */ >+ protected abstract Class getAdapterClass(); >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void partBroughtToTop(IWorkbenchPart part) { >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void partClosed(IWorkbenchPart part) { >+ clearPart(part); >+ if (part.equals(fDebugview)) { >+ fDebugview = null; >+ } >+ } >+ >+ /** >+ * Clears reference to active part and adapter when a relevant part >+ * is closed or deactivated. >+ * >+ * @param part workbench part that has been closed or deactivated >+ */ >+ protected void clearPart(IWorkbenchPart part) { >+ if (part.equals(fActivePart)) { >+ fActivePart = null; >+ } >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void partDeactivated(IWorkbenchPart part) { >+ clearPart(part); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void partOpened(IWorkbenchPart part) { >+ if (part.getSite().getId().equals(IDebugUIConstants.ID_DEBUG_VIEW)) { >+ fDebugview = part; >+ } >+ } >+ >+ /** >+ * Returns whether the specific operation is supported. >+ * >+ * @param target the target adapter >+ * @return whether the operation can be performed >+ */ >+ protected abstract boolean canPerformAction(Object target); >+ >+ /** >+ * Returns the selection in the given part, or <code>null</code>. >+ * >+ * @param part workbench part >+ * @return the selection in the given part, or <code>null</code> >+ */ >+ protected ISelection getSelection(IWorkbenchPart part) { >+ if (part != null) { >+ IWorkbenchPartSite site = part.getSite(); >+ if (site != null) { >+ ISelectionProvider provider = site.getSelectionProvider(); >+ if (provider != null) { >+ return provider.getSelection(); >+ } >+ } >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.actions.RetargetAction#update() >+ */ >+ protected void doUpdate() { >+ if (fDebugview == null) { >+ // update based on active part >+ update(fActivePart, fActivePartSelection); >+ } else if (fDebugview.equals(getActivePart())){ >+ // update based on debug view >+ update(fDebugview, fDebugViewSelection); >+ } else { >+ // update active part, then revert to debug view if still disabled >+ update(fActivePart, fActivePartSelection); >+ if (!getAction().isEnabled()) { >+ update(fDebugview, fDebugViewSelection); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) >+ */ >+ public void handleDebugEvents(DebugEvent[] events) { >+ update(); >+ } >+ >+} >Index: ui/org/eclipse/debug/internal/ui/actions/StepOverRetargetAction.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/actions/StepOverRetargetAction.java >diff -N ui/org/eclipse/debug/internal/ui/actions/StepOverRetargetAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/actions/StepOverRetargetAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 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.actions; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.model.IStep; >+ >+public class StepOverRetargetAction extends StepRetargetActon { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.actions.LaunchViewRetargetAction#performAction(java.lang.Object) >+ */ >+ protected void performAction(Object target) throws CoreException { >+ ((IStep)target).stepOver(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.actions.LaunchViewRetargetAction#canPerformAction(java.lang.Object) >+ */ >+ protected boolean canPerformAction(Object target) { >+ return ((IStep)target).canStepOver(); >+ } >+ >+} >Index: ui/org/eclipse/debug/internal/ui/actions/StepRetargetActon.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/actions/StepRetargetActon.java >diff -N ui/org/eclipse/debug/internal/ui/actions/StepRetargetActon.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/actions/StepRetargetActon.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 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.actions; >+ >+import org.eclipse.debug.core.model.IStep; >+ >+/** >+ * Common function for retargettable step actions. >+ * >+ * @since 3.1 >+ */ >+public abstract class StepRetargetActon extends LaunchViewRetargetAction { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.actions.RetargetAction#isInstanceOfAdapterClass(java.lang.Object) >+ */ >+ protected boolean isInstanceOfAdapterClass(Object object) { >+ return object instanceof IStep; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.actions.RetargetAction#getAdapterClass() >+ */ >+ protected Class getAdapterClass() { >+ return IStep.class; >+ } >+ >+}
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 80323
: 20531