diff options
author | Dani Megert | 2003-10-27 15:34:29 +0000 |
---|---|---|
committer | Dani Megert | 2003-10-27 15:34:29 +0000 |
commit | 260f399835ccadc87e04b534caa52a3eec9cc7e4 (patch) | |
tree | dfffa99ae9383e3f31f67a44afb5404b3f406d57 | |
parent | 0ca16a55db531e7fe836106d73d921eeb6ecbe2a (diff) | |
download | eclipse.platform.text-260f399835ccadc87e04b534caa52a3eec9cc7e4.tar.gz eclipse.platform.text-260f399835ccadc87e04b534caa52a3eec9cc7e4.tar.xz eclipse.platform.text-260f399835ccadc87e04b534caa52a3eec9cc7e4.zip |
Implemented feature 45509: Allow to disable icons in vertical ruler
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java | 88 |
1 files changed, 86 insertions, 2 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java index 94ddbecb8ab..9d08f82faee 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java @@ -12,7 +12,9 @@ package org.eclipse.jface.text.source; +import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; @@ -102,10 +104,47 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn { private int fWidth; /** Switch for enabling/disabling the setModel method. */ private boolean fAllowSetModel= true; + /** + * The list of annotation types to be shown in this ruler. + * @since 3.0 + */ + private Set fAnnotationTypes= new HashSet(); + /** + * The annotation access. + * @since 3.0 + */ + private IAnnotationAccess fAnnotationAccess; /** - * Constructs this column with the given width. + * Constructs this column with the given arguments. + * + * @param width the width of the vertical ruler + * @param annotationAccess the annotation access + * @since 3.0 + */ + public AnnotationRulerColumn(IAnnotationModel model, int width, IAnnotationAccess annotationAccess) { + fWidth= width; + fAllowSetModel= false; + fModel= model; + fModel.addAnnotationModelListener(fInternalListener); + fAnnotationAccess= annotationAccess; + } + + /** + * Constructs this column with the given arguments. + * + * @param width the width of the vertical ruler + * @param annotationAccess the annotation access + * @since 3.0 + */ + public AnnotationRulerColumn(int width, IAnnotationAccess annotationAccess) { + fWidth= width; + fAnnotationAccess= annotationAccess; + } + + /** + * Constructs this column with the given arguments. * * @param width the width of the vertical ruler */ @@ -212,6 +251,9 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn { fBuffer.dispose(); fBuffer= null; } + + fAnnotationTypes.clear(); + fAnnotationAccess= null; } /** @@ -330,6 +372,9 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn { while (iter.hasNext()) { Annotation annotation= (Annotation) iter.next(); + if (fAnnotationAccess != null && skip(fAnnotationAccess.getType(annotation))) + continue; + int lay= annotation.getLayer(); maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum if (lay != layer) // wrong layer: skip annotation @@ -408,7 +453,10 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn { while (iter.hasNext()) { Annotation annotation= (Annotation) iter.next(); - + + if (fAnnotationAccess != null && skip(fAnnotationAccess.getType(annotation))) + continue; + int lay= annotation.getLayer(); maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum if (lay != layer) // wrong layer: skip annotation @@ -513,4 +561,40 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn { protected IAnnotationModel getModel() { return fModel; } + + /** + * Adds the given annotation type to this annotation ruler column. Starting + * with this call, annotations of the given type are shown in this annotation + * ruler column. + * + * @param annotationType the annotation type + * @since 3.0 + */ + public void addAnnotationType(Object annotationType) { + fAnnotationTypes.add(annotationType); + } + + /** + * Removes the given annotation type from this annotation ruler column. + * Annotations of the given type are no longer shown in this annotation + * ruler column. + * + * @param annotationType the annotation type + * @since 3.0 + */ + public void removeAnnotationType(Object annotationType) { + fAnnotationTypes.remove(annotationType); + } + + /** + * Returns whether annotation of the given annotation type should be skipped + * by the drawing routine. + * + * @param annotationType the annotation type + * @return <code>true</code> if annotation of the given type should be skipped + * @since 3.0 + */ + private boolean skip(Object annotationType) { + return !fAnnotationTypes.contains(annotationType); + } } |