1 19 20 package org.netbeans.modules.project.libraries.ui; 21 22 import java.awt.Dialog ; 23 import java.awt.Dimension ; 24 import java.awt.GridBagConstraints ; 25 import java.awt.GridBagLayout ; 26 import java.awt.Image ; 27 import java.awt.event.ActionEvent ; 28 import java.awt.event.ActionListener ; 29 import java.beans.Customizer ; 30 import java.beans.PropertyChangeEvent ; 31 import java.beans.PropertyChangeListener ; 32 import java.beans.PropertyVetoException ; 33 import java.beans.VetoableChangeListener ; 34 import java.io.IOException ; 35 import java.util.ArrayList ; 36 import java.util.Collection ; 37 import java.util.MissingResourceException ; 38 import java.util.ResourceBundle ; 39 import javax.swing.JComponent ; 40 import javax.swing.JPanel ; 41 import javax.swing.event.ListDataEvent ; 42 import javax.swing.event.ListDataListener ; 43 import org.netbeans.modules.project.libraries.LibraryTypeRegistry; 44 import org.netbeans.spi.project.libraries.LibraryImplementation; 45 import org.netbeans.spi.project.libraries.LibraryTypeProvider; 46 import org.openide.DialogDescriptor; 47 import org.openide.DialogDisplayer; 48 import org.openide.ErrorManager; 49 import org.openide.NotifyDescriptor; 50 import org.openide.explorer.ExplorerManager; 51 import org.openide.explorer.view.BeanTreeView; 52 import org.openide.filesystems.Repository; 53 import org.openide.loaders.DataFolder; 54 import org.openide.nodes.AbstractNode; 55 import org.openide.nodes.Children; 56 import org.openide.nodes.Node; 57 import org.openide.nodes.NodeNotFoundException; 58 import org.openide.nodes.NodeOp; 59 import org.openide.util.HelpCtx; 60 import org.openide.util.NbBundle; 61 import org.openide.util.lookup.Lookups; 62 63 67 public final class LibrariesCustomizer extends JPanel implements ExplorerManager.Provider, HelpCtx.Provider { 68 69 private ExplorerManager manager; 70 private LibrariesModel model; 71 private BeanTreeView libraries; 72 73 74 public LibrariesCustomizer () { 75 this.model = new LibrariesModel (); 76 initComponents(); 77 postInitComponents (); 78 } 79 80 81 public void setSelectedLibrary (LibraryImplementation library) { 82 if (library == null) 83 return; 84 ExplorerManager manager = this.getExplorerManager(); 85 Node root = manager.getRootContext(); 86 String [] path = new String [2]; 87 path[0]=library.getType(); 88 path[1]=library.getName(); 89 try { 90 Node node = NodeOp.findPath(root, path); 91 if (node != null) { 92 manager.setSelectedNodes(new Node[] {node}); 93 } 94 } catch (NodeNotFoundException e) { 95 } 97 catch (PropertyVetoException e) { 98 } 100 } 101 102 public HelpCtx getHelpCtx() { 103 return new HelpCtx( LibrariesCustomizer.class ); 104 } 105 106 public boolean apply () { 107 try { 108 this.model.apply(); 109 return true; 110 } catch (IOException ioe) { 111 ErrorManager.getDefault().notify(ioe); 112 return false; 113 } 114 } 115 116 public void cancel () { 117 this.model.cancel(); 118 } 119 120 public void addNotify() { 121 super.addNotify(); 122 expandAllNodes(this.libraries,this.getExplorerManager().getRootContext()); 123 if (this.getExplorerManager().getSelectedNodes().length == 0) { 125 Node root = this.getExplorerManager().getRootContext(); 126 Node[] nodes = root.getChildren().getNodes (true); 127 for (int i = 0; i< nodes.length; i++) { 128 Node[] lnodes = nodes[i].getChildren().getNodes(true); 129 if (lnodes.length > 0) { 130 try { 131 this.getExplorerManager().setSelectedNodes(new Node[] {lnodes[0]}); 132 } catch (PropertyVetoException e) { 133 } 135 break; 136 } 137 } 138 } 139 this.libraries.requestFocus(); 140 } 141 142 143 public ExplorerManager getExplorerManager () { 144 if (this.manager == null) { 145 this.manager = new ExplorerManager (); 146 this.manager.addPropertyChangeListener (new PropertyChangeListener () { 147 public void propertyChange (PropertyChangeEvent event) { 148 if (ExplorerManager.PROP_SELECTED_NODES.equals(event.getPropertyName())) { 149 Node[] nodes = (Node[]) event.getNewValue (); 150 selectLibrary(nodes); 151 libraries.requestFocus(); 152 } 153 } 154 }); 155 this.manager.addVetoableChangeListener(new VetoableChangeListener () { 156 public void vetoableChange(PropertyChangeEvent event) throws PropertyVetoException { 157 if (ExplorerManager.PROP_SELECTED_NODES.equals(event.getPropertyName())) { 158 Node[] nodes = (Node[]) event.getNewValue(); 159 if (nodes.length <=1) { 160 return; 161 } 162 else { 163 throw new PropertyVetoException ("Invalid length", event); } 165 } 166 } 167 }); 168 this.manager.setRootContext (buildTree(this.model)); 169 } 170 return this.manager; 171 } 172 173 174 private void postInitComponents () { 175 this.libraries = new LibrariesView (); 176 GridBagConstraints c = new GridBagConstraints (); 177 c.gridx = GridBagConstraints.RELATIVE; 178 c.gridy = GridBagConstraints.RELATIVE; 179 c.gridwidth = GridBagConstraints.REMAINDER; 180 c.gridheight = GridBagConstraints.REMAINDER; 181 c.fill = GridBagConstraints.BOTH; 182 c.anchor = GridBagConstraints.NORTHWEST; 183 c.weightx = 1.0; 184 c.weighty = 1.0; 185 ((GridBagLayout )this.libsPanel.getLayout()).setConstraints(this.libraries,c); 186 this.libsPanel.add(this.libraries); 187 this.libraries.setPreferredSize(new Dimension (200,334)); 188 this.libraryName.setColumns(25); 189 this.libraryName.setEnabled(false); 190 this.libraryName.addActionListener( 191 new ActionListener () { 192 public void actionPerformed(ActionEvent e) { 193 nameChanged(); 194 } 195 }); 196 } 197 198 199 private void nameChanged () { 200 Node[] nodes = this.getExplorerManager().getSelectedNodes(); 201 if (nodes.length == 1 && (nodes[0] instanceof LibraryNode)) { 202 LibraryNode node = (LibraryNode) nodes[0]; 203 String newName = this.libraryName.getText(); 204 if (newName.length () == 0) { 205 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message ( 206 NbBundle.getMessage(LibrariesCustomizer.class, "ERR_InvalidName"), 207 NotifyDescriptor.ERROR_MESSAGE)); 208 } 209 else if (isValidName (this.model, newName)) { 210 node.getLibrary().setName(newName); 211 } 212 else { 213 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message ( 214 NbBundle.getMessage(LibrariesCustomizer.class, "ERR_ExistingName", newName), 215 NotifyDescriptor.ERROR_MESSAGE)); 216 } 217 } 218 } 219 220 221 private void selectLibrary (Node[] nodes) { 222 int tabCount = this.properties.getTabCount(); 223 for (int i=0; i<tabCount; i++) { 224 this.properties.removeTabAt(0); 225 } 226 this.libraryName.setEnabled(false); 227 this.libraryName.setText(""); this.jLabel1.setVisible(false); 229 this.libraryName.setVisible(false); 230 this.properties.setVisible(false); 231 this.deleteButton.setEnabled(false); 232 if (nodes.length != 1 || !(nodes[0] instanceof LibraryNode)) { 233 return; 234 } 235 this.jLabel1.setVisible(true); 236 this.libraryName.setVisible(true); 237 this.properties.setVisible(true); 238 LibraryNode lnode = (LibraryNode) nodes[0]; 239 LibraryImplementation impl = lnode.getLibrary (); 240 boolean editable = model.isLibraryEditable (impl); 241 this.libraryName.setEnabled(editable); 242 this.deleteButton.setEnabled(editable); 243 this.libraryName.setText (getLocalizedString(impl.getLocalizingBundle(),impl.getName())); 244 String libraryType = impl.getType(); 245 LibraryTypeProvider provider = lnode.getProvider (); 246 if (provider == null) 247 return; 248 String [] volumeTypes = provider.getSupportedVolumeTypes(); 249 for (int i=0; i< volumeTypes.length; i++) { 250 Customizer c = provider.getCustomizer (volumeTypes[i]); 251 if (c instanceof JComponent ) { 252 c.setObject (impl); 253 JComponent component = (JComponent ) c; 254 component.setEnabled (editable); 255 String tabName = component.getName(); 256 if (tabName == null) { 257 tabName = volumeTypes[i]; 258 } 259 this.properties.addTab(tabName, component); 260 } 261 } 262 } 263 264 269 private void initComponents() { 271 java.awt.GridBagConstraints gridBagConstraints; 272 273 jLabel1 = new javax.swing.JLabel (); 274 libraryName = new javax.swing.JTextField (); 275 jPanel1 = new javax.swing.JPanel (); 276 properties = new javax.swing.JTabbedPane (); 277 createButton = new javax.swing.JButton (); 278 deleteButton = new javax.swing.JButton (); 279 libsPanel = new javax.swing.JPanel (); 280 jLabel2 = new javax.swing.JLabel (); 281 282 setLayout(new java.awt.GridBagLayout ()); 283 284 getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_LibrariesCustomizer")); 285 jLabel1.setLabelFor(libraryName); 286 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("CTL_CustomizerLibraryName")); 287 gridBagConstraints = new java.awt.GridBagConstraints (); 288 gridBagConstraints.gridx = 2; 289 gridBagConstraints.gridy = 1; 290 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 291 gridBagConstraints.insets = new java.awt.Insets (0, 6, 12, 6); 292 add(jLabel1, gridBagConstraints); 293 294 libraryName.setEditable(false); 295 gridBagConstraints = new java.awt.GridBagConstraints (); 296 gridBagConstraints.gridx = 3; 297 gridBagConstraints.gridy = 1; 298 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 299 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 300 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 301 gridBagConstraints.weightx = 0.6; 302 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 12); 303 add(libraryName, gridBagConstraints); 304 libraryName.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_LibraryName")); 305 306 jPanel1.setLayout(new java.awt.BorderLayout ()); 307 308 properties.setPreferredSize(new java.awt.Dimension (400, 300)); 309 jPanel1.add(properties, java.awt.BorderLayout.CENTER); 310 properties.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AN_LibrariesCustomizerProperties")); 311 properties.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_LibrariesCustomizerProperties")); 312 313 gridBagConstraints = new java.awt.GridBagConstraints (); 314 gridBagConstraints.gridx = 2; 315 gridBagConstraints.gridy = 2; 316 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 317 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 318 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 319 gridBagConstraints.weightx = 1.0; 320 gridBagConstraints.weighty = 1.0; 321 gridBagConstraints.insets = new java.awt.Insets (0, 6, 12, 12); 322 add(jPanel1, gridBagConstraints); 323 324 org.openide.awt.Mnemonics.setLocalizedText(createButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("CTL_NewLibrary")); 325 createButton.addActionListener(new java.awt.event.ActionListener () { 326 public void actionPerformed(java.awt.event.ActionEvent evt) { 327 createLibrary(evt); 328 } 329 }); 330 331 gridBagConstraints = new java.awt.GridBagConstraints (); 332 gridBagConstraints.gridx = 0; 333 gridBagConstraints.gridy = 3; 334 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 335 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 12); 336 add(createButton, gridBagConstraints); 337 createButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_NewLibrary")); 338 339 org.openide.awt.Mnemonics.setLocalizedText(deleteButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("CTL_DeleteLibrary")); 340 deleteButton.addActionListener(new java.awt.event.ActionListener () { 341 public void actionPerformed(java.awt.event.ActionEvent evt) { 342 deleteLibrary(evt); 343 } 344 }); 345 346 gridBagConstraints = new java.awt.GridBagConstraints (); 347 gridBagConstraints.gridx = 1; 348 gridBagConstraints.gridy = 3; 349 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 350 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 351 add(deleteButton, gridBagConstraints); 352 deleteButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_DeleteLibrary")); 353 354 libsPanel.setLayout(new java.awt.GridBagLayout ()); 355 356 libsPanel.setBorder(new javax.swing.border.EtchedBorder ()); 357 gridBagConstraints = new java.awt.GridBagConstraints (); 358 gridBagConstraints.gridx = 0; 359 gridBagConstraints.gridy = 1; 360 gridBagConstraints.gridwidth = 2; 361 gridBagConstraints.gridheight = 2; 362 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 363 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 364 gridBagConstraints.weighty = 1.0; 365 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 6); 366 add(libsPanel, gridBagConstraints); 367 libsPanel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("AD_libsPanel")); 368 369 jLabel2.setLabelFor(libsPanel); 370 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, java.util.ResourceBundle.getBundle("org/netbeans/modules/project/libraries/ui/Bundle").getString("TXT_LibrariesPanel")); 371 gridBagConstraints = new java.awt.GridBagConstraints (); 372 gridBagConstraints.gridx = 0; 373 gridBagConstraints.gridy = 0; 374 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 375 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 376 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 377 gridBagConstraints.insets = new java.awt.Insets (12, 12, 2, 12); 378 add(jLabel2, gridBagConstraints); 379 380 } 381 383 private void deleteLibrary(java.awt.event.ActionEvent evt) { Node[] nodes = this.getExplorerManager().getSelectedNodes(); 385 if (nodes.length == 1 && (nodes[0] instanceof LibraryNode)) { 386 Node[] sib = nodes[0].getParentNode().getChildren().getNodes(true); 387 Node selNode = null; 388 for (int i=0; i < sib.length; i++) { 389 if (nodes[0].equals(sib[i])) { 390 if (i>0) { 391 selNode = sib[i-1]; 392 } 393 else if (i<sib.length-1){ 394 selNode = sib[i+1]; 395 } 396 } 397 } 398 model.removeLibrary (((LibraryNode)nodes[0]).getLibrary()); 399 try { 400 if (selNode != null) { 401 this.getExplorerManager().setSelectedNodes(new Node[] {selNode}); 402 } 403 } catch (PropertyVetoException e) { 404 } 406 this.libraries.requestFocus(); 407 } 408 } 410 private void createLibrary(java.awt.event.ActionEvent evt) { Dialog dlg = null; 412 try { 413 String preselectedLibraryType = null; 414 Node[] preselectedNodes = this.getExplorerManager().getSelectedNodes(); 415 if (preselectedNodes.length == 1) { 416 LibraryCategory lc = preselectedNodes[0].getLookup().lookup(LibraryCategory.class); 417 if (lc != null) { 418 preselectedLibraryType = lc.getCategoryType(); 419 } 420 } 421 NewLibraryPanel p = new NewLibraryPanel (this.model, preselectedLibraryType); 422 DialogDescriptor dd = new DialogDescriptor (p, NbBundle.getMessage(LibrariesCustomizer.class,"CTL_CreateLibrary"), 423 true, DialogDescriptor.OK_CANCEL_OPTION, null, null); 424 p.setDialogDescriptor(dd); 425 dlg = DialogDisplayer.getDefault().createDialog (dd); 426 dlg.setVisible(true); 427 if (dd.getValue() == DialogDescriptor.OK_OPTION) { 428 String libraryType = p.getLibraryType(); 429 String libraryName = p.getLibraryName(); 430 LibraryTypeProvider provider = LibraryTypeRegistry.getDefault().getLibraryTypeProvider (libraryType); 431 if (provider == null) { 432 return; 433 } 434 LibraryImplementation impl = provider.createLibrary(); 435 impl.setName (libraryName); 436 model.addLibrary (impl); 437 String [] path = new String [2]; 438 path[0] = impl.getType(); 439 path[1] = impl.getName(); 440 ExplorerManager mgr = this.getExplorerManager(); 441 try { 442 Node node = NodeOp.findPath(mgr.getRootContext(),path); 443 if (node != null) { 444 mgr.setSelectedNodes(new Node[] {node}); 445 } 446 } catch (PropertyVetoException e) { 447 } 449 catch (NodeNotFoundException e) { 450 } 452 this.libraryName.requestFocus(); 453 this.libraryName.selectAll(); 454 } 455 else { 456 this.libraries.requestFocus(); 457 } 458 } 459 finally { 460 if (dlg != null) 461 dlg.dispose(); 462 } 463 } 465 466 static boolean isValidName (LibrariesModel model, String name) { 467 int count = model.getSize(); 468 for (int i=0; i<count; i++) { 469 LibraryImplementation lib = (LibraryImplementation) model.getElementAt (i); 470 if (lib != null && lib.getName().equals(name)) 471 return false; 472 } 473 return true; 474 } 475 476 477 static String getLocalizedString (String bundleResourceName, String key) { 478 if (key == null) { 479 return null; 480 } 481 if (bundleResourceName == null) { 482 return key; 483 } 484 ResourceBundle bundle; 485 try { 486 bundle = NbBundle.getBundle(bundleResourceName); 487 } catch (MissingResourceException mre) { 488 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, mre); 490 return key; 491 } 492 try { 493 return bundle.getString (key); 494 } catch (MissingResourceException mre) { 495 return key; 497 } 498 } 499 500 501 private javax.swing.JButton createButton; 503 private javax.swing.JButton deleteButton; 504 private javax.swing.JLabel jLabel1; 505 private javax.swing.JLabel jLabel2; 506 private javax.swing.JPanel jPanel1; 507 private javax.swing.JTextField libraryName; 508 private javax.swing.JPanel libsPanel; 509 private javax.swing.JTabbedPane properties; 510 512 513 private static void expandAllNodes (BeanTreeView btv, Node node) { 514 btv.expandNode (node); 515 Children ch = node.getChildren(); 516 if ( ch == Children.LEAF ) { 517 return; 518 } 519 Node nodes[] = ch.getNodes( true ); 520 for ( int i = 0; i < nodes.length; i++ ) { 521 expandAllNodes( btv, nodes[i]); 522 } 523 524 } 525 526 private static class LibrariesView extends BeanTreeView { 527 528 public LibrariesView () { 529 super (); 530 this.setRootVisible(false); 531 this.setPopupAllowed(false); 532 this.setDefaultActionAllowed(false); 533 this.tree.setEditable (false); 534 this.tree.setShowsRootHandles (false); 535 } 536 537 } 538 539 540 private static class RootChildren extends Children.Keys<LibraryTypeProvider> { 541 542 private LibrariesModel model; 543 544 public RootChildren (LibrariesModel model) { 545 this.model = model; 546 } 547 548 public void addNotify () { 549 this.setKeys(LibraryTypeRegistry.getDefault().getLibraryTypeProviders()); 550 } 551 552 public void removeNotify () { 553 this.setKeys(new LibraryTypeProvider[0]); 554 } 555 556 protected Node[] createNodes(LibraryTypeProvider provider) { 557 return new Node[] {new CategoryNode(provider, model)}; 558 } 559 560 } 561 562 563 private static final class LibraryCategory { 564 565 private final String name; 566 567 LibraryCategory (String name) { 568 this.name = name; 569 } 570 571 public String getCategoryType () { 572 return this.name; 573 } 574 575 } 576 577 private static class CategoryNode extends AbstractNode { 578 579 580 private LibraryTypeProvider provider; 581 private Node iconDelegate; 582 583 public CategoryNode (LibraryTypeProvider provider, LibrariesModel model) { 584 super (new CategoryChildren(provider, model), Lookups.singleton(new LibraryCategory (provider.getLibraryType()))); 585 this.provider = provider; 586 this.iconDelegate = DataFolder.findFolder (Repository.getDefault().getDefaultFileSystem().getRoot()).getNodeDelegate(); 587 } 588 589 public String getName () { 590 return provider.getLibraryType (); 591 } 592 593 public String getDisplayName() { 594 return this.provider.getDisplayName(); 595 } 596 597 public Image getIcon(int type) { 598 return this.iconDelegate.getIcon (type); 599 } 600 601 public Image getOpenedIcon(int type) { 602 return this.iconDelegate.getOpenedIcon (type); 603 } 604 605 } 606 607 private static class CategoryChildren extends Children.Keys<LibraryImplementation> implements ListDataListener { 608 609 private LibraryTypeProvider provider; 610 private LibrariesModel model; 611 612 public CategoryChildren (LibraryTypeProvider provider, LibrariesModel model) { 613 this.provider = provider; 614 this.model = model; 615 this.model.addListDataListener(this); 616 } 617 618 public void addNotify () { 619 Collection <LibraryImplementation> keys = new ArrayList <LibraryImplementation>(); 620 for (int i=0; i<model.getSize(); i++) { 621 LibraryImplementation impl = (LibraryImplementation) model.getElementAt(i); 622 if (this.provider.getLibraryType().equals(impl.getType())) { 623 keys.add (impl); 624 } 625 } 626 this.setKeys(keys); 627 } 628 629 public void removeNotify () { 630 this.setKeys(new LibraryImplementation[0]); 631 } 632 633 protected Node[] createNodes(LibraryImplementation impl) { 634 return new Node[] {new LibraryNode(impl, provider)}; 635 } 636 637 public void contentsChanged(ListDataEvent e) { 638 this.addNotify(); 640 } 641 642 public void intervalAdded(ListDataEvent e) { 643 this.addNotify(); 645 } 646 647 public void intervalRemoved(ListDataEvent e) { 648 this.addNotify(); 650 } 651 652 } 653 654 private static class LibraryNode extends AbstractNode { 655 656 private static final String ICON = "org/netbeans/modules/project/libraries/resources/libraries.gif"; 658 private LibraryImplementation lib; 659 private LibraryTypeProvider provider; 660 661 public LibraryNode (LibraryImplementation lib, LibraryTypeProvider provider) { 662 super (Children.LEAF); 663 this.lib = lib; 664 this.provider = provider; 665 this.setIconBaseWithExtension(ICON); 666 } 667 668 public String getName () { 669 return this.lib.getName (); 670 } 671 672 public String getDisplayName () { 673 return getLocalizedString(this.lib.getLocalizingBundle(), this.lib.getName()); 674 } 675 676 public LibraryImplementation getLibrary () { 677 return this.lib; 678 } 679 680 public LibraryTypeProvider getProvider () { 681 return this.provider; 682 } 683 684 public boolean equals (Object other) { 685 if (other instanceof LibraryNode) { 686 LibraryNode ol = (LibraryNode) other; 687 return (this.lib == null ? ol.lib == null : this.lib.equals(ol.lib)) 688 && (this.provider == null ? ol.provider == null : this.provider.equals(ol.provider)); 689 } 690 return false; 691 } 692 } 693 694 private static Node buildTree (LibrariesModel model) { 695 return new AbstractNode (new RootChildren (model)); 696 } 697 698 699 } 700 | Popular Tags |