use of com.intellij.ui.CheckedTreeNode in project intellij-community by JetBrains.
the class BreakpointItemsTreeController method buildTree.
public void buildTree(@NotNull Collection<? extends BreakpointItem> breakpoints) {
final TreeState state = TreeState.createOn(myTreeView, myRoot);
myRoot.removeAllChildren();
myNodes.clear();
myGroups.clear();
for (BreakpointItem breakpoint : breakpoints) {
BreakpointItemNode node = new BreakpointItemNode(breakpoint);
CheckedTreeNode parent = getParentNode(breakpoint);
parent.add(node);
myNodes.put(breakpoint, node);
}
TreeUtil.sortRecursively(myRoot, myComparator);
myInBuild = true;
((DefaultTreeModel) (myTreeView.getModel())).nodeStructureChanged(myRoot);
state.applyTo(myTreeView, myRoot);
myInBuild = false;
}
use of com.intellij.ui.CheckedTreeNode in project android by JetBrains.
the class ModuleVariantsInfoDialog method createDependentsTree.
@NotNull
private static JTree createDependentsTree(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
VariantCheckboxTreeCellRenderer renderer = new VariantCheckboxTreeCellRenderer() {
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof DefaultMutableTreeNode) {
Object data = ((DefaultMutableTreeNode) value).getUserObject();
if (data instanceof String) {
appendVariant((String) data);
} else if (data instanceof DependentTreeElement) {
DependentTreeElement dependent = (DependentTreeElement) data;
String variant = null;
if (!dependent.myVariants.isEmpty()) {
variant = Joiner.on(", ").join(dependent.myVariants);
}
appendModule(dependent.myModule, variant);
}
}
}
};
//noinspection ConstantConditions
CheckedTreeNode root = new CheckedTreeNode(null);
AndroidProject androidProject = GradleUtil.getAndroidProject(module);
assert androidProject != null;
String gradlePath = GradleUtil.getGradlePath(module);
assert gradlePath != null;
Multimap<String, DependentTreeElement> dependentsByVariant = HashMultimap.create();
ModuleManager moduleManager = ModuleManager.getInstance(module.getProject());
for (Module dependent : moduleManager.getModuleDependentModules(module)) {
AndroidProject dependentProject = GradleUtil.getAndroidProject(dependent);
if (dependentProject == null) {
continue;
}
DependentTreeElement element = new DependentTreeElement(dependent);
for (Variant variant : dependentProject.getVariants()) {
for (AndroidLibrary library : GradleUtil.getDirectLibraryDependencies(variant, androidModel)) {
if (gradlePath.equals(library.getProject())) {
element.addVariant(variant.getName());
String projectVariant = library.getProjectVariant();
if (StringUtil.isNotEmpty(projectVariant)) {
dependentsByVariant.put(projectVariant, element);
}
}
}
}
}
List<String> variantNames = Lists.newArrayList(dependentsByVariant.keySet());
Collections.sort(variantNames);
for (String variantName : variantNames) {
Collection<DependentTreeElement> dependents = dependentsByVariant.get(variantName);
if (!dependents.isEmpty()) {
List<DependentTreeElement> sortedDependents = Lists.newArrayList(dependents);
Collections.sort(sortedDependents);
DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(variantName);
for (DependentTreeElement dependent : dependents) {
variantNode.add(new DefaultMutableTreeNode(dependent));
}
root.add(variantNode);
}
}
CheckboxTree tree = new CheckboxTree(renderer, root);
tree.setRootVisible(false);
TreeUtil.expandAll(tree);
return tree;
}
use of com.intellij.ui.CheckedTreeNode in project intellij-plugins by JetBrains.
the class FlexBCTree method iterateRecursively.
private static void iterateRecursively(final CheckedTreeNode node, final boolean iterateChecked, final Consumer<Pair<Module, FlexBuildConfiguration>> consumer) {
if (node.isLeaf()) {
if (node.isChecked() == iterateChecked && node.getParent() instanceof CheckedTreeNode) {
final Object userObject = node.getUserObject();
final Object parentUserObject = ((CheckedTreeNode) node.getParent()).getUserObject();
if (userObject instanceof FlexBuildConfiguration && parentUserObject instanceof Module) {
consumer.consume(Pair.create((Module) parentUserObject, (FlexBuildConfiguration) userObject));
}
}
} else {
// do not try to optimize asking non-leaf node about its checked status - it may give unexpected result!
final Enumeration children = node.children();
while (children.hasMoreElements()) {
iterateRecursively((CheckedTreeNode) children.nextElement(), iterateChecked, consumer);
}
}
}
use of com.intellij.ui.CheckedTreeNode in project intellij-plugins by JetBrains.
the class FlexBCTree method installSpeedSearch.
protected void installSpeedSearch() {
new TreeSpeedSearch(this, path -> {
final CheckedTreeNode node = (CheckedTreeNode) path.getLastPathComponent();
final Object userObject = node.getUserObject();
if (userObject instanceof Project) {
return ((Project) userObject).getName();
} else if (userObject instanceof Module) {
return ((Module) userObject).getName();
} else if (userObject instanceof FlexBuildConfiguration) {
return ((FlexBuildConfiguration) userObject).getName();
}
return null;
});
}
use of com.intellij.ui.CheckedTreeNode in project intellij-plugins by JetBrains.
the class FlexBCTree method getBCNode.
private CheckedTreeNode getBCNode(final String moduleName, final String bcName) {
final Enumeration moduleNodes = ((CheckedTreeNode) getModel().getRoot()).children();
while (moduleNodes.hasMoreElements()) {
final CheckedTreeNode moduleNode = (CheckedTreeNode) moduleNodes.nextElement();
final Object userObject = moduleNode.getUserObject();
if (userObject instanceof Module && ((Module) userObject).getName().equals(moduleName)) {
final Enumeration bcNodes = moduleNode.children();
while (bcNodes.hasMoreElements()) {
final CheckedTreeNode bcNode = (CheckedTreeNode) bcNodes.nextElement();
final Object bcUserObject = bcNode.getUserObject();
if (bcUserObject instanceof FlexBuildConfiguration && ((FlexBuildConfiguration) bcUserObject).getName().equals(bcName)) {
return bcNode;
}
}
return null;
}
}
return null;
}
Aggregations