diff options
author | Darin Wright | 2005-12-05 19:26:43 +0000 |
---|---|---|
committer | Darin Wright | 2005-12-05 19:26:43 +0000 |
commit | dfcd8e860e3c49686c020be8880084074444fba6 (patch) | |
tree | b81cddb6d46afe48aa8a723b165a70df984b11bb /org.eclipse.debug.ui/ui/org/eclipse | |
parent | 956486b72d2f4296032cbe772035b77e46b6c6b1 (diff) | |
download | eclipse.platform.debug-dfcd8e860e3c49686c020be8880084074444fba6.tar.gz eclipse.platform.debug-dfcd8e860e3c49686c020be8880084074444fba6.tar.xz eclipse.platform.debug-dfcd8e860e3c49686c020be8880084074444fba6.zip |
Bug 114521 - Still too hard to customize the coloring of the executing line
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse')
9 files changed, 138 insertions, 37 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java index 23c462a3b..c1699197e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java @@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; +import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IDebugElement; @@ -29,7 +30,9 @@ import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.ui.IDebugEditorPresentation; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.IInstructionPointerPresentation; import org.eclipse.debug.ui.IValueDetailListener; +import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.viewers.IColorProvider; import org.eclipse.jface.viewers.IFontProvider; import org.eclipse.jface.viewers.ILabelProvider; @@ -47,7 +50,7 @@ import org.eclipse.ui.IEditorPart; * asked to render an object from a debug model, this presentation delegates * to the extension registered for that debug model. */ -public class DelegatingModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider { +public class DelegatingModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider, IInstructionPointerPresentation { /** * A mapping of attribute ids to their values @@ -64,10 +67,8 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe */ public void removeAnnotations(IEditorPart editorPart, IThread thread) { IDebugModelPresentation presentation = getConfiguredPresentation(thread); - if (presentation != null) { - if (presentation instanceof IDebugEditorPresentation) { - ((IDebugEditorPresentation)presentation).removeAnnotations(editorPart, thread); - } + if (presentation instanceof IDebugEditorPresentation) { + ((IDebugEditorPresentation)presentation).removeAnnotations(editorPart, thread); } } @@ -76,10 +77,8 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe */ public boolean addAnnotations(IEditorPart editorPart, IStackFrame frame) { IDebugModelPresentation presentation = getConfiguredPresentation(frame); - if (presentation != null) { - if (presentation instanceof IDebugEditorPresentation) { - return((IDebugEditorPresentation)presentation).addAnnotations(editorPart, frame); - } + if (presentation instanceof IDebugEditorPresentation) { + return((IDebugEditorPresentation)presentation).addAnnotations(editorPart, frame); } return false; } @@ -346,4 +345,27 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe } return null; } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getInstructionPointerAnnotation(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame) + */ + public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStackFrame frame) { + IDebugModelPresentation presentation = getConfiguredPresentation(frame); + Annotation annotation = null; + if (presentation instanceof IInstructionPointerPresentation) { + IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; + annotation = pointerPresentation.getInstructionPointerAnnotation(editorPart, frame); + } + if (annotation == null) { + // use default annotation + IThread thread = frame.getThread(); + IStackFrame tos = null; + try { + tos = thread.getTopStackFrame(); + } catch (DebugException de) { + } + annotation = new InstructionPointerAnnotation(frame, frame.equals(tos)); + } + return annotation; + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java index bd52ed7b8..814717eb8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java @@ -26,10 +26,6 @@ public interface IInternalDebugUIConstants { public static final String ID_CONSOLE_FOLDER_VIEW= "org.eclipse.debug.internal.ui.ConsoleFolderView"; //$NON-NLS-1$ public static final String ID_OUTLINE_FOLDER_VIEW= "org.eclipse.debug.internal.ui.OutlineFolderView"; //$NON-NLS-1$ - // annotation types for instruction pointers - public static final String ANN_INSTR_POINTER_CURRENT = "org.eclipse.debug.ui.currentIP"; //$NON-NLS-1$ - public static final String ANN_INSTR_POINTER_SECONDARY = "org.eclipse.debug.ui.secondaryIP"; //$NON-NLS-1$ - // tool images public static final String IMG_LCL_COLLAPSE_ALL = "IMG_LCL_COLLAPSE_ALL"; //$NON-NLS-1$ public static final String IMG_LCL_TERMINATE = "IMG_LCL_TERMINATE"; //$NON-NLS-1$ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java index 1e6a8a242..e7c4c3b9a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java @@ -12,6 +12,7 @@ package org.eclipse.debug.internal.ui; import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.text.source.Annotation; /** @@ -34,7 +35,7 @@ public class InstructionPointerAnnotation extends Annotation { * @param isTopFrame whether the given frame is the top stack frame in its thread */ public InstructionPointerAnnotation(IStackFrame stackFrame, boolean isTopFrame) { - super(isTopFrame ? IInternalDebugUIConstants.ANN_INSTR_POINTER_CURRENT: IInternalDebugUIConstants.ANN_INSTR_POINTER_SECONDARY, + super(isTopFrame ? IDebugUIConstants.ANNOTATION_TYPE_INSTRUCTION_POINTER_CURRENT: IDebugUIConstants.ANNOTATION_TYPE_INSTRUCTION_POINTER_SECONDARY, false, isTopFrame ? DebugUIMessages.InstructionPointerAnnotation_0 : DebugUIMessages.InstructionPointerAnnotation_1); // fStackFrame = stackFrame; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java index 57d5fcc49..629583509 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java @@ -11,6 +11,7 @@ package org.eclipse.debug.internal.ui; +import org.eclipse.jface.text.source.Annotation; import org.eclipse.ui.texteditor.ITextEditor; /** @@ -28,9 +29,9 @@ public class InstructionPointerContext { /** * The vertical ruler annotation for this context. */ - private InstructionPointerAnnotation fAnnotation; + private Annotation fAnnotation; - public InstructionPointerContext(ITextEditor textEditor, InstructionPointerAnnotation annotation) { + public InstructionPointerContext(ITextEditor textEditor, Annotation annotation) { setTextEditor(textEditor); setAnnotation(annotation); } @@ -61,11 +62,11 @@ public class InstructionPointerContext { return fTextEditor; } - private void setAnnotation(InstructionPointerAnnotation annotation) { + private void setAnnotation(Annotation annotation) { fAnnotation = annotation; } - public InstructionPointerAnnotation getAnnotation() { + public Annotation getAnnotation() { return fAnnotation; } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java index 42f8c7759..29cbe612b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java @@ -25,6 +25,7 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; +import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.texteditor.IDocumentProvider; @@ -69,7 +70,7 @@ public class InstructionPointerManager { * Add an instruction pointer annotation in the specified editor for the * specified stack frame. */ - public void addAnnotation(ITextEditor textEditor, IStackFrame stackFrame) { + public void addAnnotation(ITextEditor textEditor, IStackFrame frame, Annotation annotation) { IDocumentProvider docProvider = textEditor.getDocumentProvider(); IEditorInput editorInput = textEditor.getEditorInput(); @@ -78,22 +79,14 @@ public class InstructionPointerManager { if (annModel == null) { return; } - IThread thread = stackFrame.getThread(); - IStackFrame tos = null; - try { - tos = thread.getTopStackFrame(); - } catch (DebugException de) { - } - // Create the annotation object - InstructionPointerAnnotation instPtrAnnotation = new InstructionPointerAnnotation(stackFrame, tos == null || stackFrame.equals(tos)); // Create the Position object that specifies a location for the annotation Position position = null; int charStart = -1; int length = -1; try { - charStart = stackFrame.getCharStart(); - length = stackFrame.getCharEnd() - charStart; + charStart = frame.getCharStart(); + length = frame.getCharEnd() - charStart; } catch (DebugException de) { } if (charStart < 0) { @@ -102,7 +95,7 @@ public class InstructionPointerManager { return; } try { - int lineNumber = stackFrame.getLineNumber() - 1; + int lineNumber = frame.getLineNumber() - 1; IRegion region = doc.getLineInformation(lineNumber); charStart = region.getOffset(); length = region.getLength(); @@ -118,16 +111,17 @@ public class InstructionPointerManager { position = new Position(charStart, length); // Add the annotation at the position to the editor's annotation model. - annModel.removeAnnotation(instPtrAnnotation); - annModel.addAnnotation(instPtrAnnotation, position); + annModel.removeAnnotation(annotation); + annModel.addAnnotation(annotation, position); // Retrieve the list of instruction pointer contexts - IDebugTarget debugTarget = stackFrame.getDebugTarget(); + IDebugTarget debugTarget = frame.getDebugTarget(); Map threadMap = (Map) fDebugTargetMap.get(debugTarget); if (threadMap == null) { threadMap = new HashMap(); fDebugTargetMap.put(debugTarget, threadMap); } + IThread thread = frame.getThread(); List contextList = (List) threadMap.get(thread); if (contextList == null) { contextList = new ArrayList(); @@ -135,7 +129,7 @@ public class InstructionPointerManager { } // Create a context object & add it to the list - InstructionPointerContext context = new InstructionPointerContext(textEditor, instPtrAnnotation); + InstructionPointerContext context = new InstructionPointerContext(textEditor, annotation); contextList.remove(context); contextList.add(context); } @@ -202,7 +196,7 @@ public class InstructionPointerManager { /** * Remove the specified annotation from the specified text editor. */ - private void removeAnnotation(ITextEditor textEditor, InstructionPointerAnnotation annotation) { + private void removeAnnotation(ITextEditor textEditor, Annotation annotation) { IDocumentProvider docProvider = textEditor.getDocumentProvider(); if (docProvider != null) { IAnnotationModel annotationModel = docProvider.getAnnotationModel(textEditor.getEditorInput()); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java index e48037908..9784206f6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java @@ -29,7 +29,9 @@ import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition; import org.eclipse.debug.ui.IDebugEditorPresentation; import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.debug.ui.IInstructionPointerPresentation; import org.eclipse.debug.ui.IValueDetailListener; +import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.viewers.IColorProvider; import org.eclipse.jface.viewers.IFontProvider; @@ -45,7 +47,7 @@ import org.eclipse.ui.IEditorPart; * when it is needed. */ -public class LazyModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider { +public class LazyModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider, IInstructionPointerPresentation { /** * A temporary mapping of attribute ids to their values @@ -377,4 +379,16 @@ public class LazyModelPresentation implements IDebugModelPresentation, IDebugEdi } return null; } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getInstructionPointerAnnotation(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame) + */ + public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStackFrame frame) { + IDebugModelPresentation presentation = getPresentation(); + if (presentation instanceof IInstructionPointerPresentation) { + IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; + return pointerPresentation.getInstructionPointerAnnotation(editorPart, frame); + } + return null; + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java index 52a75c361..3e1daff7d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java @@ -30,14 +30,17 @@ import org.eclipse.debug.internal.ui.views.launch.Decoration; import org.eclipse.debug.internal.ui.views.launch.DecorationManager; import org.eclipse.debug.internal.ui.views.launch.SourceNotFoundEditorInput; import org.eclipse.debug.internal.ui.views.launch.StandardDecoration; +import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugEditorPresentation; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.IInstructionPointerPresentation; import org.eclipse.debug.ui.ISourcePresentation; import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.custom.BusyIndicator; @@ -73,6 +76,11 @@ public class SourceLookupFacility implements IPageListener, IPartListener2, IPro private Map fEditorsByPage; /** + * Used to generate annotations for stack frames + */ + private IInstructionPointerPresentation fPresentation = (IInstructionPointerPresentation) DebugUITools.newDebugModelPresentation(); + + /** * Whether to re-use editors when displaying source. */ private boolean fReuseEditor = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_REUSE_EDITOR); @@ -230,7 +238,8 @@ public class SourceLookupFacility implements IPageListener, IPartListener2, IPro } if (textEditor != null) { positionEditor(textEditor, frame); - InstructionPointerManager.getDefault().addAnnotation(textEditor, frame); + Annotation annotation = fPresentation.getInstructionPointerAnnotation(textEditor, frame); + InstructionPointerManager.getDefault().addAnnotation(textEditor, frame, annotation); } } } @@ -492,5 +501,6 @@ public class SourceLookupFacility implements IPageListener, IPartListener2, IPro protected void dispose() { DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); fEditorsByPage.clear(); + fPresentation.dispose(); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java index 4c062bc38..45fcc4b33 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java @@ -1091,4 +1091,24 @@ public interface IDebugUIConstants { * TODO: new api, needs review */ public static final String PREF_MEMORY_HISTORY_KNOWN_COLOR = PLUGIN_ID + ".MemoryHistoryKnownColor"; //$NON-NLS-1$ + + /** + * Annotation type identifier for default annotation of the current instruction + * pointer (top stack frame in a thread). Value is <code>org.eclipse.debug.ui.currentIP</code>, + * identifying a <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> + * extension. + * + * @since 3.2 + */ + public static final String ANNOTATION_TYPE_INSTRUCTION_POINTER_CURRENT = "org.eclipse.debug.ui.currentIP"; //$NON-NLS-1$ + + /** + * Annotation type identifier for default annotation of secondary instruction pointers + * (non top stack frames). Value is <code>org.eclipse.debug.ui.secondaryIP</code>, + * identifying a <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> + * extension. + * + * @since 3.2 + */ + public static final String ANNOTATION_TYPE_INSTRUCTION_POINTER_SECONDARY = "org.eclipse.debug.ui.secondaryIP"; //$NON-NLS-1$ } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IInstructionPointerPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IInstructionPointerPresentation.java new file mode 100644 index 000000000..beed86e61 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IInstructionPointerPresentation.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 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.ui; + +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.jface.text.source.Annotation; +import org.eclipse.ui.IEditorPart; + +/** + * A debug model presentation may implement this interface to override + * standard annotations used to display instruction pointers for stack frames. + * + * @since 3.2 + */ +public interface IInstructionPointerPresentation extends IDebugModelPresentation { + /** + * Returns an annotation used for the specified stack frame in the specified + * editor, or <code>null</code> if a default annotation should be used. + * This method is called when the debugger has opened an editor to display + * source for the given stack frame. The annotation will be positioned based + * on stack frame line number and character ranges. + * <p> + * By default, the debug platform uses different annotations for top stack + * frames and non-top stack frames in a thread. The default platform annotations + * are contributed as <code>markerAnnotationSpecification</code> extensions with + * the identifiers {@link IDebugUIConstants.ANNOTATION_INSTRUCTION_POINTER_CURRENT} + * and @link {@link IDebugUIConstants.ANNOTAION_INSTRUCTION_POINTER_SECONDARY}. + * </p> + * @param editorPart the editor the debugger has opened + * @param frame the stack frame for which the debugger is displaying + * source + */ + public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStackFrame frame); + +} |