summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-05-22 05:16:00 -0400
committerMickael Istria2018-05-22 08:50:24 -0400
commit1e43b3ba58740f78bbd54f9894dec1d7821c8ac3 (patch)
tree091d2fe4adafd3b02311909da730da4a38e3a8ec
parent30061a13a03c470c959f108a39b9d4f9d4ad01c0 (diff)
downloadeclipse.platform.text-1e43b3ba58740f78bbd54f9894dec1d7821c8ac3.tar.gz
eclipse.platform.text-1e43b3ba58740f78bbd54f9894dec1d7821c8ac3.tar.xz
eclipse.platform.text-1e43b3ba58740f78bbd54f9894dec1d7821c8ac3.zip
StyledText is resized Change-Id: Ib97f2f6ca0f03c50259686ef674eefa9df710330 Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java
index f5c43be38..6ef638b9e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java
@@ -23,6 +23,8 @@ import java.util.function.Consumer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
@@ -126,17 +128,17 @@ public class InlinedAnnotationSupport {
* Class to track start/end offset of visible lines.
*
*/
- private class VisibleLines implements IViewportListener, IDocumentListener {
+ private class VisibleLines implements IViewportListener, IDocumentListener, ControlListener {
private int startOffset;
private Integer endOffset;
public VisibleLines() {
+ install();
fViewer.getTextWidget().getDisplay().asyncExec(() -> {
compute();
});
- fViewer.getDocument().addDocumentListener(this);
}
@Override
@@ -154,6 +156,16 @@ public class InlinedAnnotationSupport {
// Do nothing
}
+ @Override
+ public void controlMoved(ControlEvent e) {
+ // Do nothing
+ }
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ compute();
+ }
+
@SuppressWarnings("boxing")
private void compute() {
startOffset= getInclusiveTopIndexStartOffset();
@@ -225,10 +237,22 @@ public class InlinedAnnotationSupport {
* Uninstall visible lines
*/
void uninstall() {
- if (fViewer != null && fViewer.getDocument() != null) {
- fViewer.getDocument().removeDocumentListener(this);
+ if (fViewer != null) {
+ fViewer.removeViewportListener(this);
+ if (fViewer.getDocument() != null) {
+ fViewer.getDocument().removeDocumentListener(this);
+ }
+ if (fViewer.getTextWidget() != null) {
+ fViewer.getTextWidget().removeControlListener(this);
+ }
}
}
+
+ void install() {
+ fViewer.addViewportListener(this);
+ fViewer.getDocument().addDocumentListener(this);
+ fViewer.getTextWidget().addControlListener(this);
+ }
}
private class MouseTracker implements MouseMoveListener, MouseListener {
@@ -329,7 +353,6 @@ public class InlinedAnnotationSupport {
((ITextViewerExtension4) fViewer).addTextPresentationListener(updateStylesWidth);
}
visibleLines= new VisibleLines();
- fViewer.addViewportListener(visibleLines);
text.addMouseListener(fMouseTracker);
text.addMouseMoveListener(fMouseTracker);
setColor(text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
@@ -365,7 +388,6 @@ public class InlinedAnnotationSupport {
if (fViewer instanceof ITextViewerExtension4) {
((ITextViewerExtension4) fViewer).removeTextPresentationListener(updateStylesWidth);
}
- fViewer.removeViewportListener(visibleLines);
}
if (visibleLines != null) {
visibleLines.uninstall();