Lines 7-20
Link Here
|
7 |
* http://www.sun.com/ |
7 |
* http://www.sun.com/ |
8 |
* |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
12 |
*/ |
12 |
*/ |
13 |
|
13 |
|
14 |
package org.netbeans.api.project.libraries; |
14 |
package org.netbeans.api.project.libraries; |
15 |
|
15 |
|
16 |
|
16 |
|
|
|
17 |
import java.io.IOException; |
17 |
import org.netbeans.api.project.libraries.Library; |
18 |
import org.netbeans.api.project.libraries.Library; |
|
|
19 |
import org.netbeans.modules.project.libraries.WriteableLibraryProvider; |
20 |
import org.netbeans.spi.project.libraries.LibraryFactory; |
18 |
import org.netbeans.spi.project.libraries.LibraryImplementation; |
21 |
import org.netbeans.spi.project.libraries.LibraryImplementation; |
19 |
import org.netbeans.spi.project.libraries.LibraryProvider; |
22 |
import org.netbeans.spi.project.libraries.LibraryProvider; |
20 |
import org.openide.util.Lookup; |
23 |
import org.openide.util.Lookup; |
Lines 98-104
Link Here
|
98 |
this.currentStorages.add (storage); |
101 |
this.currentStorages.add (storage); |
99 |
LibraryImplementation[] impls = storage.getLibraries(); |
102 |
LibraryImplementation[] impls = storage.getLibraries(); |
100 |
for (int i=0; i<impls.length; i++) { |
103 |
for (int i=0; i<impls.length; i++) { |
101 |
l.add(new Library (impls[i])); |
104 |
l.add(LibraryFactory.createLibrary (impls[i])); |
102 |
} |
105 |
} |
103 |
} |
106 |
} |
104 |
for (Iterator it = removed.iterator(); it.hasNext();) { |
107 |
for (Iterator it = removed.iterator(); it.hasNext();) { |
Lines 110-115
Link Here
|
110 |
this.cache = l; |
113 |
this.cache = l; |
111 |
} |
114 |
} |
112 |
return (Library[]) this.cache.toArray(new Library[this.cache.size()]); |
115 |
return (Library[]) this.cache.toArray(new Library[this.cache.size()]); |
|
|
116 |
} |
117 |
|
118 |
|
119 |
/** |
120 |
* Installs new library |
121 |
* @param library to be installed, the library has to be created |
122 |
* with registered {@link org.netbeans.spi.project.libraries.LibraryTypeProvider}. |
123 |
* @throws IOException when library can be stored |
124 |
* @throws IllegalArgumentException if the library is not recognized by any |
125 |
* {@link org.netbeans.spi.project.libraries.LibraryTypeProvider} |
126 |
* @since org.netbeans.modules.project.libraries/1 1.10 |
127 |
*/ |
128 |
public void addLibrary (Library library) throws IOException, IllegalArgumentException { |
129 |
Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template (WriteableLibraryProvider.class)); |
130 |
Collection/*<WriteableLibraryProvider>*/ providers = result.allInstances(); |
131 |
assert providers.size() == 1; |
132 |
((WriteableLibraryProvider)providers.iterator().next()).addLibrary(library.getLibraryImplementation()); |
133 |
} |
134 |
|
135 |
/** |
136 |
* Removes installed library |
137 |
* @param library to be removed. |
138 |
* @throws IOException when library can not be deleted. |
139 |
* @throws IllegalArgumentException when library is not installed in writeable |
140 |
* {@link org.netbeans.spi.project.libraries.LibraryProvider} |
141 |
* @since org.netbeans.modules.project.libraries/1 1.10 |
142 |
*/ |
143 |
public void removeLibrary (Library library) throws IOException, IllegalArgumentException { |
144 |
Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template (WriteableLibraryProvider.class)); |
145 |
Collection/*<WriteableLibraryProvider>*/ providers = result.allInstances(); |
146 |
assert providers.size() == 1; |
147 |
((WriteableLibraryProvider)providers.iterator().next()).removeLibrary(library.getLibraryImplementation()); |
113 |
} |
148 |
} |
114 |
|
149 |
|
115 |
/** |
150 |
/** |