CheckboxTree () { final CheckedTreeNode root = new CheckedTreeNode(); if (myCompositeRootSettings != null) { List<CheckedTreeNode> nodes = new ArrayList<>(); for (GradleProjectSettings projectSettings : GradleSettings.getInstance(myProject).getLinkedProjectsSettings()) { if (projectSettings == myCompositeRootSettings) continue; if (projectSettings.getCompositeBuild() != null && projectSettings.getCompositeBuild().getCompositeDefinitionSource() == CompositeDefinitionSource.SCRIPT) { continue; } GradleProjectSettings.CompositeBuild compositeBuild = myCompositeRootSettings.getCompositeBuild(); boolean added = compositeBuild != null && compositeBuild.getCompositeParticipants().stream() .anyMatch(participant -> pathsEqual(participant.getRootPath(), projectSettings.getExternalProjectPath())); String representationName = myExternalSystemUiAware.getProjectRepresentationName( projectSettings.getExternalProjectPath(), projectSettings.getExternalProjectPath()); CheckedTreeNode treeNode = new CheckedTreeNode(Pair.create(representationName, projectSettings.getExternalProjectPath())); treeNode.setChecked(added); nodes.add(treeNode); } ContainerUtil.sort(nodes, (o1, o2) -> StringUtil.naturalCompare((String)((Pair<?, ?>)o1.getUserObject()).first, (String)((Pair<?, ?>)o2.getUserObject()).first)); TreeUtil.addChildrenTo(root, nodes); } 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 CheckedTreeNode node)) return; if (!(node.getUserObject() instanceof Pair pair)) return; ColoredTreeCellRenderer renderer = getTextRenderer(); renderer.setIcon(myExternalSystemUiAware.getProjectIcon()); String projectName = (String)pair.first; renderer.append(projectName, SimpleTextAttributes.REGULAR_ATTRIBUTES); String projectPath = StringUtil.trimMiddle((String)pair.second, MAX_PATH_LENGTH); renderer.append(" (" + projectPath + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); setToolTipText((String)pair.second); } }, root); TreeUtil.expand(tree, 1); return tree; }