Refine search
nodesCheckingState = new HashMap<TreePath, CheckedNode>(); checkedPaths = new HashSet<TreePath>(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)getModel().getRoot(); if (node == null) { return; nodesCheckingState.put(tp, cn); for (int i = 0 ; i < node.getChildCount() ; i++) { addSubtreeToCheckingStateTracking((DefaultMutableTreeNode) tp.pathByAddingChild(node.getChildAt(i)).getLastPathComponent()); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) parentPath.getLastPathComponent(); parentCheckedNode.allChildrenSelected = true; parentCheckedNode.isSelected = false; CheckedNode cn = nodesCheckingState.get(tp); cn.isSelected = check; DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent(); for (int i = 0 ; i < node.getChildCount() ; i++) { checkSubTree(tp.pathByAddingChild(node.getChildAt(i)), check);
(DefaultMutableTreeNode)tree.getModel().getRoot(); Enumeration e = root.breadthFirstEnumeration(); while(e.hasMoreElements()) { (DefaultMutableTreeNode)dest.getLastPathComponent(); TreePath path = tree.getPathForRow(selRows[0]); DefaultMutableTreeNode firstNode = (DefaultMutableTreeNode)path.getLastPathComponent(); if(firstNode.getChildCount() > 0 && target.getLevel() < firstNode.getLevel()) { TreePath path = tree.getPathForRow(selRows[0]); DefaultMutableTreeNode first = (DefaultMutableTreeNode)path.getLastPathComponent(); int childCount = first.getChildCount(); if((action & MOVE) == MOVE) { JTree tree = (JTree)source; DefaultTreeModel model = (DefaultTreeModel)tree.getModel(); (DefaultMutableTreeNode)dest.getLastPathComponent(); JTree tree = (JTree)support.getComponent(); DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
protected void arrowButtonDownAction(ActionEvent evt) { TreePath tpath = tree.getSelectionPath(); if (tpath != null) { Object current = tpath.getLastPathComponent(); Object child = tree.getModel().getChild(current, 0); if (child != null) { Object[] treeObjs = new Object[30]; int objCnt = 2; while (parentpath != null) { Object po = parentpath.getLastPathComponent(); treeObjs[objCnt] = po; objCnt += 1;
Object value = tpath.getLastPathComponent(); TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { Object parent = parentpath.getLastPathComponent(); if (parent instanceof MondrianGuiDef.Hierarchy) { ((MondrianGuiDef.Hierarchy) parent).relation = relationObj; } else if (parent instanceof MondrianGuiDef.Join) { int indexOfChild = tree.getModel().getIndexOfChild(parent, value); switch (indexOfChild) { case 0:
Object node = path.getLastPathComponent(); Object parentNode = parent.getLastPathComponent(); Object node = temp.getLastPathComponent(); Object peekNode = peekPath.getLastPathComponent(); int childCount = model.getChildCount(node); selectionModel = new CheckTreeSelectionModel(tree.getModel());
.getLastPathComponent())) lastSelected = e.getPath().getLastPathComponent(); Object o = tpath.getLastPathComponent(); Object po = null; if (parentName.equalsIgnoreCase("Join")) { Object parentJoin = parentTpath.getLastPathComponent(); int indexOfChild = tree.getModel().getIndexOfChild( parentJoin, o); switch (indexOfChild) {
TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { Object parent = parentpath.getLastPathComponent(); if (parent instanceof MondrianGuiDef.Join) { int indexOfChild = tree.getModel().getIndexOfChild( parent, value); switch (indexOfChild) {
public boolean test() { // It is possible that the path has been updated, in the test // case where we saw this change the lazily loaded nodes // are replaced with the new correct nodes on expand // so we need to get hold of the new version // final TreePath updatedPath = getRealPath(path, timeout, tree); final Object o = updatedPath.getLastPathComponent(); return tree.getModel().getChildCount(o) != 0; } public String toString() {
public static CategoryTreeNode getSelectedCategoryTreeNode(JTree tree) { TreePath treePath = tree.getSelectionPath(); // if there is no selected root take the local root Object value = treePath != null ? treePath.getLastPathComponent() : tree.getModel().getChild(tree.getModel().getRoot(), 0); if (!(value instanceof CategoryTreeNode)) return null; return (CategoryTreeNode) value; }
private boolean isLeaf(TreePath path) { return jTree.getModel().isLeaf(path.getLastPathComponent()); }
public void mouseClicked (MouseEvent ev) { if (ev.getClickCount () != 2) return; TreePath path = tree.getPathForLocation (ev.getX (), ev.getY ()); if (path == null) return; Object node = path.getLastPathComponent (); LanguagesNavigatorModel model = (LanguagesNavigatorModel) tree.getModel (); model.show (node); }
public String getToolTipText (MouseEvent ev) { TreePath path = tree.getPathForLocation (ev.getX (), ev.getY ()); if (path == null) return null; Object node = path.getLastPathComponent (); LanguagesNavigatorModel model = (LanguagesNavigatorModel) tree.getModel (); return model.getTooltip (node); } };
@Override public void mouseClicked(final MouseEvent e) { if (!e.isPopupTrigger() && e.getClickCount() == 2) { if (tree.getModel().isLeaf(tree.getSelectionPath().getLastPathComponent())) { runScripts(); } } }
@Override public void actionPerformed(ActionEvent e) { Object node = path.getLastPathComponent(); if (node instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode leaf = (DefaultMutableTreeNode) node; textField.setText(leaf.getUserObject().toString()); JTree tree = (JTree) getInvoker(); int ret = JOptionPane.showConfirmDialog(tree, textField, "edit", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (ret == JOptionPane.OK_OPTION) { Optional.ofNullable(textField.getText()) .filter(str -> !str.trim().isEmpty()) .ifPresent(str -> ((DefaultTreeModel) tree.getModel()).valueForPathChanged(path, str)); } } } };
private static void dumpTree(StringBuilder sb, JTree tree, TreePath path, String prefix) { String currentName = JTreeTester.valueToString(tree, path); sb.append(prefix).append(currentName).append('\n'); Object parent = path.getLastPathComponent(); int count = tree.getModel().getChildCount(parent); for (int i = 0; i < count; i++) { dumpTree(sb, tree, new TreePath(path, tree.getModel().getChild(parent, i)) {}, prefix + "-"); } }
public void keyPressed(KeyEvent e) { if (e.getKeyCode() != 10) return; // ENTER pressed? TreePath path = tree.getSelectionPath(); if (path == null) return; Object node = path.getLastPathComponent (); LanguagesNavigatorModel model = (LanguagesNavigatorModel) tree.getModel (); model.show (node); }
@Override public void actionPerformed(ActionEvent e) { ((FilterTreeModel) filterTree.getModel()).removeFilter((Filter) filterTree.getSelectionPath().getLastPathComponent()); } });
/** * Returns the number of children of a given node. */ public int getChildCount(String path) { TreePath jTreePath = getTreePath(path); return jTree.getModel().getChildCount(jTreePath.getLastPathComponent()); }
@Override public void actionPerformed(ActionEvent e) { ((FilterTreeModel) filterTree.getModel()).removeFilter((Filter) filterTree.getSelectionPath().getLastPathComponent()); } });
@Override public void actionPerformed(ActionEvent e) { JTree tree = (JTree) getInvoker(); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getLastPathComponent(); DefaultMutableTreeNode child = new DefaultMutableTreeNode("New node"); parent.add(child); model.reload(parent); // = model.nodeStructureChanged(parent); tree.scrollPathToVisible(new TreePath(child.getPath())); } };