int (@NotNull Project project, @NotNull Component parent) { Set<Module> existing = new HashSet<>(); for (Item item : myItems) { existing.add(item.module); } List<Module> candidates = new ArrayList<>(); for (Module module : ModuleManager.getInstance(project).getModules()) { if (!existing.contains(module)) { candidates.add(module); } } if (!candidates.isEmpty()) { candidates.sort(Comparator.comparing(Module::getName)); ChooseModulesDialog chooser = new ChooseModulesDialog(parent, candidates, JavaCompilerBundle.message("dialog.title.choose.module")); chooser.show(); List<Module> chosen = chooser.getChosenElements(); if (!chosen.isEmpty()) { for (Module module : chosen) { myItems.add(new Item(module)); } sortItems(); fireTableDataChanged(); for (int i = 0; i < myItems.size(); i++) { if (myItems.get(i).module.equals(chosen.get(0))) { return i; } } } } return -1; }