+ Added method for adding and removing a new library into/from the library manager. + Added a factory class for creating Library (API object) form LibraryImplementation (SPI object). + Added a support methods for listing installed LibraryTypeProviders. +
++ * A typical usage would be: + *
+ * LibraryManager libraryManager = LibraryManager.getDefault(); + * LibraryImplementation libImpl = LibrariesSupport.getLibraryTypeProvider("j2se").createLibrary(); + * libImpl.setName("FooLibTest"); + * libImpl.setContent ("classpath",listOfResources); + * libraryManager.addLibrary(LibraryFactory.createLibrary(libImpl)); + * + * @param library to be installed, the library has to be created + * with registered {@link org.netbeans.spi.project.libraries.LibraryTypeProvider}. + * @throws IOException when the library cannot be stored + * @throws IllegalArgumentException if the library is not recognized by any + * {@link org.netbeans.spi.project.libraries.LibraryTypeProvider} or the library + * of the same name already exists. + * @since org.netbeans.modules.project.libraries/1 1.14 + */ + public void addLibrary (final Library library) throws IOException, IllegalArgumentException { + assert library != null; + if (LibrariesSupport.getLibraryTypeProvider(library.getType()) == null) { + throw new IllegalArgumentException ("Trying to add a library of unknown type: " + library.getType()); //NOI18N + } + String newLibraryName = library.getName(); + if ( newLibraryName == null || getLibrary(newLibraryName)!= null) { + throw new IllegalArgumentException ("Library hasn't name or the name is already used: " + newLibraryName); //NOI18N + } + final Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template (WriteableLibraryProvider.class)); + final Collection/*