From e5798cdbb55891d77eba8130713e57a359e8b910 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 21 Jan 2005 23:03:46 +0000 Subject: [PATCH] Partial fix for bug 83465: Add "Run to line" and "Resume at line" actions to the context menu of Disassembly view. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 6 ++++ debug/org.eclipse.cdt.debug.ui/plugin.xml | 20 +++++++++++++ .../actions/ResumeAtLineActionDelegate.java | 28 ++++++++++++++++--- .../ui/views/disassembly/DisassemblyView.java | 5 ++++ 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 9bb9ad0a005..95f4a126389 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,9 @@ +2005-01-21 Mikhail Khodjaiants + Partial fix for bug 83465: Add "Run to line" and "Resume at line" actions to the context menu of Disassembly view. + * ResumeAtLineActionDelegate.java + * DisassemblyView.java + * plugin.xml + 2005-01-21 Mikhail Khodjaiants Fix for bug 83437: Loading symbols should be run in the background. * ActionMessages.properties diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 811bdcdc3ac..982600dc833 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -694,6 +694,26 @@ + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java index 6f8bea85d66..cf215722a54 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java @@ -17,7 +17,6 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.model.ISuspendResume; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.actions.IRunToLineTarget; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; @@ -27,6 +26,8 @@ import org.eclipse.ui.IActionDelegate2; import org.eclipse.ui.IEditorActionDelegate; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; @@ -35,9 +36,9 @@ import org.eclipse.ui.IWorkbenchPartSite; * will perform the "resume at line" operation for editors that provide * an appropriate IResumeAtLineTarget adapter. */ -public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActionDelegate2 { +public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IViewActionDelegate, IActionDelegate2 { - private IEditorPart fActivePart = null; + private IWorkbenchPart fActivePart = null; private IResumeAtLineTarget fPartTarget = null; @@ -83,7 +84,7 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio if ( fPartTarget == null ) { IAdapterManager adapterManager = Platform.getAdapterManager(); // TODO: we could restrict loading to cases when the debugging context is on - if ( adapterManager.hasAdapter( targetEditor, IRunToLineTarget.class.getName() ) ) { + if ( adapterManager.hasAdapter( targetEditor, IResumeAtLineTarget.class.getName() ) ) { fPartTarget = (IResumeAtLineTarget)adapterManager.loadAdapter( targetEditor, IResumeAtLineTarget.class.getName() ); } } @@ -158,4 +159,23 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio } fAction.setEnabled( enabled ); } + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + */ + public void init( IViewPart view ) { + fActivePart = view; + if ( view != null ) { + view.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); + fPartTarget = (IResumeAtLineTarget)view.getAdapter( IResumeAtLineTarget.class ); + if ( fPartTarget == null ) { + IAdapterManager adapterManager = Platform.getAdapterManager(); + // TODO: we could restrict loading to cases when the debugging context is on + if ( adapterManager.hasAdapter( view, IResumeAtLineTarget.class.getName() ) ) { + fPartTarget = (IResumeAtLineTarget)adapterManager.loadAdapter( view, IResumeAtLineTarget.class.getName() ); + } + } + } + update(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java index 67895a96695..5baecf86149 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java @@ -860,6 +860,11 @@ public class DisassemblyView extends AbstractDebugEventHandlerView StyledText styledText = getSourceViewer().getTextWidget(); setTextContextMenu( manager.createContextMenu( styledText ) ); styledText.setMenu( getTextContextMenu() ); + + // register the context menu such that other plugins may contribute to it + if ( getSite() != null ) { + getSite().registerContextMenu( getViewContextMenuId(), manager, getSourceViewer() ); + } } private void createRulerContextMenu() {