1 19 package org.openide.text; 20 21 22 36 public abstract class Annotation extends Object { 37 38 public static final String PROP_SHORT_DESCRIPTION = "shortDescription"; 40 41 public static final String PROP_ANNOTATION_TYPE = "annotationType"; 43 48 public static final String PROP_MOVE_TO_FRONT = "moveToFront"; 50 51 private java.beans.PropertyChangeSupport support; 52 53 55 private Annotatable attached; 56 57 68 private boolean inDocument = false; 69 70 public Annotation() { 71 support = new java.beans.PropertyChangeSupport (this); 72 } 73 74 78 public abstract String getAnnotationType(); 79 80 84 public abstract String getShortDescription(); 85 86 88 public final void attach(Annotatable anno) { 89 if (attached != null) { 90 detach(); 91 } 92 93 attached = anno; 94 95 attached.addAnnotation(this); 96 notifyAttached(attached); 97 } 98 99 105 protected void notifyAttached(Annotatable toAnno) { 106 } 107 108 109 public final void detach() { 110 if (attached != null) { 111 attached.removeAnnotation(this); 112 113 Annotatable old = attached; 114 attached = null; 115 notifyDetached(old); 116 } 117 } 118 119 125 protected void notifyDetached(Annotatable fromAnno) { 126 } 127 128 131 final public Annotatable getAttachedAnnotatable() { 132 return attached; 133 } 134 135 137 final public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 138 support.addPropertyChangeListener(l); 139 } 140 141 143 final public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 144 support.removePropertyChangeListener(l); 145 } 146 147 148 final protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 149 support.firePropertyChange(propertyName, oldValue, newValue); 150 } 151 152 157 final public void moveToFront() { 158 support.firePropertyChange(PROP_MOVE_TO_FRONT, null, null); 159 } 160 161 163 final boolean isInDocument() { 164 return inDocument; 165 } 166 167 169 final void setInDocument(boolean b) { 170 inDocument = b; 171 } 172 } 173 | Popular Tags |