void (boolean checked) { List<DataNode<Identifiable>> selectedModules = new SmartList<>(); for (DataNode node : TreeUtil.collectSelectedObjectsOfType(myTree, DataNode.class)) { if (myDependencyAwareDataKeys.contains(node.getKey())) { //noinspection unchecked selectedModules.add(node); } } final Set<DataNode<Identifiable>> deps = new HashSet<>(); for (DataNode<Identifiable> selectedModule : selectedModules) { if (checked) { deps.addAll(ContainerUtil.filter(dependentNodeMap.get(selectedModule), node -> { final DataNodeCheckedTreeNode uiNode = node.getUserData(CONNECTED_UI_NODE_KEY); return uiNode != null && !uiNode.isChecked(); })); } else { for (DataNode<Identifiable> node : dependentNodeMap.keySet()) { final DataNodeCheckedTreeNode uiNode = node.getUserData(CONNECTED_UI_NODE_KEY); if (uiNode != null && !uiNode.isChecked()) continue; Collection<DataNode<Identifiable>> dependencies = dependentNodeMap.get(node); if (dependencies.contains(selectedModule)) { deps.add(node); } } } } if (!deps.isEmpty()) { final String message = checked ? getEnableMessage(selectedModules, deps) : getDisableMessage(deps); if (Messages.showOkCancelDialog(message, checked ? ExternalSystemBundle.message("enable.dependant.modules") : ExternalSystemBundle.message("disable.modules.with.dependency.on.this"), Messages.getQuestionIcon()) == Messages.OK) { List<DataNodeCheckedTreeNode> nodes = ContainerUtil.mapNotNull(deps, node -> node.getUserData(CONNECTED_UI_NODE_KEY)); for (DataNodeCheckedTreeNode node : nodes) { DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel(); myTree.addSelectionPath(new TreePath(treeModel.getPathToRoot(node))); } for (DataNodeCheckedTreeNode node : nodes) { node.setChecked(checked); } } } }