| 553 | |
| 554 | |
| 555 | public void rebuildImportMenu() { //JMenu importMenu) { |
| 556 | if (importMenu == null) { |
| 557 | importMenu = new JMenu(Language.text("menu.library")); |
| 558 | } else { |
| 559 | //System.out.println("rebuilding import menu"); |
| 560 | importMenu.removeAll(); |
| 561 | } |
| 562 | |
| 563 | JMenuItem addLib = new JMenuItem(Language.text("menu.library.add_library")); |
| 564 | addLib.addActionListener(new ActionListener() { |
| 565 | public void actionPerformed(ActionEvent e) { |
| 566 | ContributionManager.openLibraries(); |
| 567 | } |
| 568 | }); |
| 569 | importMenu.add(addLib); |
| 570 | importMenu.addSeparator(); |
| 571 | |
| 572 | rebuildLibraryList(); |
| 573 | |
| 574 | ActionListener listener = new ActionListener() { |
| 575 | public void actionPerformed(ActionEvent e) { |
| 576 | base.activeEditor.handleImportLibrary(e.getActionCommand()); |
| 577 | } |
| 578 | }; |
| 579 | |
| 580 | // try { |
| 581 | // pw = new PrintWriter(new FileWriter(System.getProperty("user.home") + "/Desktop/libs.csv")); |
| 582 | // } catch (IOException e1) { |
| 583 | // e1.printStackTrace(); |
| 584 | // } |
| 585 | |
| 586 | if (coreLibraries.size() == 0) { |
| 587 | JMenuItem item = new JMenuItem(getTitle() + " " + Language.text("menu.library.no_core_libraries")); |
| 588 | item.setEnabled(false); |
| 589 | importMenu.add(item); |
| 590 | } else { |
| 591 | for (Library library : coreLibraries) { |
| 592 | JMenuItem item = new JMenuItem(library.getName()); |
| 593 | item.addActionListener(listener); |
| 594 | |
| 595 | // changed to library-name to facilitate specification of imports from properties file |
| 596 | item.setActionCommand(library.getName()); |
| 597 | |
| 598 | importMenu.add(item); |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | if (contribLibraries.size() != 0) { |
| 603 | importMenu.addSeparator(); |
| 604 | JMenuItem contrib = new JMenuItem(Language.text("menu.library.contributed")); |
| 605 | contrib.setEnabled(false); |
| 606 | importMenu.add(contrib); |
| 607 | |
| 608 | HashMap<String, JMenu> subfolders = new HashMap<>(); |
| 609 | |
| 610 | for (Library library : contribLibraries) { |
| 611 | JMenuItem item = new JMenuItem(library.getName()); |
| 612 | item.addActionListener(listener); |