void (@NotNull Module module) { final TreePath selectionPath = myTree.getSelectionPath(); MyNode parent = null; if (selectionPath != null) { MyNode selected = (MyNode)selectionPath.getLastPathComponent(); final Object o = selected.getConfigurable().getEditableObject(); if (o instanceof ModuleGroup) { if (!ModuleGrouperKt.isQualifiedModuleNamesEnabled(module.getProject())) { myContext.myModulesConfigurator.getModuleModel().setModuleGroupPath(module, ((ModuleGroup)o).getGroupPath()); } parent = selected; } else if (o instanceof Module) { //create near selected final ModifiableModuleModel modifiableModuleModel = myContext.myModulesConfigurator.getModuleModel(); final String[] groupPath = modifiableModuleModel.getModuleGroupPath((Module)o); if (groupPath != null) { modifiableModuleModel.setModuleGroupPath(module, groupPath); parent = findNodeByObject(myRoot, new ModuleGroup(Arrays.asList(groupPath))); } } } if (parent == null) parent = myRoot; MyNode node = createModuleNode(module, getModuleGrouper()); TreeUtil.insertNode(node, parent, getTreeModel(), getNodeComparator()); selectNodeInTree(node); final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer(); daemonAnalyzer.queueUpdate(new ModuleProjectStructureElement(myContext, module)); daemonAnalyzer.queueUpdateForAllElementsWithErrors(); //missing modules added }