CheckboxTree () { final Couple<CheckedTreeNode> rootAndPreselectedNode = createRoot(); final CheckedTreeNode root = rootAndPreselectedNode.first; final CheckboxTree tree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer(true, false) { @Override public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (!(value instanceof DataNodeCheckedTreeNode node)) { return; } String tooltip = null; boolean hasErrors = false; if (node.isChecked()) { final Enumeration children = node.children(); while (children.hasMoreElements()) { final Object o = children.nextElement(); if (o instanceof DataNodeCheckedTreeNode && !((DataNodeCheckedTreeNode)o).isChecked()) { myCheckbox.setEnabled(false); break; } } if (myDependencyAwareDataKeys.contains(node.myDataNode.getKey())) { //noinspection unchecked final String listOfUncheckedDependencies = StringUtil .join(dependentNodeMap.get((DataNode<Identifiable>)node.myDataNode), depNode -> { final DataNodeCheckedTreeNode uiNode = depNode.getUserData(CONNECTED_UI_NODE_KEY); return uiNode != null && !uiNode.isChecked() ? depNode.getData().getId() : null; }, "<br>"); if (StringUtil.isNotEmpty(listOfUncheckedDependencies)) { hasErrors = true; tooltip = ExternalSystemBundle.message("there.are.not.selected.module.dependencies.of.the.module.br.b.0.b", listOfUncheckedDependencies); } } } ColoredTreeCellRenderer renderer = getTextRenderer(); renderer.setIcon(node.icon); renderer.append(node.text, hasErrors ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); if (!StringUtil.isEmptyOrSpaces(node.comment)) { String description = node.comment; if (node.comment.length() > MAX_PATH_LENGTH) { description = node.comment.substring(0, MAX_PATH_LENGTH) + "..."; } renderer.append(" (" + description + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); setToolTipText(StringUtil.isEmpty(tooltip) ? node.comment : tooltip); } else { setToolTipText(StringUtil.isNotEmpty(tooltip) ? tooltip : null); } } }, root, new CheckboxTreeBase.CheckPolicy(true, true, false, false)); TreeUtil.expand(tree, 1); if (rootAndPreselectedNode.second != null) { TreeUtil.selectNode(tree, rootAndPreselectedNode.second); } else { tree.setSelectionRow(0); } return tree; }