1 19 20 package org.netbeans.editor; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.util.Iterator ; 25 import javax.swing.event.ChangeEvent ; 26 import javax.swing.text.JTextComponent ; 27 import javax.swing.event.ChangeListener ; 28 import javax.swing.event.EventListenerList ; 29 import javax.swing.text.Document ; 30 import org.netbeans.modules.editor.lib2.DocumentsRegistry; 31 import org.openide.util.WeakListeners; 32 33 43 public class Registry { 44 45 private static final EventListenerList listenerList 46 = new EventListenerList (); 47 48 private static final PropertyChangeListener PCL = new PropertyChangeListener () { 49 public void propertyChange(PropertyChangeEvent pce) { 50 ChangeListener [] listeners 51 = (ChangeListener [])listenerList.getListeners(ChangeListener .class); 52 ChangeEvent evt = new ChangeEvent (Registry.class); 53 for (int i = 0; i < listeners.length; i++) { 54 listeners[i].stateChanged(evt); 55 } 56 } 57 }; 58 59 static { 60 DocumentsRegistry.addPropertyChangeListener(PCL); 61 } 62 63 69 public static void addChangeListener(ChangeListener l) { 70 listenerList.add(ChangeListener .class, WeakListeners.change(l, null)); 71 } 72 73 78 public static void removeChangeListener(ChangeListener l) { 79 } 81 82 86 public static int getID(BaseDocument doc) { 87 return DocumentsRegistry.getID(doc); 88 } 89 90 94 public static int getID(JTextComponent c) { 95 return DocumentsRegistry.getID(c); 96 } 97 98 104 public static BaseDocument getDocument(int docID) { 105 Document doc = DocumentsRegistry.getDocument(docID); 107 return doc instanceof BaseDocument ? (BaseDocument) doc : null; 108 } 109 110 116 public static JTextComponent getComponent(int compID) { 117 return DocumentsRegistry.getComponent(compID); 118 } 119 120 124 public static int addDocument(BaseDocument doc) { 125 return DocumentsRegistry.addDocument(doc); 126 } 127 128 133 public static synchronized int addComponent(JTextComponent c) { 134 return DocumentsRegistry.addComponent(c); 135 } 136 137 143 public static synchronized int removeComponent(JTextComponent c) { 144 return DocumentsRegistry.removeComponent(c); 145 } 146 147 150 public static void activate(JTextComponent c) { 151 DocumentsRegistry.activate(c); 152 } 153 154 159 public static void activate(BaseDocument doc) { 160 DocumentsRegistry.activate(doc); 161 } 162 163 public static synchronized BaseDocument getMostActiveDocument() { 164 Document doc = DocumentsRegistry.getMostActiveDocument(); 166 return doc instanceof BaseDocument ? (BaseDocument) doc : null; 167 } 168 169 public static synchronized BaseDocument getLeastActiveDocument() { 170 Document doc = DocumentsRegistry.getLeastActiveDocument(); 172 return doc instanceof BaseDocument ? (BaseDocument) doc : null; 173 } 174 175 public static BaseDocument getLessActiveDocument(BaseDocument doc) { 176 Document doc2 = DocumentsRegistry.getLessActiveDocument(doc); 178 return doc2 instanceof BaseDocument ? (BaseDocument) doc2 : null; 179 } 180 181 public static synchronized BaseDocument getLessActiveDocument(int docID) { 182 Document doc2 = DocumentsRegistry.getLessActiveDocument(docID); 184 return doc2 instanceof BaseDocument ? (BaseDocument) doc2 : null; 185 } 186 187 public static BaseDocument getMoreActiveDocument(BaseDocument doc) { 188 Document doc2 = DocumentsRegistry.getMoreActiveDocument(doc); 190 return doc2 instanceof BaseDocument ? (BaseDocument) doc2 : null; 191 } 192 193 public static synchronized BaseDocument getMoreActiveDocument(int docID) { 194 Document doc2 = DocumentsRegistry.getMoreActiveDocument(docID); 196 return doc2 instanceof BaseDocument ? (BaseDocument) doc2 : null; 197 } 198 199 204 public static synchronized Iterator getDocumentIterator() { 205 return DocumentsRegistry.getDocumentIterator(); 207 } 208 209 public static synchronized JTextComponent getMostActiveComponent() { 210 return DocumentsRegistry.getMostActiveComponent(); 211 } 212 213 public static synchronized JTextComponent getLeastActiveComponent() { 214 return DocumentsRegistry.getLeastActiveComponent(); 215 } 216 217 public static JTextComponent getLessActiveComponent(JTextComponent c) { 218 return DocumentsRegistry.getLessActiveComponent(c); 219 } 220 221 public static synchronized JTextComponent getLessActiveComponent(int compID) { 222 return DocumentsRegistry.getLessActiveComponent(compID); 223 } 224 225 public static JTextComponent getMoreActiveComponent(JTextComponent c) { 226 return DocumentsRegistry.getMoreActiveComponent(c); 227 } 228 229 public static synchronized JTextComponent getMoreActiveComponent(int compID) { 230 return DocumentsRegistry.getMoreActiveComponent(compID); 231 } 232 233 236 public static synchronized Iterator getComponentIterator() { 237 return DocumentsRegistry.getComponentIterator(); 238 } 239 240 241 public static synchronized String registryToString() { 242 return DocumentsRegistry.registryToString(); 243 } 244 } 245 | Popular Tags |