use of javax.swing.tree.TreeNode in project jmeter by apache.
the class CollapseExpandTreeBranch method doAction.
/**
* This method performs the actual command processing.
*
* @param e the generic UI action event
*/
@Override
public void doAction(ActionEvent e) {
JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
JTree jTree = GuiPackage.getInstance().getMainFrame().getTree();
JMeterTreeNode[] selectedNodes = treeListener.getSelectedNodes();
for (JMeterTreeNode currentNode : selectedNodes) {
if (!currentNode.isLeaf()) {
TreeNode[] nodes = GuiPackage.getInstance().getTreeModel().getPathToRoot(currentNode);
TreePath path = new TreePath(nodes);
boolean collapse = ActionNames.COLLAPSE.equals(e.getActionCommand());
expandCollapseNode(jTree, path, collapse);
}
}
}
use of javax.swing.tree.TreeNode in project jmeter by apache.
the class CollapseExpandTreeBranch method expandCollapseNode.
private void expandCollapseNode(JTree jTree, TreePath parent, boolean collapse) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.isLeaf()) {
return;
}
Enumeration<?> children = node.children();
while (children.hasMoreElements()) {
TreeNode child = (TreeNode) children.nextElement();
TreePath path = parent.pathByAddingChild(child);
expandCollapseNode(jTree, path, collapse);
}
if (collapse) {
jTree.collapsePath(parent);
} else {
jTree.expandPath(parent);
}
}
use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.
the class InspectionViewNavigationPanel method resetChildrenNavigation.
private void resetChildrenNavigation() {
final int currentChildrenCount = myNode.getChildCount();
if (myShownChildrenCount != currentChildrenCount) {
myLinks.removeAll();
myLinks.add(Box.createVerticalStrut(JBUI.scale(10)));
for (int i = 0; i < currentChildrenCount; i++) {
final TreeNode child = myNode.getChildAt(i);
final LinkLabel link = new LinkLabel(child.toString(), null) {
@Override
public void doClick() {
TreeUtil.selectInTree((DefaultMutableTreeNode) child, true, myTree);
}
};
link.setBorder(IdeBorderFactory.createEmptyBorder(1, 17, 3, 1));
myLinks.add(link);
}
myShownChildrenCount = currentChildrenCount;
}
}
use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.
the class CachedInspectionTreeNode method dropCache.
@SuppressWarnings("ResultOfMethodCallIgnored")
protected void dropCache(Project project) {
myValid = calculateIsValid();
myPresentableName = calculatePresentableName();
for (int i = 0; i < getChildCount(); i++) {
TreeNode child = getChildAt(i);
if (child instanceof CachedInspectionTreeNode) {
((CachedInspectionTreeNode) child).dropCache(project);
}
}
}
use of javax.swing.tree.TreeNode in project intellij-community by JetBrains.
the class DetectedFrameworksTree method collapseDirectoryNode.
private static FrameworkDirectoryNode collapseDirectoryNode(FrameworkDirectoryNode node) {
if (node.getChildCount() == 1) {
final TreeNode child = node.getChildAt(0);
if (child instanceof FrameworkDirectoryNode) {
return collapseDirectoryNode((FrameworkDirectoryNode) child);
}
}
for (int i = 0; i < node.getChildCount(); i++) {
TreeNode child = node.getChildAt(i);
if (child instanceof FrameworkDirectoryNode) {
final FrameworkDirectoryNode collapsed = collapseDirectoryNode((FrameworkDirectoryNode) child);
if (collapsed != child) {
node.remove(i);
node.insert(collapsed, i);
}
}
}
return node;
}
Aggregations