MCPcopy Index your code
hub / github.com/benfry/processing4 / rebuildImportMenu

Method rebuildImportMenu

app/src/processing/app/Mode.java:495–564  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

493
494
495 public void rebuildImportMenu() { //JMenu importMenu) {
496 if (importMenu == null) {
497 importMenu = new JMenu(Language.text("menu.library"));
498 } else {
499 //System.out.println("rebuilding import menu");
500 importMenu.removeAll();
501 }
502
503 JMenuItem manageLibs = new JMenuItem(Language.text("menu.library.manage_libraries"));
504 manageLibs.addActionListener(e -> ContributionManager.openLibraries());
505 importMenu.add(manageLibs);
506 importMenu.addSeparator();
507
508 rebuildLibraryList();
509
510 ActionListener listener = e -> base.activeEditor.handleImportLibrary(e.getActionCommand());
511
512// try {
513// pw = new PrintWriter(new FileWriter(System.getProperty("user.home") + "/Desktop/libs.csv"));
514// } catch (IOException e1) {
515// e1.printStackTrace();
516// }
517
518 if (coreLibraries.size() == 0) {
519 JMenuItem item = new JMenuItem(getTitle() + " " + Language.text("menu.library.no_core_libraries"));
520 item.setEnabled(false);
521 importMenu.add(item);
522
523 } else {
524 for (Library library : coreLibraries) {
525 JMenuItem item = new JMenuItem(library.getName());
526 item.addActionListener(listener);
527
528 // changed to library-name to facilitate specification of imports from properties file
529 item.setActionCommand(library.getName());
530
531 importMenu.add(item);
532 }
533 }
534
535 if (contribLibraries.size() != 0) {
536 importMenu.addSeparator();
537 JMenuItem contrib = new JMenuItem(Language.text("menu.library.contributed"));
538 contrib.setEnabled(false);
539 importMenu.add(contrib);
540
541 Map<String, JMenu> subfolders = new HashMap<>();
542
543 for (Library library : contribLibraries) {
544 JMenuItem item = new JMenuItem(library.getName());
545 item.addActionListener(listener);
546
547 // changed to library-name to facilitate specification if imports from properties file
548 item.setActionCommand(library.getName());
549
550 String group = library.getGroup();
551 if (group != null) {
552 JMenu subMenu = subfolders.get(group);

Callers 3

getImportMenuMethod · 0.95
refreshContribsMethod · 0.80
rebuildSketchbookMethod · 0.80

Calls 11

textMethod · 0.95
openLibrariesMethod · 0.95
rebuildLibraryListMethod · 0.95
getTitleMethod · 0.95
getGroupMethod · 0.80
getMethod · 0.65
addMethod · 0.45
handleImportLibraryMethod · 0.45
sizeMethod · 0.45
getNameMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected