diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java index 9f4160ea25e..f245814ddb6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java @@ -136,12 +136,7 @@ public abstract class AbstractEditorActionDelegate implements IWorkbenchWindowAc { } - /* (non-Javadoc) - * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) - */ - public void selectionChanged( IWorkbenchPart part, ISelection selection ) - { - } + public abstract void selectionChanged( IWorkbenchPart part, ISelection selection ); /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(IAction) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java index 40c0d2c6861..552c93233a5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java @@ -14,11 +14,14 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.texteditor.ITextEditor; /** @@ -74,6 +77,31 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate } } + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) + */ + public void selectionChanged( IWorkbenchPart part, ISelection selection ) + { + IDebugTarget target = null; + if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) + { + if ( selection != null && selection instanceof IStructuredSelection ) + { + Object element = ((IStructuredSelection)selection).getFirstElement(); + if ( element != null && element instanceof IDebugElement ) + { + IDebugTarget target1 = ((IDebugElement)element).getDebugTarget(); + if ( target1 != null && target1 instanceof IRunToLine ) + { + target = target1; + } + } + } + setDebugTarget( target ); + update(); + } + } + protected void runToLine( IResource resource, int lineNumber ) { if ( !((IRunToLine)getDebugTarget()).canRunToLine( resource, lineNumber ) )