use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.
the class IdeFrameFixture method debuggerTreeRootToChildrenTexts.
@NotNull
private static String[] debuggerTreeRootToChildrenTexts(XDebuggerTreeNode treeRoot) {
List<? extends TreeNode> children = treeRoot.getChildren();
String[] childrenTexts = new String[children.size()];
int i = 0;
for (TreeNode child : children) {
childrenTexts[i] = ((XDebuggerTreeNode) child).getText().toString();
++i;
}
return childrenTexts;
}
use of javax.swing.tree.TreeNode in project android by JetBrains.
the class ClassesTreeView method restoreViewState.
private void restoreViewState(@NotNull final SelectionModel selectionModel) {
ClassObj classToSelect = selectionModel.getClassObj();
TreeNode nodeToSelect = null;
if (classToSelect != null) {
nodeToSelect = findClassObjNode(classToSelect);
}
sortTree(myRoot);
myTreeModel.nodeStructureChanged(myRoot);
final TreeNode targetNode = nodeToSelect;
if (targetNode != null) {
// If the new heap has the selected class (from a previous heap), then select it and scroll to it.
myColumnTree.revalidate();
final TreePath pathToSelect = new TreePath(myTreeModel.getPathToRoot(targetNode));
myTree.setSelectionPath(pathToSelect);
// This is kind of clunky, but the viewport doesn't know how big the tree is until it repaints.
// We need to do this because the contents of this tree has been more or less completely replaced.
// Unfortunately, calling repaint() only queues it, so we actually need an extra frame to select the node.
ApplicationManager.getApplication().invokeLater(() -> myTree.scrollPathToVisible(pathToSelect));
} else {
selectionModel.setClassObj(null);
if (myTree.getRowCount() > 0) {
myTree.scrollRowToVisible(0);
}
}
}
use of javax.swing.tree.TreeNode in project android by JetBrains.
the class PackageNode method getQualifiedName.
@NotNull
public String getQualifiedName() {
TreeNode parent = getParent();
String pkg = parent instanceof PackageNode ? ((PackageNode) parent).getQualifiedName() : "";
return pkg.isEmpty() ? myName : pkg + "." + myName;
}
use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.
the class GradleProjectCompositeSelectorDialog method createTree.
private CheckboxTree createTree() {
final CheckedTreeNode root = new CheckedTreeNode();
if (myCompositeRootSettings != null) {
List<TreeNode> nodes = ContainerUtil.newArrayList();
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);
}
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))
return;
CheckedTreeNode node = (CheckedTreeNode) value;
if (!(node.getUserObject() instanceof Pair))
return;
Pair pair = (Pair) node.getUserObject();
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;
}
use of javax.swing.tree.TreeNode in project jmeter by apache.
the class Move method moveAndSelectNode.
private static void moveAndSelectNode(JMeterTreeNode currentNode, JMeterTreeNode parentNode, int newIndx) {
GuiPackage guiInstance = GuiPackage.getInstance();
guiInstance.getTreeModel().removeNodeFromParent(currentNode);
guiInstance.getTreeModel().insertNodeInto(currentNode, parentNode, newIndx);
// select the node
TreeNode[] nodes = guiInstance.getTreeModel().getPathToRoot(currentNode);
JTree jTree = guiInstance.getMainFrame().getTree();
jTree.setSelectionPath(new TreePath(nodes));
}
Aggregations