Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2017-12-18 14:22:41 +0000
committerMickael Istria2017-12-21 16:24:59 +0000
commitfbf48eb2c866c228064cd1e70e4164a19449eeac (patch)
treef45d387e6d25ac33c13348aa07449651e2905c1f
parentb70fdcd63eab02c88bac2a93fb8cf73535b6fcbf (diff)
downloadeclipse.platform.text-fbf48eb2c866c228064cd1e70e4164a19449eeac.tar.gz
eclipse.platform.text-fbf48eb2c866c228064cd1e70e4164a19449eeac.tar.xz
eclipse.platform.text-fbf48eb2c866c228064cd1e70e4164a19449eeac.zip
Bug 528851 - [CodeMining] Problem while getting bad AnnotationPainter
(with JDT Editor) Change-Id: I04710e6a04d7bdcdd3a53869d3e0dacd6cbf99b6 Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-rw-r--r--org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/CodeMiningDemo.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java7
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java3
4 files changed, 15 insertions, 7 deletions
diff --git a/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/CodeMiningDemo.java b/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/CodeMiningDemo.java
index 64fb47d11..903a2617b 100644
--- a/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/CodeMiningDemo.java
+++ b/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/CodeMiningDemo.java
@@ -102,6 +102,8 @@ public class CodeMiningDemo {
};
AnnotationPainter painter = new AnnotationPainter(viewer, annotationAccess);
((ITextViewerExtension2) viewer).addPainter(painter);
+ // Register this annotation painter as CodeMining annotation painter.
+ ((ISourceViewerExtension5) viewer).setCodeMiningAnnotationPainter(painter);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java
index 6cfa66cde..2ed4f97bd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java
@@ -26,6 +26,13 @@ import org.eclipse.jface.text.codemining.ICodeMiningProvider;
public interface ISourceViewerExtension5 {
/**
+ * Set the {@link AnnotationPainter} to use to draw code minings.
+ *
+ * @param painter the {@link AnnotationPainter} to use to draw code minings.
+ */
+ void setCodeMiningAnnotationPainter(AnnotationPainter painter);
+
+ /**
* Update the code minings.
*
* Clients and implementors are responsible of calling this method when needed. A typical
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
index 824486d69..93d7db848 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
@@ -40,7 +40,6 @@ import org.eclipse.jface.text.DocumentRewriteSessionType;
import org.eclipse.jface.text.IBlockTextSelection;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
-import org.eclipse.jface.text.IPainter;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.IRewriteTarget;
@@ -1308,12 +1307,9 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
}
@Override
- public void addPainter(IPainter painter) {
- if (painter instanceof AnnotationPainter) {
- fAnnotationPainter= (AnnotationPainter) painter;
- ensureCodeMiningManagerInstalled();
- }
- super.addPainter(painter);
+ public void setCodeMiningAnnotationPainter(AnnotationPainter painter) {
+ fAnnotationPainter= painter;
+ ensureCodeMiningManagerInstalled();
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
index b16c24648..9342f2c6e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
@@ -40,6 +40,7 @@ import org.eclipse.jface.text.source.ICharacterPairMatcher;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.ISourceViewerExtension5;
import org.eclipse.jface.text.source.MatchingCharacterPainter;
@@ -826,6 +827,8 @@ public class SourceViewerDecorationSupport {
((ITextViewerExtension4)fSourceViewer).addTextPresentationListener(fAnnotationPainter);
ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer;
extension.addPainter(fAnnotationPainter);
+ if (fSourceViewer instanceof ISourceViewerExtension5)
+ ((ISourceViewerExtension5) fSourceViewer).setCodeMiningAnnotationPainter(fAnnotationPainter);
}
fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType));
Object decorationType= getAnnotationDecorationType(annotationType);

Back to the top