1 19 20 package org.netbeans.modules.java.j2seplatform.libraries; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeSupport ; 24 import java.io.IOException ; 25 import java.util.ArrayList ; 26 import java.util.Collection ; 27 import org.netbeans.spi.project.libraries.LibraryImplementation; 28 import org.openide.util.Lookup; 29 30 35 public class LibraryProviderImpl implements org.netbeans.spi.project.libraries.LibraryProvider { 36 37 private ArrayList libs = new ArrayList (); 38 private PropertyChangeSupport support; 39 40 private static final LibraryProviderImpl DEFAULT = new LibraryProviderImpl(); 41 42 public static LibraryProviderImpl getDefault() { 43 assert DEFAULT != null; 44 return DEFAULT; 45 } 46 47 private LibraryProviderImpl() { 48 support = new PropertyChangeSupport (this); 49 } 50 51 public void addLibrary(LibraryImplementation library) throws IOException { 52 libs.add(library); 53 fireChange(); 54 } 55 56 public void addPropertyChangeListener(PropertyChangeListener listener) { 57 support.addPropertyChangeListener(listener); 58 } 59 60 public LibraryImplementation[] getLibraries() { 61 return (LibraryImplementation[])libs.toArray(new LibraryImplementation[libs.size()]); 62 } 63 64 public void init() throws IOException { 65 } 66 67 public void removeLibrary(LibraryImplementation library) throws IOException { 68 boolean res = libs.remove(library); 69 assert res : "Removing library which is not in this provider "+library; 70 fireChange(); 71 } 72 73 public void removePropertyChangeListener(PropertyChangeListener listener) { 74 support.removePropertyChangeListener(listener); 75 } 76 77 private void fireChange() { 78 support.firePropertyChange("xxx", null, null); 79 } 80 81 } 82 | Popular Tags |