Java Code Examples for javax.swing.tree.TreeModel#getIndexOfChild()
The following examples show how to use
javax.swing.tree.TreeModel#getIndexOfChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfilerTreeTable.java From netbeans with Apache License 2.0 | 6 votes |
TreePath getNextPath(TreePath path, boolean down) { TreeModel _model = model.treeModel; TreeNode node = (TreeNode)path.getLastPathComponent(); if (down && _model.getChildCount(node) > 0) return path.pathByAddingChild(_model.getChild(node, 0)); TreePath parentPath = path.getParentPath(); if (!down && parentPath == null) return path.pathByAddingChild(_model.getChild(node, 0)); TreeNode parent = (TreeNode)parentPath.getLastPathComponent(); int idx = _model.getIndexOfChild(parent, node) + 1; if (_model.getChildCount(parent) > idx) return parentPath.pathByAddingChild(_model.getChild(parent, idx)); if (!down && parentPath.getParentPath() == null) { return parentPath.pathByAddingChild(_model.getChild(parent, 0)); } else { return getNextPath(parentPath, false); } }
Example 2
Source File: ProfilerTreeTable.java From visualvm with GNU General Public License v2.0 | 6 votes |
TreePath getNextPath(TreePath path, boolean down) { TreeModel _model = model.treeModel; TreeNode node = (TreeNode)path.getLastPathComponent(); if (down && _model.getChildCount(node) > 0) return path.pathByAddingChild(_model.getChild(node, 0)); TreePath parentPath = path.getParentPath(); if (!down && parentPath == null) return path.pathByAddingChild(_model.getChild(node, 0)); TreeNode parent = (TreeNode)parentPath.getLastPathComponent(); int idx = _model.getIndexOfChild(parent, node) + 1; if (_model.getChildCount(parent) > idx) return parentPath.pathByAddingChild(_model.getChild(parent, idx)); if (!down && parentPath.getParentPath() == null) { return parentPath.pathByAddingChild(_model.getChild(parent, 0)); } else { return getNextPath(parentPath, false); } }
Example 3
Source File: TreeState.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static List<PathElement> createPath(@Nonnull TreeModel model, @Nonnull TreePath treePath) { Object prev = null; int count = treePath.getPathCount(); PathElement[] result = new PathElement[count]; for (int i = 0; i < count; i++) { Object cur = treePath.getPathComponent(i); Object userObject = TreeUtil.getUserObject(cur); int childIndex = prev == null ? 0 : model.getIndexOfChild(prev, cur); result[i] = new PathElement(calcId(userObject), calcType(userObject), childIndex, userObject); prev = cur; } return Arrays.asList(result); }
Example 4
Source File: SimpleTreeWalker.java From weblaf with GNU General Public License v3.0 | 4 votes |
@Override protected int getIndexOfChild ( @NotNull final TreeModel model, @NotNull final N parent, @NotNull final N child ) { return model.getIndexOfChild ( parent, child ); }
Example 5
Source File: Preferences.java From pdfxtk with Apache License 2.0 | 4 votes |
static void path2str(Object[] path, String[] strs, int idxs[], TreeModel model) { for(int i = 0; i < strs.length; i++) { strs[i] = path[i + 1].toString(); idxs[i] = model.getIndexOfChild(path[i], path[i + 1]); } }