1 19 package org.netbeans.api.retouche.source; 20 21 import org.openide.util.Lookup; 22 import org.openide.util.LookupEvent; 23 import org.openide.util.LookupListener; 24 25 34 public final class SourceTaskFactoryManager { 35 36 private static SourceTaskFactoryManager INSTANCE; 37 38 public static synchronized void register() { 39 INSTANCE = new SourceTaskFactoryManager(); 40 } 41 42 private Lookup.Result<SourceTaskFactory> factories; 43 44 45 private SourceTaskFactoryManager() { 46 factories = Lookup.getDefault().lookupResult(SourceTaskFactory.class); 47 factories.addLookupListener(new LookupListener() { 48 public void resultChanged(LookupEvent ev) { 49 update(); 50 } 51 }); 52 53 update(); 54 } 55 56 private void update() { 57 for (SourceTaskFactory f : factories.allInstances()) { 58 ACCESSOR.fireChangeEvent(f); 59 } 60 } 61 62 public static interface Accessor { 63 public abstract void fireChangeEvent(SourceTaskFactory f); 64 } 65 66 public static Accessor ACCESSOR; 67 68 } 69 | Popular Tags |