boolean (@NotNull final List<? extends Pair<String, Path>> orphanModules, @NotNull final Project project) { final CheckBoxList<Pair<String, Path>> orphanModulesList = new CheckBoxList<>(); DialogWrapper dialog = new DialogWrapper(project) { { setTitle(ExternalSystemBundle.message("orphan.modules.dialog.title")); init(); } @Override protected JComponent createCenterPanel() { orphanModulesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); orphanModulesList.setItems(orphanModules, module -> FileUtilRt.getNameWithoutExtension(new File(module.getFirst()).getName())); //NON-NLS orphanModulesList.setBorder(JBUI.Borders.empty(5)); JScrollPane myModulesScrollPane = ScrollPaneFactory.createScrollPane(orphanModulesList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); myModulesScrollPane.setBorder(new MatteBorder(0, 0, 1, 0, JBColor.border())); myModulesScrollPane.setMaximumSize(new Dimension(-1, 300)); JPanel content = new JPanel(new BorderLayout()); content.add(myModulesScrollPane, BorderLayout.CENTER); return content; } @NotNull @Override protected JComponent createNorthPanel() { GridBagConstraints gbConstraints = new GridBagConstraints(); JPanel panel = new JPanel(new GridBagLayout()); gbConstraints.insets = JBUI.insets(4, 0, 10, 8); panel.add(new JLabel(ExternalSystemBundle.message("orphan.modules.dialog.text")), gbConstraints); return panel; } }; if (dialog.showAndGet()) { ExternalSystemApiUtil.doWriteAction(() -> { for (int i = 0; i < orphanModules.size(); i++) { Pair<String, Path> pair = orphanModules.get(i); String originalPath = pair.first; Path savedPath = pair.second; if (orphanModulesList.isItemSelected(i) && savedPath.toFile().isFile()) { try { File file = new File(originalPath); FileUtil.copy(savedPath.toFile(), file); ModuleManager.getInstance(project).loadModule(file.toPath()); } catch (IOException | ModuleWithNameAlreadyExists e) { LOG.warn(e); } } } }); return true; } return false; }