diff options
author | Mikhail Khodjaiants | 2005-01-18 23:24:45 +0000 |
---|---|---|
committer | Mikhail Khodjaiants | 2005-01-18 23:24:45 +0000 |
commit | 3d4951f408418d3d64c9807914fb259f218951a5 (patch) | |
tree | e1155301554533ad186e58f44324a0920606cfc4 | |
parent | 03cba52fca3e75aedf632456ceafaf5c71d5ad3e (diff) | |
download | org.eclipse.cdt-3d4951f408418d3d64c9807914fb259f218951a5.tar.gz org.eclipse.cdt-3d4951f408418d3d64c9807914fb259f218951a5.tar.xz org.eclipse.cdt-3d4951f408418d3d64c9807914fb259f218951a5.zip |
Fix for bug 82800: Make "Resume At Line" action retargettable.
14 files changed, 886 insertions, 589 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index e9fa9fefc60..1234dcff4ad 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,19 @@ +2005-01-18 Mikhail Khodjaiants
+ Fix for bug 82800: Make "Resume At Line" action retargettable.
+ * plugin.xml
+ * CDebugImages.java
+ * EvaluationContextManager.java: new
+ * ActionMessages.properties
+ * IResumeAtLineTarget.java: new
+ * ResumeAtLineActionDelegate.java
+ * ResumeAtLineAdapter.java: new
+ * RetargetAction.java: new
+ * RetargetResumeAtLineAction.java: new
+ * RetargettableActionAdapterFactory.java
+ * CDebugUIPlugin.java
+ * JumpToLineActionDelegate.java: removed
+ * RunToLineActionDelegate.java: removed
+
2005-01-12 Mikhail Khodjaiants
Bug 73168: Use memory view provided by Eclipse platform in CDT.
Removed the old memory view.
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index e738120b450..811bdcdc3ac 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -130,9 +130,9 @@ id="org.eclipse.ui.run"> </menu> <action - id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate" + id="org.eclipse.cdt.debug.ui.actions.ResumeAtLine" hoverIcon="icons/full/clcl16/jump_co.gif" - class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate" + class="org.eclipse.cdt.debug.internal.ui.actions.RetargetResumeAtLineAction" disabledIcon="icons/full/dlcl16/jump_co.gif" enablesFor="1" icon="icons/full/elcl16/jump_co.gif" @@ -256,6 +256,14 @@ <viewerContribution targetID="#CEditorContext" id="org.eclipse.cdt.debug.ui.CEditorPopupActions"> + <visibility> + <and> + <systemProperty + value="true" + name="org.eclipse.cdt.debug.ui.debuggerActive"/> + <objectClass name="org.eclipse.jface.text.ITextSelection"/> + </and> + </visibility> <action label="%AddExpressionAction.label" icon="icons/full/etool16/watch_exp.gif" @@ -268,31 +276,18 @@ label="%JumpToLineAction.label" icon="icons/full/clcl16/jump_co.gif" helpContextId="jump_to_line_action_context" - class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate" + class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate" menubarPath="additions" enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"> - <enablement> - <pluginState - value="activated" - id="org.eclipse.cdt.debug.ui"> - </pluginState> - </enablement> </action> <action - label="%RunToLineAction.label" - icon="icons/full/clcl16/runtoline_co.gif" helpContextId="run_to_line_action_context" - class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate" + label="%RunToLineAction.label" + definitionId="org.eclipse.debug.ui.commands.RunToLine" + class="org.eclipse.debug.ui.actions.RunToLineActionDelegate" menubarPath="additions" - enablesFor="1" - id="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate"> - <enablement> - <pluginState - value="activated" - id="org.eclipse.cdt.debug.ui"> - </pluginState> - </enablement> + id="org.eclipse.cdt.debug.ui.actions.popup.RunToLine"> </action> </viewerContribution> <objectContribution @@ -349,6 +344,14 @@ <viewerContribution targetID="#ASMEditorContext" id="org.eclipse.cdt.debug.ui.AsmEditorPopupActions"> + <visibility> + <and> + <objectClass name="org.eclipse.jface.text.ITextSelection"/> + <systemProperty + value="true" + name="org.eclipse.cdt.debug.ui.debuggerActive"/> + </and> + </visibility> <action label="%AddExpressionAction.label" icon="icons/full/etool16/watch_exp.gif" @@ -361,31 +364,18 @@ label="%JumpToLineAction.label" icon="icons/full/clcl16/jump_co.gif" helpContextId="jump_to_line_action_context" - class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate" + class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate" menubarPath="additions" enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"> - <enablement> - <pluginState - value="activated" - id="org.eclipse.cdt.debug.ui"> - </pluginState> - </enablement> </action> <action - label="%RunToLineAction.label" - icon="icons/full/clcl16/runtoline_co.gif" helpContextId="run_to_line_action_context" - class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate" + label="%RunToLineAction.label" + definitionId="org.eclipse.debug.ui.commands.RunToLine" + class="org.eclipse.debug.ui.actions.RunToLineActionDelegate" menubarPath="additions" - enablesFor="1" - id="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate"> - <enablement> - <pluginState - value="activated" - id="org.eclipse.cdt.debug.ui"> - </pluginState> - </enablement> + id="org.eclipse.cdt.debug.ui.actions.popup.RunToLine"> </action> </viewerContribution>
<objectContribution @@ -1093,6 +1083,7 @@ <adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"> </adapter> + <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/> </factory> <factory class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory" @@ -1103,6 +1094,7 @@ <adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"> </adapter> + <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/> </factory> <factory class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory" @@ -1113,6 +1105,7 @@ <adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"> </adapter> + <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/> </factory> <factory class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory" diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index d20faf205a6..01fc51c3f8e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -111,6 +111,7 @@ public class CDebugImages public static final String IMG_LCL_LOAD_ALL_SYMBOLS = NAME_PREFIX + "load_all_symbols_co.gif"; //$NON-NLS-1$ public static final String IMG_LCL_CAST_TO_TYPE = NAME_PREFIX + "casttotype_co.gif"; //$NON-NLS-1$ public static final String IMG_LCL_DISPLAY_AS_ARRAY = NAME_PREFIX + "showasarray_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_RESUME_AT_LINE = NAME_PREFIX + "jump_co.gif"; //$NON-NLS-1$ public static final String IMG_TOOLS_ADD_DIR_SOURCE_LOCATION = NAME_PREFIX + "adddirsource_wiz.gif"; //$NON-NLS-1$ public static final String IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION = NAME_PREFIX + "addprjsource_wiz.gif"; //$NON-NLS-1$ @@ -127,6 +128,7 @@ public class CDebugImages private static final String T_WIZBAN = "wizban"; //$NON-NLS-1$ private static final String T_LCL = "lcl16"; //$NON-NLS-1$ private static final String T_CLCL = "clcl16"; //$NON-NLS-1$ + private static final String T_DLCL = "dlcl16"; //$NON-NLS-1$ private static final String T_CTOOL = "ctool16"; //$NON-NLS-1$ // private static final String T_CVIEW = "cview16"; //$NON-NLS-1$ // private static final String T_DTOOL = "dtool16"; //$NON-NLS-1$ @@ -174,13 +176,15 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_SIGNAL = createManaged( T_OBJ, IMG_OBJS_SIGNAL ); public static final ImageDescriptor DESC_OBJS_WORKSPACE_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_WORKSPACE_SOURCE_FILE ); public static final ImageDescriptor DESC_OBJS_EXTERNAL_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_EXTERNAL_SOURCE_FILE ); - public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE_LOCATION ); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOLS_ADD_PRJ_SOURCE_LOCATION = createManaged( T_CTOOL, IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOLS_ADD_DIR_SOURCE_LOCATION = createManaged( T_CTOOL, IMG_TOOLS_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$ - public static final ImageDescriptor DESC_LCL_CAST_TO_TYPE = createManaged( T_CLCL, IMG_LCL_CAST_TO_TYPE ); //$NON-NLS-1$ - public static final ImageDescriptor DESC_LCL_DISPLAY_AS_ARRAY = createManaged( T_CLCL, IMG_LCL_DISPLAY_AS_ARRAY ); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE_LOCATION ); + public static final ImageDescriptor DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); + public static final ImageDescriptor DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION ); + public static final ImageDescriptor DESC_TOOLS_ADD_PRJ_SOURCE_LOCATION = createManaged( T_CTOOL, IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION ); + public static final ImageDescriptor DESC_TOOLS_ADD_DIR_SOURCE_LOCATION = createManaged( T_CTOOL, IMG_TOOLS_ADD_DIR_SOURCE_LOCATION ); + public static final ImageDescriptor DESC_LCL_CAST_TO_TYPE = createManaged( T_CLCL, IMG_LCL_CAST_TO_TYPE ); + public static final ImageDescriptor DESC_LCL_DISPLAY_AS_ARRAY = createManaged( T_CLCL, IMG_LCL_DISPLAY_AS_ARRAY ); + public static final ImageDescriptor DESC_LCL_RESUME_AT_LINE = createManaged( T_CLCL, IMG_LCL_RESUME_AT_LINE ); + public static final ImageDescriptor DESC_LCL_RESUME_AT_LINE_DISABLED = createManaged( T_DLCL, IMG_LCL_RESUME_AT_LINE ); /** * Returns the image managed under the given key in this registry. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/EvaluationContextManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/EvaluationContextManager.java new file mode 100644 index 00000000000..1e30ed20c95 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/EvaluationContextManager.java @@ -0,0 +1,228 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.ui; + +import java.util.HashMap; +import java.util.Map; +import org.eclipse.cdt.debug.core.model.ICDebugTarget; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IPageListener; +import org.eclipse.ui.IPartListener2; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWindowListener; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartReference; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * Manages the current evaluation context (stack frame) for evaluation actions. + * In each page, the selection is tracked in each debug view (if any). When a debug + * target selection exists, the "debuggerActive" System property is set to true. + * This property is used to make the "Run To Line" and "Resume At Line" actions + * visible in editors only if there is a running debug session. + */ +public class EvaluationContextManager implements IWindowListener, IPageListener, ISelectionListener, IPartListener2 { + + private final static String DEBUGGER_ACTIVE = CDebugUIPlugin.getUniqueIdentifier() + ".debuggerActive"; //$NON-NLS-1$ + + protected static EvaluationContextManager fgManager; + + private Map fContextsByPage = null; + + protected EvaluationContextManager() { + } + + public static void startup() { + Runnable r = new Runnable() { + + public void run() { + if ( fgManager == null ) { + fgManager = new EvaluationContextManager(); + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); + for( int i = 0; i < windows.length; i++ ) { + fgManager.windowOpened( windows[i] ); + } + workbench.addWindowListener( fgManager ); + } + } + }; + CDebugUIPlugin.getStandardDisplay().asyncExec( r ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) + */ + public void windowActivated( IWorkbenchWindow window ) { + windowOpened( window ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow) + */ + public void windowDeactivated( IWorkbenchWindow window ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow) + */ + public void windowClosed( IWorkbenchWindow window ) { + window.removePageListener( this ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow) + */ + public void windowOpened( IWorkbenchWindow window ) { + IWorkbenchPage[] pages = window.getPages(); + for( int i = 0; i < pages.length; i++ ) { + window.addPageListener( this ); + pageOpened( pages[i] ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPageListener#pageActivated(org.eclipse.ui.IWorkbenchPage) + */ + public void pageActivated( IWorkbenchPage page ) { + pageOpened( page ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPageListener#pageClosed(org.eclipse.ui.IWorkbenchPage) + */ + public void pageClosed( IWorkbenchPage page ) { + page.removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + page.removePartListener( this ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPageListener#pageOpened(org.eclipse.ui.IWorkbenchPage) + */ + public void pageOpened( IWorkbenchPage page ) { + page.addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + page.addPartListener( this ); + IWorkbenchPartReference ref = page.getActivePartReference(); + if ( ref != null ) { + partActivated( ref ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged( IWorkbenchPart part, ISelection selection ) { + IWorkbenchPage page = part.getSite().getPage(); + if ( selection instanceof IStructuredSelection ) { + IStructuredSelection ss = (IStructuredSelection)selection; + if ( ss.size() == 1 ) { + Object element = ss.getFirstElement(); + if ( element instanceof IAdaptable ) { + ICDebugTarget target = (ICDebugTarget)((IAdaptable)element).getAdapter( ICDebugTarget.class ); + if ( target != null ) { + setContext( page, target ); + return; + } + } + } + } + // no context in the given view + removeContext( page ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partActivated( IWorkbenchPartReference partRef ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partBroughtToTop( IWorkbenchPartReference partRef ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partClosed( IWorkbenchPartReference partRef ) { + if ( IDebugUIConstants.ID_DEBUG_VIEW.equals( partRef.getId() ) ) { + removeContext( partRef.getPage() ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partDeactivated( IWorkbenchPartReference partRef ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partOpened( IWorkbenchPartReference partRef ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partHidden( IWorkbenchPartReference partRef ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partVisible( IWorkbenchPartReference partRef ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference) + */ + public void partInputChanged( IWorkbenchPartReference partRef ) { + } + + /** + * Sets the evaluation context for the given page, and notes that + * a valid execution context exists. + * + * @param page + * @param frame + */ + private void setContext( IWorkbenchPage page, ICDebugTarget target ) { + if ( fContextsByPage == null ) { + fContextsByPage = new HashMap(); + } + fContextsByPage.put( page, target ); + System.setProperty( DEBUGGER_ACTIVE, Boolean.TRUE.toString() ); + } + + /** + * Removes an evaluation context for the given page, and determines if + * any valid execution context remain. + * + * @param page + */ + private void removeContext( IWorkbenchPage page ) { + if ( fContextsByPage != null ) { + fContextsByPage.remove( page ); + if ( fContextsByPage.isEmpty() ) { + System.setProperty( DEBUGGER_ACTIVE, Boolean.FALSE.toString() ); + } + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties index ad22a8896f2..b3d99f48e1c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties @@ -46,6 +46,9 @@ ToggleBreakpointRulerAction.Error_1=Error ToggleBreakpointRulerAction.Operation_failed_1=Operation failed CBreakpointPropertiesRulerAction.Breakpoint_Properties=Breakpoint &Properties... ResumeAtLineActionDelegate.Error_1=Error +ResumeAtLineActionDelegate.0=Resume At Li&ne +ResumeAtLineActionDelegate.1=Error +ResumeAtLineActionDelegate.2=Resume at line failed RestoreDefaultTypeActionDelegate.0=Unable to restore the default type. ResumeAtLineActionDelegate.Operation_failed_1=Operation failed. ResumeAtLineActionDelegate.Missing_document=Missing document @@ -85,3 +88,7 @@ AddWatchpointDialog.1=Expression to watch: AddWatchpointDialog.2=Access AddWatchpointDialog.3=Write AddWatchpointDialog.4=Read +ResumeAtLineAdapter.0=Empty editor +ResumeAtLineAdapter.1=Missing document +ResumeAtLineAdapter.2=Empty editor +ResumeAtLineAdapter.3=Operation is not supported. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java new file mode 100644 index 00000000000..92bca8dd226 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java @@ -0,0 +1,43 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; + +/** + * An adapter for a "resume at line" operation. + */ +public interface IResumeAtLineTarget { + /** + * Perform a resume at line operation on the given element that is + * currently selected and suspended in the Debug view. + * + * @param part the part on which the action has been invoked + * @param selection the selection on which the action has been invoked + * @param target suspended element to perform the "resume at line" action on + * @throws CoreException if unable to perform the action + */ + public void resumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException; + + /** + * Returns whether a resume at line operation can be performed on the given + * element that is currently selected and suspended in the Debug view. + * + * @param part the part on which the action has been invoked + * @param selection the selection on which the action has been invoked + * @param target suspended element to perform the "resume at line" action on + * @throws CoreException if unable to perform the action + */ + public boolean canResumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java deleted file mode 100644 index 1297d9cd106..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; - -import org.eclipse.cdt.core.IAddress; -import org.eclipse.cdt.core.resources.FileStorage; -import org.eclipse.cdt.debug.core.model.IJumpToAddress; -import org.eclipse.cdt.debug.core.model.IJumpToLine; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -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.IFileEditorInput; -import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Enter type comment. - * - * @since: Feb 5, 2003 - */ -public class JumpToLineActionDelegate extends AbstractEditorActionDelegate -{ - /** - * Constructor for JumpToLineActionDelegate. - */ - public JumpToLineActionDelegate() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) - */ - public void selectionChanged( IWorkbenchPart part, ISelection selection ) - { - IDebugTarget target = null; - if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) - { - if ( selection instanceof IStructuredSelection ) - { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if ( element != null && element instanceof IDebugElement ) - { - IDebugTarget target1 = ((IDebugElement)element).getDebugTarget(); - if ( target1 != null && - ( target1 instanceof IJumpToLine || target1 instanceof IJumpToAddress ) ) - { - target = target1; - } - } - } - setDebugTarget( target ); - update(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(IAction) - */ - public void run( IAction action ) - { - if ( getTargetPart() != null && getTargetPart() instanceof ITextEditor ) - { - IEditorInput input = ((ITextEditor)getTargetPart()).getEditorInput(); - if ( input != null && input instanceof IFileEditorInput ) - { - IFile file = ((IFileEditorInput)input).getFile(); - if ( file != null ) - { - ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection(); - int lineNumber = selection.getStartLine() + 1; - jumpToLine( file, lineNumber ); - } - } - else if ( input != null && input instanceof IStorageEditorInput ) - { - try - { - IStorage storage = ((IStorageEditorInput)input).getStorage(); - if ( storage instanceof FileStorage ) - { - IPath path = storage.getFullPath(); - if ( path != null ) - { - ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection(); - int lineNumber = selection.getStartLine() + 1; - jumpToLine( path.lastSegment(), lineNumber ); - } - } - } - catch( CoreException e ) - { - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractEditorActionDelegate#initializeDebugTarget() - */ - protected void initializeDebugTarget() - { - setDebugTarget( null ); - IAdaptable context = DebugUITools.getDebugContext(); - if ( context != null && context instanceof IDebugElement ) - { - IDebugTarget target = ((IDebugElement)context).getDebugTarget(); - if ( target != null && - ( target instanceof IJumpToLine || target instanceof IJumpToAddress ) ) - { - setDebugTarget( target ); - } - } - } - - protected void jumpToLine( IFile file, int lineNumber ) - { - IJumpToLine target = (IJumpToLine)getDebugTarget().getAdapter( IJumpToLine.class ); - if ( target != null ) - { - if ( !target.canJumpToLine( file, lineNumber ) ) - { - getTargetPart().getSite().getShell().getDisplay().beep(); - return; - } - try - { - target.jumpToLine( file, lineNumber ); - } - catch( DebugException e ) - { - CDebugUIPlugin.errorDialog( e.getMessage(), e ); - } - } - } - - protected void jumpToLine( String fileName, int lineNumber ) - { - IJumpToLine target = (IJumpToLine)getDebugTarget().getAdapter( IJumpToLine.class ); - if ( target != null ) - { - if ( !target.canJumpToLine( fileName, lineNumber ) ) - { - getTargetPart().getSite().getShell().getDisplay().beep(); - return; - } - try - { - target.jumpToLine( fileName, lineNumber ); - } - catch( DebugException e ) - { - CDebugUIPlugin.errorDialog( e.getMessage(), e ); - } - } - } - - protected void jumpToAddress( IAddress address ) - { - IJumpToAddress target = (IJumpToAddress)getDebugTarget().getAdapter( IJumpToAddress.class ); - if ( target != null ) - { - if ( !target.canJumpToAddress( address ) ) - { - getTargetPart().getSite().getShell().getDisplay().beep(); - return; - } - try - { - target.jumpToAddress( address ); - } - catch( DebugException e ) - { - CDebugUIPlugin.errorDialog( e.getMessage(), e ); - } - } - } -} 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 e75ed8d39cf..6f8bea85d66 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 @@ -1,82 +1,65 @@ /********************************************************************** * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: + * + * Contributors: * QNX Software Systems - Initial API and implementation -***********************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.ui.actions; -import org.eclipse.cdt.core.IAddress; -import org.eclipse.cdt.debug.core.CDIDebugModel; -import org.eclipse.cdt.debug.core.model.IJumpToAddress; -import org.eclipse.cdt.debug.core.model.IJumpToLine; -import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyEditorInput; -import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.cdt.debug.ui.ICDebugUIConstants; +import org.eclipse.cdt.debug.internal.ui.CDebugImages; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.core.runtime.IAdapterManager; +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.text.IDocument; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IEditorInput; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IActionDelegate2; +import org.eclipse.ui.IEditorActionDelegate; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IPartService; import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.IUpdate; - +import org.eclipse.ui.IWorkbenchPartSite; + /** - * Global retargettable "Resume at Line" action. + * A resume at line action that can be contributed to a an editor. The action + * will perform the "resume at line" operation for editors that provide + * an appropriate <code>IResumeAtLineTarget</code> adapter. */ -public class ResumeAtLineActionDelegate implements IWorkbenchWindowActionDelegate, IPartListener, IUpdate { +public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActionDelegate2 { - protected IWorkbenchWindow fWindow = null; - private IWorkbenchPart fActivePart = null; - private IAction fAction = null; - private IDebugElement fTargetElement = null; + private IEditorPart fActivePart = null; - private static final ISelection EMPTY_SELECTION = new EmptySelection(); - - static class EmptySelection implements ISelection { - public boolean isEmpty() { - return true; - } - } + private IResumeAtLineTarget fPartTarget = null; + + private IAction fAction = null; private ISelectionListener fSelectionListener = new DebugSelectionListener(); + protected ISuspendResume fTargetElement = null; + class DebugSelectionListener implements ISelectionListener { + /* (non-Javadoc) * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged( IWorkbenchPart part, ISelection selection ) { - setTargetElement( null ); + fTargetElement = null; if ( selection instanceof IStructuredSelection ) { IStructuredSelection ss = (IStructuredSelection)selection; if ( ss.size() == 1 ) { Object object = ss.getFirstElement(); - if ( object instanceof IDebugElement ) { - setTargetElement( (IDebugElement)object ); + if ( object instanceof ISuspendResume ) { + fTargetElement = (ISuspendResume)object; } } } @@ -84,98 +67,68 @@ public class ResumeAtLineActionDelegate implements IWorkbenchWindowActionDelegat } } - /** - * Returns the current selection in the active part, possibly - * and empty selection, but never <code>null</code>. - * - * @return the selection in the active part, possibly empty + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) */ - private ISelection getTargetSelection() { - if ( fActivePart != null ) { - ISelectionProvider selectionProvider = fActivePart.getSite().getSelectionProvider(); - if ( selectionProvider != null ) { - return selectionProvider.getSelection(); + public void setActiveEditor( IAction action, IEditorPart targetEditor ) { + init( action ); + if ( fActivePart != null && !fActivePart.equals( targetEditor ) ) { + fActivePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); + } + fPartTarget = null; + fActivePart = targetEditor; + if ( targetEditor != null ) { + targetEditor.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); + fPartTarget = (IResumeAtLineTarget)targetEditor.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( targetEditor, IRunToLineTarget.class.getName() ) ) { + fPartTarget = (IResumeAtLineTarget)adapterManager.loadAdapter( targetEditor, IResumeAtLineTarget.class.getName() ); + } } } - return EMPTY_SELECTION; + update(); } /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ - public void dispose() { - fWindow.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); - fWindow.getPartService().removePartListener( this ); - fActivePart = 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 ); - fWindow.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); - IWorkbenchPart part = partService.getActivePart(); - if ( part != null ) { - partActivated( part ); + public void init( IAction action ) { + this.fAction = action; + if ( action != null ) { + action.setText( ActionMessages.getString( "ResumeAtLineActionDelegate.0" ) ); //$NON-NLS-1$ + action.setImageDescriptor( CDebugImages.DESC_LCL_RESUME_AT_LINE ); + action.setDisabledImageDescriptor( CDebugImages.DESC_LCL_RESUME_AT_LINE_DISABLED ); } } /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) - */ - public void partActivated( IWorkbenchPart part ) { - fActivePart = part; - update(); - } - - /* (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); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart) + * @see org.eclipse.ui.IActionDelegate2#dispose() */ - public void partDeactivated( IWorkbenchPart part ) { - clearPart(part); + public void dispose() { + fActivePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); + fActivePart = null; + fPartTarget = null; } /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) + * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ - public void partOpened( IWorkbenchPart part ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - public void update() { - if ( fAction == null ) { - return; - } - fAction.setEnabled( canPerformAction( getTargetSelection() ) ); + public void runWithEvent( IAction action, Event event ) { + run( action ); } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run( IAction action ) { - if ( fTargetElement != null ) { + if ( fPartTarget != null && fTargetElement != null ) { try { - performAction( getTargetSelection() ); - } catch( CoreException e ) { - DebugUIPlugin.errorDialog( fWindow.getShell(), ActionMessages.getString( "ResumeAtLineActionDelegate.Error_1" ), ActionMessages.getString( "ResumeAtLineActionDelegate.Operation_failed_1" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ + fPartTarget.resumeAtLine( fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement ); + } + catch( CoreException e ) { + DebugUIPlugin.errorDialog( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "ResumeAtLineActionDelegate.1" ), ActionMessages.getString( "ResumeAtLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -188,129 +141,21 @@ public class ResumeAtLineActionDelegate implements IWorkbenchWindowActionDelegat update(); } - /** - * 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; - } - } - - protected IDebugElement getTargetElement() { - return this.fTargetElement; - } - - protected void setTargetElement( IDebugElement targetElement ) { - this.fTargetElement = targetElement; - } - - private boolean canPerformAction( ISelection selection ) { - if ( fTargetElement == null || - !fTargetElement.getModelIdentifier().equals( CDIDebugModel.getPluginIdentifier() ) ) - return false; - IDebugTarget debugTarget = fTargetElement.getDebugTarget(); - if ( fActivePart instanceof IEditorPart ) { - IJumpToLine jumpToLine = (IJumpToLine)debugTarget.getAdapter( IJumpToLine.class ); - if ( jumpToLine == null ) - return false; - IEditorPart editorPart = (IEditorPart)fActivePart; - IEditorInput input = editorPart.getEditorInput(); - if ( input == null ) { - return false; - } - if ( !(editorPart instanceof ITextEditor) ) { - return false; - } - ITextEditor textEditor = (ITextEditor)editorPart; - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - return false; - } - String fileName; - try { - fileName = getFileName( input ); - } - catch( CoreException e ) { - return false; - } - ITextSelection textSelection = (ITextSelection)selection; - int lineNumber = textSelection.getStartLine() + 1; - return jumpToLine.canJumpToLine( fileName, lineNumber ); - } - if ( fActivePart instanceof DisassemblyView ) { - IJumpToAddress jumpToAddress = (IJumpToAddress)debugTarget.getAdapter( IJumpToAddress.class ); - if ( jumpToAddress == null ) - return false; - IEditorInput input = ((DisassemblyView)fActivePart).getInput(); - if ( !(input instanceof DisassemblyEditorInput) ) { - return false; - } - ITextSelection textSelection = (ITextSelection)selection; - int lineNumber = textSelection.getStartLine() + 1; - IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); - return jumpToAddress.canJumpToAddress( address ); + protected void update() { + if ( fAction == null ) { + return; } - return false; - } - - private void performAction( ISelection selection ) throws CoreException { - IDebugTarget debugTarget = fTargetElement.getDebugTarget(); - String errorMessage = null; - if ( fActivePart instanceof IEditorPart ) { - IEditorPart editorPart = (IEditorPart)fActivePart; - IEditorInput input = editorPart.getEditorInput(); - if ( input == null ) { - errorMessage = ActionMessages.getString( "ResumeAtLineActionDelegate.Empty_editor_1" ); //$NON-NLS-1$ - } - else { - ITextEditor textEditor = (ITextEditor)editorPart; - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - errorMessage = ActionMessages.getString( "ResumeAtLineActionDelegate.Missing_document" ); //$NON-NLS-1$ - } - else { - String fileName = getFileName( input ); - ITextSelection textSelection = (ITextSelection)selection; - int lineNumber = textSelection.getStartLine() + 1; - IJumpToLine jumpToLine = (IJumpToLine)((IAdaptable)debugTarget).getAdapter( IJumpToLine.class ); - if ( jumpToLine != null ) - jumpToLine.jumpToLine( fileName, lineNumber ); - return; + boolean enabled = false; + 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.canResumeAtLine( fActivePart, selection, fTargetElement ); } } } - else if ( fActivePart instanceof DisassemblyView ) { - IEditorInput input = ((DisassemblyView)fActivePart).getInput(); - if ( !(input instanceof DisassemblyEditorInput) ) { - errorMessage = ActionMessages.getString( "ResumeAtLineActionDelegate.Empty_editor_1" ); //$NON-NLS-1$ - } - else { - ITextSelection textSelection = (ITextSelection)selection; - int lineNumber = textSelection.getStartLine() + 1; - IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); - IJumpToAddress jumpToAddress = (IJumpToAddress)((IAdaptable)debugTarget).getAdapter( IJumpToAddress.class ); - if ( jumpToAddress != null ) - jumpToAddress.jumpToAddress( address ); - return; - } - } - else { - errorMessage = ActionMessages.getString( "ResumeAtLineActionDelegate.Operation_is_not_supported_1" ); //$NON-NLS-1$ - } - throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); - } - - private String getFileName( IEditorInput input ) throws CoreException { - if ( input instanceof IFileEditorInput ) { - return ((IFileEditorInput)input).getFile().getName(); - } - if ( input instanceof IStorageEditorInput ) { - return ((IStorageEditorInput)input).getStorage().getName(); - } - return null; + fAction.setEnabled( enabled ); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java new file mode 100644 index 00000000000..5cdd6643aff --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java @@ -0,0 +1,153 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.debug.core.model.IJumpToAddress; +import org.eclipse.cdt.debug.core.model.IJumpToLine; +import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyEditorInput; +import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.debug.ui.ICDebugUIConstants; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IStorageEditorInput; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * Resume at line target adapter for the CDI debugger + */ +public class ResumeAtLineAdapter implements IResumeAtLineTarget { + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget#resumeAtLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) + */ + public void resumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException { + String errorMessage = null; + if ( part instanceof ITextEditor ) { + ITextEditor textEditor = (ITextEditor)part; + IEditorInput input = textEditor.getEditorInput(); + if ( input == null ) { + errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.0" ); //$NON-NLS-1$ + } + else { + IDocument document = textEditor.getDocumentProvider().getDocument( input ); + if ( document == null ) { + errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.1" ); //$NON-NLS-1$ + } + else { + String fileName = getFileName( input ); + ITextSelection textSelection = (ITextSelection)selection; + int lineNumber = textSelection.getStartLine() + 1; + if ( target instanceof IAdaptable ) { + IJumpToLine jumpToLine = (IJumpToLine)((IAdaptable)target).getAdapter( IJumpToLine.class ); + if ( jumpToLine != null && jumpToLine.canJumpToLine( fileName, lineNumber ) ) { + jumpToLine.jumpToLine( fileName, lineNumber ); + } + } + return; + } + } + } + else if ( part instanceof DisassemblyView ) { + IEditorInput input = ((DisassemblyView)part).getInput(); + if ( !(input instanceof DisassemblyEditorInput) ) { + errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.2" ); //$NON-NLS-1$ + } + else { + ITextSelection textSelection = (ITextSelection)selection; + int lineNumber = textSelection.getStartLine() + 1; + IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); + if ( target instanceof IAdaptable ) { + IJumpToAddress jumpToAddress = (IJumpToAddress)((IAdaptable)target).getAdapter( IJumpToAddress.class ); + if ( jumpToAddress != null && jumpToAddress.canJumpToAddress( address ) ) { + jumpToAddress.jumpToAddress( address ); + } + } + return; + } + } + else { + errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.3" ); //$NON-NLS-1$ + } + throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget#canResumeAtLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) + */ + public boolean canResumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) { + if ( target instanceof IAdaptable ) { + if ( part instanceof IEditorPart ) { + IJumpToLine jumpToLine = (IJumpToLine)((IAdaptable)target).getAdapter( IJumpToLine.class ); + if ( jumpToLine == null ) + return false; + IEditorPart editorPart = (IEditorPart)part; + IEditorInput input = editorPart.getEditorInput(); + if ( input == null ) { + return false; + } + if ( !(editorPart instanceof ITextEditor) ) { + return false; + } + ITextEditor textEditor = (ITextEditor)editorPart; + IDocument document = textEditor.getDocumentProvider().getDocument( input ); + if ( document == null ) { + return false; + } + String fileName; + try { + fileName = getFileName( input ); + } + catch( CoreException e ) { + return false; + } + ITextSelection textSelection = (ITextSelection)selection; + int lineNumber = textSelection.getStartLine() + 1; + return jumpToLine.canJumpToLine( fileName, lineNumber ); + } + if ( part instanceof DisassemblyView ) { + IJumpToAddress jumpToAddress = (IJumpToAddress)((IAdaptable)target).getAdapter( IJumpToAddress.class ); + if ( jumpToAddress == null ) + return false; + IEditorInput input = ((DisassemblyView)part).getInput(); + if ( !(input instanceof DisassemblyEditorInput) ) { + return false; + } + ITextSelection textSelection = (ITextSelection)selection; + int lineNumber = textSelection.getStartLine() + 1; + IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); + return jumpToAddress.canJumpToAddress( address ); + } + } + return false; + } + + private String getFileName( IEditorInput input ) throws CoreException { + if ( input instanceof IFileEditorInput ) { + return ((IFileEditorInput)input).getFile().getName(); + } + if ( input instanceof IStorageEditorInput ) { + return ((IStorageEditorInput)input).getStorage().getName(); + } + return null; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java new file mode 100644 index 00000000000..24d37355f7e --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java @@ -0,0 +1,215 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IAdapterManager; +import org.eclipse.core.runtime.Platform; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +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.ui.IPartListener; +import org.eclipse.ui.IPartService; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.texteditor.IUpdate; + +/** + * Global retargettable debug action. + * + * @since 3.0 + */ +public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, IPartListener, IUpdate { + + protected IWorkbenchWindow fWindow = null; + private IWorkbenchPart fActivePart = null; + private Object fTargetAdapter = null; + private IAction fAction = null; + private static final ISelection EMPTY_SELECTION = new EmptySelection(); + + static class EmptySelection implements ISelection { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelection#isEmpty() + */ + public boolean isEmpty() { + return true; + } + + } + + /** + * Returns the current selection in the active part, possibly + * and empty selection, but never <code>null</code>. + * + * @return the selection in the active part, possibly empty + */ + private ISelection getTargetSelection() { + if (fActivePart != null) { + ISelectionProvider selectionProvider = fActivePart.getSite().getSelectionProvider(); + if (selectionProvider != null) { + return selectionProvider.getSelection(); + } + } + return EMPTY_SELECTION; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + fWindow.getPartService().removePartListener(this); + fActivePart = null; + fTargetAdapter = 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); + } + } + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + if (fTargetAdapter != null) { + try { + performAction(fTargetAdapter, getTargetSelection(), fActivePart); + } catch (CoreException e) { + DebugUIPlugin.errorDialog(fWindow.getShell(), ActionMessages.getString("RetargetAction.2"), ActionMessages.getString("RetargetAction.3"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + } + + /** + * Performs the specific breakpoint toggling. + * + * @param selection selection in the active part + * @param part active part + * @throws CoreException if an exception occurrs + */ + protected abstract void performAction(Object target, ISelection selection, IWorkbenchPart part) 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) { + this.fAction = action; + // if the active part did not provide an adapter, see if the selectoin does + if (fTargetAdapter == null && selection instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) selection; + if (!ss.isEmpty()) { + Object object = ss.getFirstElement(); + if (object instanceof IAdaptable) { + fTargetAdapter = getAdapter((IAdaptable) object); + } + } + } + update(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) + */ + public void partActivated(IWorkbenchPart part) { + fActivePart = part; + fTargetAdapter = getAdapter(part); + update(); + } + + protected Object getAdapter(IAdaptable adaptable) { + Object adapter = adaptable.getAdapter(getAdapterClass()); + if (adapter == null) { + IAdapterManager adapterManager = Platform.getAdapterManager(); + if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { //$NON-NLS-1$ + fTargetAdapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); //$NON-NLS-1$ + } + } + return adapter; + } + + /** + * 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); + } + + /** + * 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; + fTargetAdapter = 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) { + } + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IUpdate#update() + */ + public void update() { + if (fAction == null) { + return; + } + if (fTargetAdapter != null) { + fAction.setEnabled(canPerformAction(fTargetAdapter, getTargetSelection(), fActivePart)); + } else { + fAction.setEnabled(false); + } + } + + /** + * Returns whether the specific operation is supported. + * + * @param target the target adapter + * @param selection the selection to verify the operation on + * @param part the part the operation has been requested on + * @return whether the operation can be performed + */ + protected abstract boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java new file mode 100644 index 00000000000..785dcb1c3d5 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java @@ -0,0 +1,96 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; + +/** + * Global retargettable resume at line action. + */ +public class RetargetResumeAtLineAction extends RetargetAction { + + private ISelectionListener fSelectionListener = new DebugSelectionListener(); + + private ISuspendResume fTargetElement = null; + + class DebugSelectionListener implements ISelectionListener { + + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged( IWorkbenchPart part, ISelection selection ) { + setTargetElement( null ); + if ( selection instanceof IStructuredSelection ) { + IStructuredSelection ss = (IStructuredSelection)selection; + if ( ss.size() == 1 ) { + Object object = ss.getFirstElement(); + if ( object instanceof ISuspendResume ) { + setTargetElement( (ISuspendResume)object ); + } + } + } + update(); + } + } + + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + fWindow.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init( IWorkbenchWindow window ) { + super.init( window ); + window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) + */ + protected void performAction( Object target, ISelection selection, IWorkbenchPart part ) throws CoreException { + ((IResumeAtLineTarget)target).resumeAtLine( part, selection, getTargetElement() ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#getAdapterClass() + */ + protected Class getAdapterClass() { + return IResumeAtLineTarget.class; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) + */ + protected boolean canPerformAction( Object target, ISelection selection, IWorkbenchPart part ) { + return getTargetElement() != null && ((IResumeAtLineTarget)target).canResumeAtLine( part, selection, getTargetElement() ); + } + + protected ISuspendResume getTargetElement() { + return fTargetElement; + } + + protected void setTargetElement( ISuspendResume targetElement ) { + fTargetElement = targetElement; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java index d331d6471fb..d0b4454bb11 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java @@ -31,6 +31,9 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory { if ( adapterType == IRunToLineTarget.class ) { return new RunToLineAdapter(); } + if ( adapterType == IResumeAtLineTarget.class ) { + return new ResumeAtLineAdapter(); + } return null; } @@ -38,6 +41,6 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory { * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() */ public Class[] getAdapterList() { - return new Class[]{ IRunToLineTarget.class, IToggleBreakpointsTarget.class }; + return new Class[]{ IRunToLineTarget.class, IToggleBreakpointsTarget.class, IResumeAtLineTarget.class }; } } 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 deleted file mode 100644 index 7b55fe63ff9..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; - -import org.eclipse.cdt.debug.core.model.IRunToAddress; -import org.eclipse.cdt.debug.core.model.IRunToLine; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IDebugTarget; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.actions.IRunToLineTarget; -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.IWorkbenchPart; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Run to line action of C editor popup menu. - */ -public class RunToLineActionDelegate extends AbstractEditorActionDelegate { - - IRunToLineTarget fRunToLineTarget; - - /** - * Constructor for RunToLineActionDelegate. - */ - public RunToLineActionDelegate() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(IAction) - */ - public void run( IAction action ) { - if ( getTargetPart() instanceof ITextEditor ) { - ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection(); - if ( getRunToLineTarget() != null ) { - try { - getRunToLineTarget().runToLine( getTargetPart(), selection, getDebugTarget() ); - } - catch( CoreException e ) { - DebugUIPlugin.errorDialog( getTargetPart().getSite().getShell(), ActionMessages.getString( "RunToLineActionDelegate.Error_1" ), ActionMessages.getString( "RunToLineActionDelegate.Operation_failed_1" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractEditorActionDelegate#initializeDebugTarget() - */ - protected void initializeDebugTarget() { - setDebugTarget( null ); - IAdaptable context = DebugUITools.getDebugContext(); - if ( context != null && context instanceof IDebugElement ) { - IDebugTarget target = ((IDebugElement)context).getDebugTarget(); - if ( target != null && (target instanceof IRunToLine || target instanceof IRunToAddress) ) { - setDebugTarget( target ); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, - * ISelection) - */ - public void selectionChanged( IWorkbenchPart part, ISelection selection ) { - IDebugTarget target = null; - if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) { - if ( 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 || target1 instanceof IRunToAddress) ) { - target = target1; - } - } - } - setDebugTarget( target ); - update(); - } - } - - private IRunToLineTarget getRunToLineTarget() { - if ( fRunToLineTarget == null ) { - fRunToLineTarget = new RunToLineAdapter(); - } - return fRunToLineTarget; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index f7a02518f21..907993e704a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.debug.internal.ui.CBreakpointUpdater; import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation; import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry; import org.eclipse.cdt.debug.internal.ui.ColorManager; +import org.eclipse.cdt.debug.internal.ui.EvaluationContextManager; import org.eclipse.cdt.debug.ui.sourcelookup.DefaultSourceLocator; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; @@ -245,6 +246,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { */ public void start( BundleContext context ) throws Exception { super.start( context ); + EvaluationContextManager.startup(); CDebugCorePlugin.getDefault().addCBreakpointListener( CBreakpointUpdater.getInstance() ); } |