@Override public int getRowCount() { return tree.getRowCount(); }
public void restoreExpanstionState(Set<String> expansionState) { if (tree != null && expansionState != null) { // tree.getRowCount() changes at tree.expandRow() for (int i = 0; i < tree.getRowCount(); i++) { TreePath path = tree.getPathForRow(i); if (expansionState.contains(getRowPathStr(path))) { tree.expandRow(i); } } } }
public Set<String> getExpansionState() { Set<String> openedSet = new HashSet<>(); if (tree != null) { int rowCount = tree.getRowCount(); for (int i = 0; i < rowCount; i++) { TreePath path = tree.getPathForRow(i); if (tree.isExpanded(path)) { String rowPathStr = getRowPathStr(path); // for switching Package Explorer on/off openedSet.addAll(getAllParentPathsStr(rowPathStr)); } } } return openedSet; }
for (int ii = tree.getRowCount(); ii>-1; ii--) { tree.expandRow(ii);
for (int ii=0; ii<tree.getRowCount(); ii++) { tree.expandRow(ii);
/** * Collapse the tree so that only the root node is visible. */ public void collapseTree() { for (int i = 1; i < resultsTree.getRowCount(); ++i) { resultsTree.collapseRow(i); } }
protected void collapseTree() { // collapse everything except the first category CategoryExplorerTree tree = _monitor.getCategoryExplorerTree(); for (int i = tree.getRowCount() - 1; i > 0; i--) { tree.collapseRow(i); } }
protected void init() { // Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("XChart Example Charts"); createNodes(top); tree = new JTree(top); // Create a tree that allows one selection at a time. tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes. tree.addTreeSelectionListener(this); // Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); // Create Chart Panel tabbedPane = new JTabbedPane(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } // select first leaf DefaultMutableTreeNode firstLeaf = top.getFirstLeaf(); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); // Add the scroll panes to a split pane. splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(tabbedPane); Dimension minimumSize = new Dimension(130, 160); treeView.setMinimumSize(minimumSize); splitPane.setPreferredSize(new Dimension(700, 700)); // Add the split pane to this panel. add(splitPane); }
/** * Returns the number of rows in the {@link JTree}. * * @return The int number of rows in the JTree. */ public int getRowCount() { return tree.getRowCount(); }
private void expandAllNodes(JTree tree, int startingIndex, int rowCount){ for(int i=startingIndex;i<rowCount;++i){ tree.expandRow(i); } if(tree.getRowCount()!=rowCount){ expandAllNodes(tree, rowCount, tree.getRowCount()); } }
void expandAll( int startingIndex, int rowCount ) { for( int i = startingIndex; i < rowCount; ++i ) { _tree.expandRow( i ); } if( _tree.getRowCount() != rowCount ) { expandAll( rowCount, _tree.getRowCount() ); } }
@SuppressWarnings("UnusedDeclaration") public void expandAll() { expandAll( 0, _tree.getRowCount() ); } void expandAll( int startingIndex, int rowCount )
void expandAll( int startingIndex, int rowCount ) { for( int i = startingIndex; i < rowCount; ++i ) { _tree.expandRow( i ); } if( _tree.getRowCount() != rowCount ) { expandAll( rowCount, _tree.getRowCount() ); } }
void expandAll( int startingIndex, int rowCount ) { for( int i = startingIndex; i < rowCount; ++i ) { _tree.expandRow( i ); } if( _tree.getRowCount() != rowCount ) { expandAll( rowCount, _tree.getRowCount() ); } }
/** * Expand configuration tree * * @param tree The tree we want to process. */ private void expandAll(JTree tree) { for (int row = 0; row < tree.getRowCount(); row++) { tree.expandRow(row); } } }
public void actionPerformed(ActionEvent e) { for (int i = 1; i < tree.getRowCount(); i++) { if (cbExp.isSelected()) { tree.expandRow(i); } else { tree.collapseRow(i); } } } }
@Override protected int getElementCount() { if (!isRecursive()) { return ((JTree) _component).getRowCount(); } else { return getTreePathes().size(); } }
private void selectVeryFirstLeaf() { if (historyTree == null || historyTree.getRowCount() < 1) return; historyTree.expandRow(1); DefaultMutableTreeNode firstLeaf = ((DefaultMutableTreeNode) historyTree .getModel().getRoot()).getFirstLeaf(); TreePath path = new TreePath(firstLeaf.getPath()); historyTree.setSelectionPath(path); }
void writeAll() { for( int i = 0; i < getJTree().getRowCount(); i++ ) { final TreePath p = getJTree().getPathForRow( i ); writeBack( ( DefaultMutableTreeNode ) p.getLastPathComponent() ); } } }
/** * Returns the treePath for the row or null if invalid. * */ public TreePath getTreePath() { if (getComponent() == null) return null; if ((row < 0) || (row >= getComponent().getRowCount())) return null; return getComponent().getPathForRow(row); } /**