diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java')
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java index e00359fbd2f..ee1f41b6568 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java @@ -12,7 +12,7 @@ * Freescale Semiconductor - Initial API and implementation * Ericsson - Updated to latest platform code *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.core.runtime.CoreException; @@ -39,20 +39,20 @@ import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkbenchWindow; - + /** * A move to line action that can be contributed to a an editor. The action * will perform the "move to line" operation for editors that provide * an appropriate <code>IMoveToLineTarget</code> adapter. */ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - + private IWorkbenchPart fActivePart = null; private IMoveToLineTarget fPartTarget = null; private IAction fAction = null; private DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; - + class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { @@ -60,8 +60,8 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { - fTargetElement = (ISuspendResume) - DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); + fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), + ISuspendResume.class); } } update(); @@ -71,19 +71,21 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void debugContextChanged(DebugContextEvent event) { contextActivated(event.getContext()); } - - } - + + } + /*(non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#dispose() */ @Override public void dispose() { - DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener); + DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()) + .removeDebugContextListener(fContextListener); fActivePart = null; fPartTarget = null; - + } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @@ -91,12 +93,16 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void run(IAction action) { if (fPartTarget != null && fTargetElement != null) { try { - fPartTarget.moveToLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement); + fPartTarget.moveToLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), + fTargetElement); } catch (CoreException e) { - ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "MoveToLineActionDelegate.1" ), ActionMessages.getString( "MoveToLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ + ErrorDialog.openError(fActivePart.getSite().getWorkbenchWindow().getShell(), + ActionMessages.getString("MoveToLineActionDelegate.1"), //$NON-NLS-1$ + ActionMessages.getString("MoveToLineActionDelegate.2"), e.getStatus()); //$NON-NLS-1$ } } } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @@ -105,7 +111,7 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD this.fAction = action; update(); } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ @@ -120,26 +126,28 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD if (fPartTarget != null && fTargetElement != null) { IWorkbenchPartSite site = fActivePart.getSite(); if (site != null) { - ISelectionProvider selectionProvider = site.getSelectionProvider(); - if (selectionProvider != null) { - ISelection selection = selectionProvider.getSelection(); - enabled = fTargetElement.isSuspended() && fPartTarget.canMoveToLine(fActivePart, selection, fTargetElement); - } + ISelectionProvider selectionProvider = site.getSelectionProvider(); + if (selectionProvider != null) { + ISelection selection = selectionProvider.getSelection(); + enabled = fTargetElement.isSuspended() + && fPartTarget.canMoveToLine(fActivePart, selection, fTargetElement); + } } } - fAction.setEnabled(enabled); + fAction.setEnabled(enabled); } }; CDebugUIPlugin.getStandardDisplay().asyncExec(r); } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ @Override public void init(IAction action) { - this.fAction = action; + this.fAction = action; } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ @@ -147,15 +155,16 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void runWithEvent(IAction action, Event event) { run(action); } + /* (non-Javadoc) * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) */ @Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { init(action); - bindTo(targetEditor); + bindTo(targetEditor); } - + /* (non-Javadoc) * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @@ -163,16 +172,17 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void init(IViewPart view) { bindTo(view); } - + /** * Binds this action to operate on the given part's IMoveToLineTarget adapter. - * + * * @param part */ private void bindTo(IWorkbenchPart part) { IDebugContextManager manager = DebugUITools.getDebugContextManager(); if (fActivePart != null && !fActivePart.equals(part)) { - manager.getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener); + manager.getContextService(fActivePart.getSite().getWorkbenchWindow()) + .removeDebugContextListener(fContextListener); } fPartTarget = null; fActivePart = part; @@ -180,17 +190,18 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow(); IDebugContextService service = manager.getContextService(workbenchWindow); service.addDebugContextListener(fContextListener); - fPartTarget = part.getAdapter(IMoveToLineTarget.class); + fPartTarget = part.getAdapter(IMoveToLineTarget.class); if (fPartTarget == null) { IAdapterManager adapterManager = Platform.getAdapterManager(); // TODO: we could restrict loading to cases when the debugging context is on if (adapterManager.hasAdapter(part, IMoveToLineTarget.class.getName())) { - fPartTarget = (IMoveToLineTarget) adapterManager.loadAdapter(part, IMoveToLineTarget.class.getName()); + fPartTarget = (IMoveToLineTarget) adapterManager.loadAdapter(part, + IMoveToLineTarget.class.getName()); } } ISelection activeContext = service.getActiveContext(); fContextListener.contextActivated(activeContext); } - update(); + update(); } } |