1 19 20 package org.netbeans.editor; 21 22 import java.beans.PropertyChangeListener ; 23 import org.netbeans.editor.Mark; 24 import java.beans.PropertyChangeSupport ; 25 import java.awt.Image ; 26 import org.netbeans.editor.AnnotationTypes; 27 import javax.swing.Action ; 28 29 35 public abstract class AnnotationDesc extends Object { 36 37 38 public static final String PROP_SHORT_DESCRIPTION = "shortDescription"; 40 41 public static final String PROP_ANNOTATION_TYPE = "annotationType"; 43 44 public static final String PROP_MOVE_TO_FRONT = "moveToFront"; 46 47 private PropertyChangeSupport support; 48 49 55 private int order; 56 57 58 private static int counter = 0; 59 60 61 private int length; 62 63 67 private Mark mark; 68 69 72 private AnnotationType type = null; 73 74 public AnnotationDesc(int offset, int length) { 75 counter++; 76 this.order = counter; 77 this.length = length; 78 support = new PropertyChangeSupport (this); 79 } 80 81 82 public Coloring getColoring() { 83 if (type == null) updateAnnotationType(); 84 return (type != null) ? type.getColoring() : new Coloring(null, Coloring.FONT_MODE_DEFAULT, null, null, null, null, null); 85 } 86 87 88 public Image getGlyph() { 89 if (type == null) updateAnnotationType(); 90 return (type != null) ? type.getGlyphImage() : null; 91 } 92 93 94 public boolean isDefaultGlyph() { 95 if (type == null) updateAnnotationType(); 96 return (type != null) ? type.isDefaultGlyph() : false; 97 } 98 99 100 public boolean isVisible() { 101 if (type == null) updateAnnotationType(); 102 return (type != null) ? type.isVisible() : false; 103 } 104 105 106 public int getOrderNumber() { 107 return order; 108 } 109 110 111 public Action [] getActions() { 112 if (type == null) updateAnnotationType(); 113 return (type != null) ? type.getActions() : new Action [0]; 114 } 115 116 117 public boolean isWholeLine() { 118 return length == -1; 119 } 120 121 122 public int getLength() { 123 return length; 124 } 125 126 127 void setMark(Mark mark) { 128 this.mark = mark; 129 } 130 131 132 Mark getMark() { 133 return mark; 134 } 135 136 137 public AnnotationType getAnnotationTypeInstance() { 138 return type; 139 } 140 141 142 public abstract String getAnnotationType(); 143 144 145 public abstract String getShortDescription(); 146 147 148 public abstract int getOffset(); 149 150 151 public abstract int getLine(); 152 153 154 157 public void updateAnnotationType() { 158 type = AnnotationTypes.getTypes().getType(getAnnotationType()); 159 } 160 161 163 final public void addPropertyChangeListener(PropertyChangeListener l) { 164 support.addPropertyChangeListener(l); 165 } 166 167 169 final public void removePropertyChangeListener(PropertyChangeListener l) { 170 support.removePropertyChangeListener(l); 171 } 172 173 174 final protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 175 support.firePropertyChange(propertyName, oldValue, newValue); 176 } 177 178 public String toString() { 179 return "Annotation: type='" + getAnnotationType() + "', line=" + getLine() + ", offset=" + getOffset() + ", length=" + length + ", coloring=" + getColoring(); } 183 184 } 185 | Popular Tags |