Lines 43-48
Link Here
|
43 |
|
43 |
|
44 |
import java.awt.Dialog; |
44 |
import java.awt.Dialog; |
45 |
import java.awt.Dimension; |
45 |
import java.awt.Dimension; |
|
|
46 |
import java.awt.EventQueue; |
46 |
import java.awt.GridBagConstraints; |
47 |
import java.awt.GridBagConstraints; |
47 |
import java.awt.GridBagLayout; |
48 |
import java.awt.GridBagLayout; |
48 |
import java.awt.Image; |
49 |
import java.awt.Image; |
Lines 54-69
Link Here
|
54 |
import java.beans.PropertyVetoException; |
55 |
import java.beans.PropertyVetoException; |
55 |
import java.beans.VetoableChangeListener; |
56 |
import java.beans.VetoableChangeListener; |
56 |
import java.io.IOException; |
57 |
import java.io.IOException; |
|
|
58 |
import java.net.URL; |
59 |
import java.text.Collator; |
57 |
import java.util.ArrayList; |
60 |
import java.util.ArrayList; |
58 |
import java.util.Collection; |
61 |
import java.util.Collection; |
|
|
62 |
import java.util.Collections; |
63 |
import java.util.Comparator; |
64 |
import java.util.List; |
59 |
import java.util.MissingResourceException; |
65 |
import java.util.MissingResourceException; |
60 |
import java.util.ResourceBundle; |
66 |
import java.util.ResourceBundle; |
61 |
import javax.swing.JComponent; |
67 |
import javax.swing.JComponent; |
62 |
import javax.swing.JPanel; |
68 |
import javax.swing.JPanel; |
63 |
import javax.swing.event.ListDataEvent; |
69 |
import javax.swing.event.ChangeEvent; |
64 |
import javax.swing.event.ListDataListener; |
70 |
import javax.swing.event.ChangeListener; |
65 |
import org.netbeans.modules.project.libraries.LibraryTypeRegistry; |
71 |
import org.netbeans.modules.project.libraries.LibraryTypeRegistry; |
66 |
import org.netbeans.spi.project.libraries.LibraryImplementation; |
72 |
import org.netbeans.spi.project.libraries.LibraryImplementation; |
|
|
73 |
import org.netbeans.spi.project.libraries.LibraryStorageArea; |
67 |
import org.netbeans.spi.project.libraries.LibraryTypeProvider; |
74 |
import org.netbeans.spi.project.libraries.LibraryTypeProvider; |
68 |
import org.openide.DialogDescriptor; |
75 |
import org.openide.DialogDescriptor; |
69 |
import org.openide.DialogDisplayer; |
76 |
import org.openide.DialogDisplayer; |
Lines 80-117
Link Here
|
80 |
import org.openide.nodes.NodeOp; |
87 |
import org.openide.nodes.NodeOp; |
81 |
import org.openide.util.HelpCtx; |
88 |
import org.openide.util.HelpCtx; |
82 |
import org.openide.util.NbBundle; |
89 |
import org.openide.util.NbBundle; |
|
|
90 |
import org.openide.util.Utilities; |
83 |
import org.openide.util.lookup.Lookups; |
91 |
import org.openide.util.lookup.Lookups; |
84 |
|
92 |
|
85 |
/** |
|
|
86 |
* |
87 |
* @author tom |
88 |
*/ |
89 |
public final class LibrariesCustomizer extends JPanel implements ExplorerManager.Provider, HelpCtx.Provider { |
93 |
public final class LibrariesCustomizer extends JPanel implements ExplorerManager.Provider, HelpCtx.Provider { |
90 |
|
94 |
|
91 |
private ExplorerManager manager; |
95 |
private ExplorerManager manager; |
92 |
private LibrariesModel model; |
96 |
private LibrariesModel model; |
93 |
private BeanTreeView libraries; |
97 |
private BeanTreeView libraries; |
|
|
98 |
private LibraryStorageArea libraryStorageArea; |
94 |
|
99 |
|
95 |
/** Creates new form LibrariesCustomizer */ |
100 |
public LibrariesCustomizer (LibraryStorageArea libraryStorageArea) { |
96 |
public LibrariesCustomizer () { |
|
|
97 |
this.model = new LibrariesModel (); |
101 |
this.model = new LibrariesModel (); |
|
|
102 |
this.libraryStorageArea = (libraryStorageArea != null ? libraryStorageArea : LibrariesModel.GLOBAL_AREA); |
98 |
initComponents(); |
103 |
initComponents(); |
99 |
postInitComponents (); |
104 |
postInitComponents (); |
|
|
105 |
expandTree(); |
106 |
} |
107 |
|
108 |
private void expandTree() { |
109 |
// get first library node |
110 |
Node[] n = getExplorerManager().getRootContext().getChildren().getNodes()[0].getChildren().getNodes(); |
111 |
if (n.length != 0) { |
112 |
try { |
113 |
getExplorerManager().setSelectedNodes(new Node[]{n[0]}); |
114 |
} catch (PropertyVetoException ex) { |
115 |
// OK to ignore - it is just selection initialization |
116 |
} |
117 |
} |
118 |
} |
119 |
|
120 |
public void setLibraryStorageArea(LibraryStorageArea libraryStorageArea) { |
121 |
this.libraryStorageArea = (libraryStorageArea != null ? libraryStorageArea : LibrariesModel.GLOBAL_AREA); |
122 |
forceTreeRecreation(); |
123 |
expandTree(); |
124 |
} |
125 |
|
126 |
public LibrariesModel getModel() { |
127 |
return model; |
128 |
} |
129 |
|
130 |
public void hideLibrariesList() { |
131 |
libsPanel.setVisible(false); |
132 |
jLabel2.setVisible(false); |
133 |
createButton.setVisible(false); |
134 |
deleteButton.setVisible(false); |
135 |
} |
136 |
|
137 |
/** |
138 |
* Force nodes recreation after LibrariesModel change. The nodes listen on |
139 |
* model and eventually refresh themselves but usually it is too late. |
140 |
* So forcing recreation makes sure that any subsequent call to |
141 |
* NodeOp.findPath is successful and selects just created library node. |
142 |
*/ |
143 |
public void forceTreeRecreation() { |
144 |
getExplorerManager().setRootContext(buildTree()); |
100 |
} |
145 |
} |
101 |
|
|
|
102 |
|
146 |
|
103 |
public void setSelectedLibrary (LibraryImplementation library) { |
147 |
public void setSelectedLibrary (LibraryImplementation library) { |
104 |
if (library == null) |
148 |
if (library == null) |
105 |
return; |
149 |
return; |
106 |
ExplorerManager manager = this.getExplorerManager(); |
150 |
ExplorerManager currentManager = this.getExplorerManager(); |
107 |
Node root = manager.getRootContext(); |
151 |
Node root = currentManager.getRootContext(); |
108 |
String[] path = new String[2]; |
152 |
String[] path = {library.getType(), library.getName()}; |
109 |
path[0]=library.getType(); |
|
|
110 |
path[1]=library.getName(); |
111 |
try { |
153 |
try { |
112 |
Node node = NodeOp.findPath(root, path); |
154 |
Node node = NodeOp.findPath(root, path); |
113 |
if (node != null) { |
155 |
if (node != null) { |
114 |
manager.setSelectedNodes(new Node[] {node}); |
156 |
currentManager.setSelectedNodes(new Node[] {node}); |
115 |
} |
157 |
} |
116 |
} catch (NodeNotFoundException e) { |
158 |
} catch (NodeNotFoundException e) { |
117 |
//Ignore it |
159 |
//Ignore it |
Lines 135-167
Link Here
|
135 |
} |
177 |
} |
136 |
} |
178 |
} |
137 |
|
179 |
|
138 |
public void cancel () { |
|
|
139 |
this.model.cancel(); |
140 |
} |
141 |
|
142 |
public void addNotify() { |
180 |
public void addNotify() { |
143 |
super.addNotify(); |
181 |
super.addNotify(); |
144 |
expandAllNodes(this.libraries,this.getExplorerManager().getRootContext()); |
182 |
expandAllNodes(this.libraries,this.getExplorerManager().getRootContext()); |
145 |
//Select first library if nothing selected |
183 |
//Select first library if nothing selected |
146 |
if (this.getExplorerManager().getSelectedNodes().length == 0) { |
184 |
if (this.getExplorerManager().getSelectedNodes().length == 0) { |
147 |
Node root = this.getExplorerManager().getRootContext(); |
185 |
SELECTED: for (Node areaNode : getExplorerManager().getRootContext().getChildren().getNodes(true)) { |
148 |
Node[] nodes = root.getChildren().getNodes (true); |
186 |
for (Node typeNode : areaNode.getChildren().getNodes(true)) { |
149 |
for (int i = 0; i< nodes.length; i++) { |
187 |
for (Node libNode : typeNode.getChildren().getNodes(true)) { |
150 |
Node[] lnodes = nodes[i].getChildren().getNodes(true); |
188 |
try { |
151 |
if (lnodes.length > 0) { |
189 |
getExplorerManager().setSelectedNodes(new Node[] {libNode}); |
152 |
try { |
190 |
} catch (PropertyVetoException e) { |
153 |
this.getExplorerManager().setSelectedNodes(new Node[] {lnodes[0]}); |
191 |
//Ignore it |
154 |
} catch (PropertyVetoException e) { |
192 |
} |
155 |
//Ignore it |
193 |
break SELECTED; |
156 |
} |
194 |
} |
157 |
break; |
|
|
158 |
} |
195 |
} |
159 |
} |
196 |
} |
160 |
} |
197 |
} |
161 |
this.libraries.requestFocus(); |
198 |
this.libraries.requestFocus(); |
162 |
} |
199 |
} |
163 |
|
200 |
|
164 |
|
|
|
165 |
public ExplorerManager getExplorerManager () { |
201 |
public ExplorerManager getExplorerManager () { |
166 |
if (this.manager == null) { |
202 |
if (this.manager == null) { |
167 |
this.manager = new ExplorerManager (); |
203 |
this.manager = new ExplorerManager (); |
Lines 187-198
Link Here
|
187 |
} |
223 |
} |
188 |
} |
224 |
} |
189 |
}); |
225 |
}); |
190 |
this.manager.setRootContext (buildTree(this.model)); |
226 |
manager.setRootContext(buildTree()); |
191 |
} |
227 |
} |
192 |
return this.manager; |
228 |
return this.manager; |
193 |
} |
229 |
} |
194 |
|
230 |
|
195 |
|
|
|
196 |
private void postInitComponents () { |
231 |
private void postInitComponents () { |
197 |
this.libraries = new LibrariesView (); |
232 |
this.libraries = new LibrariesView (); |
198 |
GridBagConstraints c = new GridBagConstraints (); |
233 |
GridBagConstraints c = new GridBagConstraints (); |
Lines 217-235
Link Here
|
217 |
}); |
252 |
}); |
218 |
} |
253 |
} |
219 |
|
254 |
|
220 |
|
|
|
221 |
private void nameChanged () { |
255 |
private void nameChanged () { |
222 |
Node[] nodes = this.getExplorerManager().getSelectedNodes(); |
256 |
Node[] nodes = this.getExplorerManager().getSelectedNodes(); |
223 |
if (nodes.length == 1 && (nodes[0] instanceof LibraryNode)) { |
257 |
if (nodes.length == 1) { |
224 |
LibraryNode node = (LibraryNode) nodes[0]; |
258 |
LibraryImplementation lib = nodes[0].getLookup().lookup(LibraryImplementation.class); |
|
|
259 |
if (lib == null) { |
260 |
return; |
261 |
} |
225 |
String newName = this.libraryName.getText(); |
262 |
String newName = this.libraryName.getText(); |
|
|
263 |
if (newName.equals(lib.getName())) { |
264 |
return; |
265 |
} |
226 |
if (newName.length () == 0) { |
266 |
if (newName.length () == 0) { |
227 |
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message ( |
267 |
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message ( |
228 |
NbBundle.getMessage(LibrariesCustomizer.class, "ERR_InvalidName"), |
268 |
NbBundle.getMessage(LibrariesCustomizer.class, "ERR_InvalidName"), |
229 |
NotifyDescriptor.ERROR_MESSAGE)); |
269 |
NotifyDescriptor.ERROR_MESSAGE)); |
230 |
} |
270 |
} else if (isValidName(model, newName, model.getArea(lib))) { |
231 |
else if (isValidName (this.model, newName)) { |
271 |
lib.setName(newName); |
232 |
node.getLibrary().setName(newName); |
|
|
233 |
} |
272 |
} |
234 |
else { |
273 |
else { |
235 |
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message ( |
274 |
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message ( |
Lines 239-245
Link Here
|
239 |
} |
278 |
} |
240 |
} |
279 |
} |
241 |
|
280 |
|
242 |
|
|
|
243 |
private void selectLibrary (Node[] nodes) { |
281 |
private void selectLibrary (Node[] nodes) { |
244 |
int tabCount = this.properties.getTabCount(); |
282 |
int tabCount = this.properties.getTabCount(); |
245 |
for (int i=0; i<tabCount; i++) { |
283 |
for (int i=0; i<tabCount; i++) { |
Lines 251-272
Link Here
|
251 |
this.libraryName.setVisible(false); |
289 |
this.libraryName.setVisible(false); |
252 |
this.properties.setVisible(false); |
290 |
this.properties.setVisible(false); |
253 |
this.deleteButton.setEnabled(false); |
291 |
this.deleteButton.setEnabled(false); |
254 |
if (nodes.length != 1 || !(nodes[0] instanceof LibraryNode)) { |
292 |
if (nodes.length != 1) { |
|
|
293 |
return; |
294 |
} |
295 |
LibraryImplementation impl = nodes[0].getLookup().lookup(LibraryImplementation.class); |
296 |
if (impl == null) { |
255 |
return; |
297 |
return; |
256 |
} |
298 |
} |
257 |
this.jLabel1.setVisible(true); |
299 |
this.jLabel1.setVisible(true); |
258 |
this.libraryName.setVisible(true); |
300 |
this.libraryName.setVisible(true); |
259 |
this.properties.setVisible(true); |
301 |
this.properties.setVisible(true); |
260 |
LibraryNode lnode = (LibraryNode) nodes[0]; |
|
|
261 |
LibraryImplementation impl = lnode.getLibrary (); |
262 |
boolean editable = model.isLibraryEditable (impl); |
302 |
boolean editable = model.isLibraryEditable (impl); |
263 |
this.libraryName.setEnabled(editable); |
303 |
this.libraryName.setEnabled(editable); |
264 |
this.deleteButton.setEnabled(editable); |
304 |
this.deleteButton.setEnabled(editable); |
265 |
this.libraryName.setText (getLocalizedString(impl.getLocalizingBundle(),impl.getName())); |
305 |
this.libraryName.setText (getLocalizedString(impl.getLocalizingBundle(),impl.getName())); |
266 |
String libraryType = impl.getType(); |
306 |
LibraryTypeProvider provider = nodes[0].getLookup().lookup(LibraryTypeProvider.class); |
267 |
LibraryTypeProvider provider = lnode.getProvider (); |
|
|
268 |
if (provider == null) |
307 |
if (provider == null) |
269 |
return; |
308 |
return; |
|
|
309 |
// a library customizer needs to know location of sharable library in order to |
310 |
// relativize paths. that's why object implementing both LibraryImplementation |
311 |
// and LibraryStorageArea is passed to JComponent here: |
312 |
LibraryStorageArea area = nodes[0].getLookup().lookup(LibraryStorageArea.class); |
313 |
if (area != null && area != LibrariesModel.GLOBAL_AREA) { |
314 |
impl = new LibraryImplementationWrapper(impl, area); |
315 |
} |
316 |
|
270 |
String[] volumeTypes = provider.getSupportedVolumeTypes(); |
317 |
String[] volumeTypes = provider.getSupportedVolumeTypes(); |
271 |
for (int i=0; i< volumeTypes.length; i++) { |
318 |
for (int i=0; i< volumeTypes.length; i++) { |
272 |
Customizer c = provider.getCustomizer (volumeTypes[i]); |
319 |
Customizer c = provider.getCustomizer (volumeTypes[i]); |
Lines 282-294
Link Here
|
282 |
} |
329 |
} |
283 |
} |
330 |
} |
284 |
} |
331 |
} |
285 |
|
332 |
|
286 |
/** This method is called from within the constructor to |
333 |
/** This method is called from within the constructor to |
287 |
* initialize the form. |
334 |
* initialize the form. |
288 |
* WARNING: Do NOT modify this code. The content of this method is |
335 |
* WARNING: Do NOT modify this code. The content of this method is |
289 |
* always regenerated by the Form Editor. |
336 |
* always regenerated by the Form Editor. |
290 |
*/ |
337 |
*/ |
291 |
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents |
338 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
292 |
private void initComponents() { |
339 |
private void initComponents() { |
293 |
java.awt.GridBagConstraints gridBagConstraints; |
340 |
java.awt.GridBagConstraints gridBagConstraints; |
294 |
|
341 |
|
Lines 301-313
Link Here
|
301 |
libsPanel = new javax.swing.JPanel(); |
348 |
libsPanel = new javax.swing.JPanel(); |
302 |
jLabel2 = new javax.swing.JLabel(); |
349 |
jLabel2 = new javax.swing.JLabel(); |
303 |
|
350 |
|
|
|
351 |
setMinimumSize(new java.awt.Dimension(642, 395)); |
304 |
setLayout(new java.awt.GridBagLayout()); |
352 |
setLayout(new java.awt.GridBagLayout()); |
305 |
|
353 |
|
306 |
getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_LibrariesCustomizer")); |
|
|
307 |
jLabel1.setLabelFor(libraryName); |
354 |
jLabel1.setLabelFor(libraryName); |
308 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("CTL_CustomizerLibraryName")); |
355 |
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle"); // NOI18N |
|
|
356 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, bundle.getString("CTL_CustomizerLibraryName")); // NOI18N |
309 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
357 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
310 |
gridBagConstraints.gridx = 2; |
358 |
gridBagConstraints.gridx = 3; |
311 |
gridBagConstraints.gridy = 1; |
359 |
gridBagConstraints.gridy = 1; |
312 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
360 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
313 |
gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 6); |
361 |
gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 6); |
Lines 315-410
Link Here
|
315 |
|
363 |
|
316 |
libraryName.setEditable(false); |
364 |
libraryName.setEditable(false); |
317 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
365 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
318 |
gridBagConstraints.gridx = 3; |
366 |
gridBagConstraints.gridx = 4; |
319 |
gridBagConstraints.gridy = 1; |
367 |
gridBagConstraints.gridy = 1; |
320 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
368 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
321 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
369 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
322 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
370 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
323 |
gridBagConstraints.weightx = 0.6; |
371 |
gridBagConstraints.weightx = 0.6; |
324 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 12); |
372 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0); |
325 |
add(libraryName, gridBagConstraints); |
373 |
add(libraryName, gridBagConstraints); |
326 |
libraryName.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_LibraryName")); |
374 |
libraryName.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_LibraryName")); // NOI18N |
327 |
|
375 |
|
328 |
jPanel1.setLayout(new java.awt.BorderLayout()); |
376 |
jPanel1.setLayout(new java.awt.BorderLayout()); |
329 |
|
377 |
|
330 |
properties.setPreferredSize(new java.awt.Dimension(400, 300)); |
378 |
properties.setPreferredSize(new java.awt.Dimension(400, 300)); |
331 |
jPanel1.add(properties, java.awt.BorderLayout.CENTER); |
379 |
jPanel1.add(properties, java.awt.BorderLayout.CENTER); |
332 |
properties.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AN_LibrariesCustomizerProperties")); |
380 |
properties.getAccessibleContext().setAccessibleName(bundle.getString("AN_LibrariesCustomizerProperties")); // NOI18N |
333 |
properties.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_LibrariesCustomizerProperties")); |
381 |
properties.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_LibrariesCustomizerProperties")); // NOI18N |
334 |
|
382 |
|
335 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
383 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
336 |
gridBagConstraints.gridx = 2; |
384 |
gridBagConstraints.gridx = 3; |
337 |
gridBagConstraints.gridy = 2; |
385 |
gridBagConstraints.gridy = 2; |
338 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
386 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
339 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
387 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
340 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
388 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
341 |
gridBagConstraints.weightx = 1.0; |
389 |
gridBagConstraints.weightx = 1.0; |
342 |
gridBagConstraints.weighty = 1.0; |
390 |
gridBagConstraints.weighty = 1.0; |
343 |
gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 12); |
391 |
gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0); |
344 |
add(jPanel1, gridBagConstraints); |
392 |
add(jPanel1, gridBagConstraints); |
345 |
|
393 |
|
346 |
org.openide.awt.Mnemonics.setLocalizedText(createButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("CTL_NewLibrary")); |
394 |
org.openide.awt.Mnemonics.setLocalizedText(createButton, bundle.getString("CTL_NewLibrary")); // NOI18N |
347 |
createButton.addActionListener(new java.awt.event.ActionListener() { |
395 |
createButton.addActionListener(new java.awt.event.ActionListener() { |
348 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
396 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
349 |
createLibrary(evt); |
397 |
createLibrary(evt); |
350 |
} |
398 |
} |
351 |
}); |
399 |
}); |
352 |
|
|
|
353 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
400 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
354 |
gridBagConstraints.gridx = 0; |
401 |
gridBagConstraints.gridx = 0; |
355 |
gridBagConstraints.gridy = 3; |
402 |
gridBagConstraints.gridy = 3; |
356 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
403 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
357 |
gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12); |
404 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); |
358 |
add(createButton, gridBagConstraints); |
405 |
add(createButton, gridBagConstraints); |
359 |
createButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_NewLibrary")); |
406 |
createButton.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_NewLibrary")); // NOI18N |
360 |
|
407 |
|
361 |
org.openide.awt.Mnemonics.setLocalizedText(deleteButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("CTL_DeleteLibrary")); |
408 |
org.openide.awt.Mnemonics.setLocalizedText(deleteButton, bundle.getString("CTL_DeleteLibrary")); // NOI18N |
362 |
deleteButton.addActionListener(new java.awt.event.ActionListener() { |
409 |
deleteButton.addActionListener(new java.awt.event.ActionListener() { |
363 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
410 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
364 |
deleteLibrary(evt); |
411 |
deleteLibrary(evt); |
365 |
} |
412 |
} |
366 |
}); |
413 |
}); |
367 |
|
|
|
368 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
414 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
369 |
gridBagConstraints.gridx = 1; |
415 |
gridBagConstraints.gridx = 1; |
370 |
gridBagConstraints.gridy = 3; |
416 |
gridBagConstraints.gridy = 3; |
371 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
417 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
372 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); |
418 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); |
373 |
add(deleteButton, gridBagConstraints); |
419 |
add(deleteButton, gridBagConstraints); |
374 |
deleteButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_DeleteLibrary")); |
420 |
deleteButton.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_DeleteLibrary")); // NOI18N |
375 |
|
421 |
|
|
|
422 |
libsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); |
376 |
libsPanel.setLayout(new java.awt.GridBagLayout()); |
423 |
libsPanel.setLayout(new java.awt.GridBagLayout()); |
377 |
|
|
|
378 |
libsPanel.setBorder(new javax.swing.border.EtchedBorder()); |
379 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
424 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
380 |
gridBagConstraints.gridx = 0; |
425 |
gridBagConstraints.gridx = 0; |
381 |
gridBagConstraints.gridy = 1; |
426 |
gridBagConstraints.gridy = 1; |
382 |
gridBagConstraints.gridwidth = 2; |
427 |
gridBagConstraints.gridwidth = 3; |
383 |
gridBagConstraints.gridheight = 2; |
428 |
gridBagConstraints.gridheight = 2; |
384 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
429 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
385 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
430 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
386 |
gridBagConstraints.weighty = 1.0; |
431 |
gridBagConstraints.weighty = 1.0; |
387 |
gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 6); |
432 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 6); |
388 |
add(libsPanel, gridBagConstraints); |
433 |
add(libsPanel, gridBagConstraints); |
389 |
libsPanel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_libsPanel")); |
434 |
libsPanel.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_libsPanel")); // NOI18N |
390 |
|
435 |
|
391 |
jLabel2.setLabelFor(libsPanel); |
436 |
jLabel2.setLabelFor(libsPanel); |
392 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("TXT_LibrariesPanel")); |
437 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, bundle.getString("TXT_LibrariesPanel")); // NOI18N |
393 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
438 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
394 |
gridBagConstraints.gridx = 0; |
439 |
gridBagConstraints.gridx = 0; |
395 |
gridBagConstraints.gridy = 0; |
440 |
gridBagConstraints.gridy = 0; |
396 |
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
|
|
397 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
441 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
398 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
442 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
399 |
gridBagConstraints.insets = new java.awt.Insets(12, 12, 2, 12); |
443 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 12); |
400 |
add(jLabel2, gridBagConstraints); |
444 |
add(jLabel2, gridBagConstraints); |
401 |
|
445 |
|
402 |
} |
446 |
getAccessibleContext().setAccessibleDescription(bundle.getString("AD_LibrariesCustomizer")); // NOI18N |
403 |
// </editor-fold>//GEN-END:initComponents |
447 |
}// </editor-fold>//GEN-END:initComponents |
404 |
|
448 |
|
405 |
private void deleteLibrary(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteLibrary |
449 |
private void deleteLibrary(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteLibrary |
406 |
Node[] nodes = this.getExplorerManager().getSelectedNodes(); |
450 |
Node[] nodes = this.getExplorerManager().getSelectedNodes(); |
407 |
if (nodes.length == 1 && (nodes[0] instanceof LibraryNode)) { |
451 |
if (nodes.length == 1) { |
|
|
452 |
LibraryImplementation library = nodes[0].getLookup().lookup(LibraryImplementation.class); |
453 |
if (library == null) { |
454 |
return; |
455 |
} |
408 |
Node[] sib = nodes[0].getParentNode().getChildren().getNodes(true); |
456 |
Node[] sib = nodes[0].getParentNode().getChildren().getNodes(true); |
409 |
Node selNode = null; |
457 |
Node selNode = null; |
410 |
for (int i=0; i < sib.length; i++) { |
458 |
for (int i=0; i < sib.length; i++) { |
Lines 417-423
Link Here
|
417 |
} |
465 |
} |
418 |
} |
466 |
} |
419 |
} |
467 |
} |
420 |
model.removeLibrary (((LibraryNode)nodes[0]).getLibrary()); |
468 |
model.removeLibrary(library); |
421 |
try { |
469 |
try { |
422 |
if (selNode != null) { |
470 |
if (selNode != null) { |
423 |
this.getExplorerManager().setSelectedNodes(new Node[] {selNode}); |
471 |
this.getExplorerManager().setSelectedNodes(new Node[] {selNode}); |
Lines 433-446
Link Here
|
433 |
Dialog dlg = null; |
481 |
Dialog dlg = null; |
434 |
try { |
482 |
try { |
435 |
String preselectedLibraryType = null; |
483 |
String preselectedLibraryType = null; |
|
|
484 |
LibraryStorageArea area = null; |
436 |
Node[] preselectedNodes = this.getExplorerManager().getSelectedNodes(); |
485 |
Node[] preselectedNodes = this.getExplorerManager().getSelectedNodes(); |
437 |
if (preselectedNodes.length == 1) { |
486 |
if (preselectedNodes.length == 1) { |
438 |
LibraryCategory lc = preselectedNodes[0].getLookup().lookup(LibraryCategory.class); |
487 |
LibraryTypeProvider provider = preselectedNodes[0].getLookup().lookup(LibraryTypeProvider.class); |
439 |
if (lc != null) { |
488 |
if (provider != null) { |
440 |
preselectedLibraryType = lc.getCategoryType(); |
489 |
preselectedLibraryType = provider.getLibraryType(); |
441 |
} |
490 |
} |
|
|
491 |
area = preselectedNodes[0].getLookup().lookup(LibraryStorageArea.class); |
492 |
} |
493 |
if (area == null) { |
494 |
area = LibrariesModel.GLOBAL_AREA; |
442 |
} |
495 |
} |
443 |
NewLibraryPanel p = new NewLibraryPanel (this.model, preselectedLibraryType); |
496 |
NewLibraryPanel p = new NewLibraryPanel(model, preselectedLibraryType, area); |
444 |
DialogDescriptor dd = new DialogDescriptor (p, NbBundle.getMessage(LibrariesCustomizer.class,"CTL_CreateLibrary"), |
497 |
DialogDescriptor dd = new DialogDescriptor (p, NbBundle.getMessage(LibrariesCustomizer.class,"CTL_CreateLibrary"), |
445 |
true, DialogDescriptor.OK_CANCEL_OPTION, null, null); |
498 |
true, DialogDescriptor.OK_CANCEL_OPTION, null, null); |
446 |
p.setDialogDescriptor(dd); |
499 |
p.setDialogDescriptor(dd); |
Lines 448-464
Link Here
|
448 |
dlg.setVisible(true); |
501 |
dlg.setVisible(true); |
449 |
if (dd.getValue() == DialogDescriptor.OK_OPTION) { |
502 |
if (dd.getValue() == DialogDescriptor.OK_OPTION) { |
450 |
String libraryType = p.getLibraryType(); |
503 |
String libraryType = p.getLibraryType(); |
451 |
String libraryName = p.getLibraryName(); |
504 |
String currentLibraryName = p.getLibraryName(); |
452 |
LibraryTypeProvider provider = LibraryTypeRegistry.getDefault().getLibraryTypeProvider (libraryType); |
505 |
LibraryImplementation impl; |
453 |
if (provider == null) { |
506 |
if (area != LibrariesModel.GLOBAL_AREA) { |
454 |
return; |
507 |
impl = model.createArealLibrary(libraryType, currentLibraryName, area); |
|
|
508 |
} else { |
509 |
LibraryTypeProvider provider = LibraryTypeRegistry.getDefault().getLibraryTypeProvider(libraryType); |
510 |
if (provider == null) { |
511 |
return; |
512 |
} |
513 |
impl = provider.createLibrary(); |
514 |
impl.setName(currentLibraryName); |
455 |
} |
515 |
} |
456 |
LibraryImplementation impl = provider.createLibrary(); |
|
|
457 |
impl.setName (libraryName); |
458 |
model.addLibrary (impl); |
516 |
model.addLibrary (impl); |
459 |
String[] path = new String[2]; |
517 |
forceTreeRecreation(); |
460 |
path[0] = impl.getType(); |
518 |
String[] path = {impl.getType(), impl.getName()}; |
461 |
path[1] = impl.getName(); |
|
|
462 |
ExplorerManager mgr = this.getExplorerManager(); |
519 |
ExplorerManager mgr = this.getExplorerManager(); |
463 |
try { |
520 |
try { |
464 |
Node node = NodeOp.findPath(mgr.getRootContext(),path); |
521 |
Node node = NodeOp.findPath(mgr.getRootContext(),path); |
Lines 484-501
Link Here
|
484 |
} |
541 |
} |
485 |
}//GEN-LAST:event_createLibrary |
542 |
}//GEN-LAST:event_createLibrary |
486 |
|
543 |
|
487 |
|
544 |
static boolean isValidName(LibrariesModel model, String name, LibraryStorageArea area) { |
488 |
static boolean isValidName (LibrariesModel model, String name) { |
545 |
for (LibraryImplementation lib : model.getLibraries()) { |
489 |
int count = model.getSize(); |
546 |
if (lib.getName().equals(name) && Utilities.compareObjects(model.getArea(lib), area)) { |
490 |
for (int i=0; i<count; i++) { |
|
|
491 |
LibraryImplementation lib = (LibraryImplementation) model.getElementAt (i); |
492 |
if (lib != null && lib.getName().equals(name)) |
493 |
return false; |
547 |
return false; |
|
|
548 |
} |
494 |
} |
549 |
} |
495 |
return true; |
550 |
return true; |
496 |
} |
551 |
} |
497 |
|
552 |
|
498 |
|
|
|
499 |
static String getLocalizedString (String bundleResourceName, String key) { |
553 |
static String getLocalizedString (String bundleResourceName, String key) { |
500 |
if (key == null) { |
554 |
if (key == null) { |
501 |
return null; |
555 |
return null; |
Lines 519-525
Link Here
|
519 |
} |
573 |
} |
520 |
} |
574 |
} |
521 |
|
575 |
|
522 |
|
|
|
523 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
576 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
524 |
private javax.swing.JButton createButton; |
577 |
private javax.swing.JButton createButton; |
525 |
private javax.swing.JButton deleteButton; |
578 |
private javax.swing.JButton deleteButton; |
Lines 530-536
Link Here
|
530 |
private javax.swing.JPanel libsPanel; |
583 |
private javax.swing.JPanel libsPanel; |
531 |
private javax.swing.JTabbedPane properties; |
584 |
private javax.swing.JTabbedPane properties; |
532 |
// End of variables declaration//GEN-END:variables |
585 |
// End of variables declaration//GEN-END:variables |
533 |
|
|
|
534 |
|
586 |
|
535 |
private static void expandAllNodes (BeanTreeView btv, Node node) { |
587 |
private static void expandAllNodes (BeanTreeView btv, Node node) { |
536 |
btv.expandNode (node); |
588 |
btv.expandNode (node); |
Lines 558-573
Link Here
|
558 |
|
610 |
|
559 |
} |
611 |
} |
560 |
|
612 |
|
561 |
|
613 |
private class AreaChildren extends Children.Keys<LibraryStorageArea> implements ChangeListener { |
562 |
private static class RootChildren extends Children.Keys<LibraryTypeProvider> { |
614 |
|
563 |
|
615 |
@Override |
564 |
private LibrariesModel model; |
616 |
protected void addNotify() { |
565 |
|
617 |
super.addNotify(); |
566 |
public RootChildren (LibrariesModel model) { |
618 |
model.addChangeListener(this); |
567 |
this.model = model; |
619 |
computeKeys(); |
568 |
} |
620 |
} |
569 |
|
621 |
|
|
|
622 |
@Override |
623 |
protected void removeNotify() { |
624 |
super.removeNotify(); |
625 |
model.removeChangeListener(this); |
626 |
setKeys(Collections.<LibraryStorageArea>emptySet()); |
627 |
} |
628 |
|
629 |
private void computeKeys() { |
630 |
setKeys(getSortedAreas(model)); |
631 |
} |
632 |
|
633 |
protected Node[] createNodes(LibraryStorageArea area) { |
634 |
return new Node[] {new AreaNode(area)}; |
635 |
} |
636 |
|
637 |
public void stateChanged(ChangeEvent e) { |
638 |
EventQueue.invokeLater(new Runnable() { |
639 |
public void run() { |
640 |
computeKeys(); |
641 |
} |
642 |
}); |
643 |
} |
644 |
|
645 |
} |
646 |
|
647 |
static Collection<? extends LibraryStorageArea> getSortedAreas(LibrariesModel model) { |
648 |
List<LibraryStorageArea> areas = new ArrayList<LibraryStorageArea>(model.getAreas()); |
649 |
Collections.sort(areas,new Comparator<LibraryStorageArea>() { |
650 |
Collator COLL = Collator.getInstance(); |
651 |
public int compare(LibraryStorageArea a1, LibraryStorageArea a2) { |
652 |
return COLL.compare(a1.getDisplayName(), a2.getDisplayName()); |
653 |
} |
654 |
}); |
655 |
areas.add(0, LibrariesModel.GLOBAL_AREA); |
656 |
assert !areas.contains(null); |
657 |
return areas; |
658 |
} |
659 |
|
660 |
private final class AreaNode extends AbstractNode { |
661 |
|
662 |
private final LibraryStorageArea area; |
663 |
|
664 |
AreaNode(LibraryStorageArea area) { |
665 |
super(new TypeChildren(area), Lookups.singleton(area)); |
666 |
this.area = area; |
667 |
} |
668 |
|
669 |
@Override |
670 |
public String getName() { |
671 |
return getDisplayName(); |
672 |
} |
673 |
|
674 |
@Override |
675 |
public String getDisplayName() { |
676 |
return area.getDisplayName(); |
677 |
} |
678 |
|
679 |
private Node delegate() { |
680 |
return DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().getRoot()).getNodeDelegate(); |
681 |
} |
682 |
|
683 |
public Image getIcon(int type) { |
684 |
return delegate().getIcon(type); |
685 |
} |
686 |
|
687 |
public Image getOpenedIcon(int type) { |
688 |
return delegate().getOpenedIcon(type); |
689 |
} |
690 |
|
691 |
} |
692 |
|
693 |
private class TypeChildren extends Children.Keys<LibraryTypeProvider> { |
694 |
|
695 |
private final LibraryStorageArea area; |
696 |
|
697 |
TypeChildren(LibraryStorageArea area) { |
698 |
this.area = area; |
699 |
} |
700 |
|
570 |
public void addNotify () { |
701 |
public void addNotify () { |
|
|
702 |
// Could also filter by area (would then need to listen to model too) |
571 |
this.setKeys(LibraryTypeRegistry.getDefault().getLibraryTypeProviders()); |
703 |
this.setKeys(LibraryTypeRegistry.getDefault().getLibraryTypeProviders()); |
572 |
} |
704 |
} |
573 |
|
705 |
|
Lines 576-609
Link Here
|
576 |
} |
708 |
} |
577 |
|
709 |
|
578 |
protected Node[] createNodes(LibraryTypeProvider provider) { |
710 |
protected Node[] createNodes(LibraryTypeProvider provider) { |
579 |
return new Node[] {new CategoryNode(provider, model)}; |
711 |
return new Node[] {new CategoryNode(provider, area)}; |
580 |
} |
712 |
} |
581 |
|
713 |
|
582 |
} |
714 |
} |
583 |
|
715 |
|
584 |
|
716 |
private class CategoryNode extends AbstractNode { |
585 |
private static final class LibraryCategory { |
|
|
586 |
|
587 |
private final String name; |
588 |
|
589 |
LibraryCategory (String name) { |
590 |
this.name = name; |
591 |
} |
592 |
|
593 |
public String getCategoryType () { |
594 |
return this.name; |
595 |
} |
596 |
|
597 |
} |
598 |
|
599 |
private static class CategoryNode extends AbstractNode { |
600 |
|
601 |
|
717 |
|
602 |
private LibraryTypeProvider provider; |
718 |
private LibraryTypeProvider provider; |
603 |
private Node iconDelegate; |
719 |
private Node iconDelegate; |
604 |
|
720 |
|
605 |
public CategoryNode (LibraryTypeProvider provider, LibrariesModel model) { |
721 |
public CategoryNode(LibraryTypeProvider provider, LibraryStorageArea area) { |
606 |
super (new CategoryChildren(provider, model), Lookups.singleton(new LibraryCategory (provider.getLibraryType()))); |
722 |
super(new CategoryChildren(provider, area), Lookups.fixed(provider, area)); |
607 |
this.provider = provider; |
723 |
this.provider = provider; |
608 |
this.iconDelegate = DataFolder.findFolder (Repository.getDefault().getDefaultFileSystem().getRoot()).getNodeDelegate(); |
724 |
this.iconDelegate = DataFolder.findFolder (Repository.getDefault().getDefaultFileSystem().getRoot()).getNodeDelegate(); |
609 |
} |
725 |
} |
Lines 625-647
Link Here
|
625 |
} |
741 |
} |
626 |
|
742 |
|
627 |
} |
743 |
} |
628 |
|
744 |
|
629 |
private static class CategoryChildren extends Children.Keys<LibraryImplementation> implements ListDataListener { |
745 |
private class CategoryChildren extends Children.Keys<LibraryImplementation> implements ChangeListener { |
630 |
|
746 |
|
631 |
private LibraryTypeProvider provider; |
747 |
private LibraryTypeProvider provider; |
632 |
private LibrariesModel model; |
748 |
private final LibraryStorageArea area; |
633 |
|
749 |
|
634 |
public CategoryChildren (LibraryTypeProvider provider, LibrariesModel model) { |
750 |
public CategoryChildren(LibraryTypeProvider provider, LibraryStorageArea area) { |
635 |
this.provider = provider; |
751 |
this.provider = provider; |
636 |
this.model = model; |
752 |
this.area = area; |
637 |
this.model.addListDataListener(this); |
753 |
model.addChangeListener(this); |
638 |
} |
754 |
} |
639 |
|
755 |
|
640 |
public void addNotify () { |
756 |
public void addNotify () { |
641 |
Collection<LibraryImplementation> keys = new ArrayList<LibraryImplementation>(); |
757 |
Collection<LibraryImplementation> keys = new ArrayList<LibraryImplementation>(); |
642 |
for (int i=0; i<model.getSize(); i++) { |
758 |
for (LibraryImplementation impl : model.getLibraries()) { |
643 |
LibraryImplementation impl = (LibraryImplementation) model.getElementAt(i); |
759 |
if (provider.getLibraryType().equals(impl.getType()) && model.getArea(impl).equals(area)) { |
644 |
if (this.provider.getLibraryType().equals(impl.getType())) { |
|
|
645 |
keys.add (impl); |
760 |
keys.add (impl); |
646 |
} |
761 |
} |
647 |
} |
762 |
} |
Lines 653-674
Link Here
|
653 |
} |
768 |
} |
654 |
|
769 |
|
655 |
protected Node[] createNodes(LibraryImplementation impl) { |
770 |
protected Node[] createNodes(LibraryImplementation impl) { |
656 |
return new Node[] {new LibraryNode(impl, provider)}; |
771 |
return new Node[] {new LibraryNode(impl, provider, area)}; |
657 |
} |
|
|
658 |
|
659 |
public void contentsChanged(ListDataEvent e) { |
660 |
//Todo: Optimize it |
661 |
this.addNotify(); |
662 |
} |
663 |
|
664 |
public void intervalAdded(ListDataEvent e) { |
665 |
//Todo: Optimize it |
666 |
this.addNotify(); |
667 |
} |
772 |
} |
668 |
|
773 |
|
669 |
public void intervalRemoved(ListDataEvent e) { |
774 |
public void stateChanged(ChangeEvent e) { |
670 |
//Todo: Optimize it |
775 |
EventQueue.invokeLater(new Runnable() { |
671 |
this.addNotify(); |
776 |
public void run() { |
|
|
777 |
addNotify(); |
778 |
} |
779 |
}); |
672 |
} |
780 |
} |
673 |
|
781 |
|
674 |
} |
782 |
} |
Lines 680-687
Link Here
|
680 |
private LibraryImplementation lib; |
788 |
private LibraryImplementation lib; |
681 |
private LibraryTypeProvider provider; |
789 |
private LibraryTypeProvider provider; |
682 |
|
790 |
|
683 |
public LibraryNode (LibraryImplementation lib, LibraryTypeProvider provider) { |
791 |
public LibraryNode(LibraryImplementation lib, LibraryTypeProvider provider, LibraryStorageArea area) { |
684 |
super (Children.LEAF); |
792 |
super(Children.LEAF, Lookups.fixed(lib, provider, area)); |
685 |
this.lib = lib; |
793 |
this.lib = lib; |
686 |
this.provider = provider; |
794 |
this.provider = provider; |
687 |
this.setIconBaseWithExtension(ICON); |
795 |
this.setIconBaseWithExtension(ICON); |
Lines 695-721
Link Here
|
695 |
return getLocalizedString(this.lib.getLocalizingBundle(), this.lib.getName()); |
803 |
return getLocalizedString(this.lib.getLocalizingBundle(), this.lib.getName()); |
696 |
} |
804 |
} |
697 |
|
805 |
|
698 |
public LibraryImplementation getLibrary () { |
806 |
} |
699 |
return this.lib; |
807 |
|
700 |
} |
808 |
private Node buildTree() { |
|
|
809 |
return new AbstractNode(new TypeChildren(libraryStorageArea)); |
810 |
} |
811 |
|
812 |
private static class LibraryImplementationWrapper implements LibraryImplementation, LibraryStorageArea { |
701 |
|
813 |
|
702 |
public LibraryTypeProvider getProvider () { |
814 |
private LibraryImplementation lib; |
703 |
return this.provider; |
815 |
private LibraryStorageArea area; |
704 |
} |
|
|
705 |
|
816 |
|
706 |
public boolean equals (Object other) { |
817 |
public LibraryImplementationWrapper(LibraryImplementation lib, LibraryStorageArea area) { |
707 |
if (other instanceof LibraryNode) { |
818 |
this.lib = lib; |
708 |
LibraryNode ol = (LibraryNode) other; |
819 |
this.area = area; |
709 |
return (this.lib == null ? ol.lib == null : this.lib.equals(ol.lib)) |
820 |
} |
710 |
&& (this.provider == null ? ol.provider == null : this.provider.equals(ol.provider)); |
821 |
|
711 |
} |
822 |
public String getType() { |
712 |
return false; |
823 |
return lib.getType(); |
|
|
824 |
} |
825 |
|
826 |
public String getName() { |
827 |
return lib.getName(); |
828 |
} |
829 |
|
830 |
public String getDescription() { |
831 |
return lib.getDescription(); |
832 |
} |
833 |
|
834 |
public String getLocalizingBundle() { |
835 |
return lib.getLocalizingBundle(); |
836 |
} |
837 |
|
838 |
public List<URL> getContent(String volumeType) throws IllegalArgumentException { |
839 |
return lib.getContent(volumeType); |
840 |
} |
841 |
|
842 |
public void setName(String name) { |
843 |
lib.setName(name); |
844 |
} |
845 |
|
846 |
public void setDescription(String text) { |
847 |
lib.setDescription(text); |
848 |
} |
849 |
|
850 |
public void setLocalizingBundle(String resourceName) { |
851 |
lib.setLocalizingBundle(resourceName); |
852 |
} |
853 |
|
854 |
public void addPropertyChangeListener(PropertyChangeListener l) { |
855 |
lib.addPropertyChangeListener(l); |
856 |
} |
857 |
|
858 |
public void removePropertyChangeListener(PropertyChangeListener l) { |
859 |
lib.removePropertyChangeListener(l); |
860 |
} |
861 |
|
862 |
public void setContent(String volumeType, List<URL> path) throws IllegalArgumentException { |
863 |
lib.setContent(volumeType, path); |
864 |
} |
865 |
|
866 |
public URL getLocation() { |
867 |
return area.getLocation(); |
868 |
} |
869 |
|
870 |
public String getDisplayName() { |
871 |
return area.getDisplayName(); |
713 |
} |
872 |
} |
714 |
} |
873 |
} |
715 |
|
|
|
716 |
private static Node buildTree (LibrariesModel model) { |
717 |
return new AbstractNode (new RootChildren (model)); |
718 |
} |
719 |
|
720 |
|
874 |
|
721 |
} |
875 |
} |