List of usage examples for javax.swing.tree TreeNode getChildCount
int getChildCount();
TreeNode
s the receiver contains. From source file:org.olivier.ihm.FramePUMLCleanerControler.java
/** * Slectionne les noeuds dans l'arbre de filtrage corespondant au motif * @param motif Le motif pour slectionner les noeuds * @param jTreeFiltre L'arbre de filtrage *///from www . j a v a 2 s . c om public void selectionnerNoeud(String motif, JTree jTreeFiltre) { // TODO : finir TreePath[] allPath = Util.getPaths(jTreeFiltre, true); // parcours des categories for (TreePath path : allPath) { // recup de la racine final DefaultMutableTreeNode root = (DefaultMutableTreeNode) path.getLastPathComponent(); // parcours des catgories for (int j = 0; j < root.getChildCount(); j++) { final TreeNode categ = root.getChildAt(j); // parcours des noeuds for (j = 0; j < categ.getChildCount(); j++) { final TreeNode unNoeudSelectionner = categ.getChildAt(j); if (!unNoeudSelectionner.toString().contains(motif)) { } } } } checkTreeManager.getSelectionModel().setSelectionPaths(allPath); }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorUtilities.java
/** * Searches all children of the currentNode and adds the node to it. * /*from w ww . ja v a 2 s. c o m*/ * @param addNode * @param currentNode * @return */ public int addNodeToModel(TreeNode addNode, TreeNode currentNode) { int chInt = currentNode.getChildCount(); int i = 0; for (; i < chInt; i++) { String currentNodeIdentifier = ((OIDObject) ((DefaultMutableTreeNode) currentNode.getChildAt(i)) .getUserObject()).getIdentifier(); String pathNodeIdentifer = ((OIDObject) ((DefaultMutableTreeNode) addNode).getUserObject()) .getIdentifier(); if (currentNodeIdentifier.equals(pathNodeIdentifer)) { return -1; //Already added, scenario never occurs. } else if (containsOID(currentNodeIdentifier, pathNodeIdentifer)) { i = addNodeToModel(addNode, currentNode.getChildAt(i)); //currentNode and pathNode share OID, continue search one level below } } //None of the children of the current node have a child sharing the OID, add node to the current Node if (i <= chInt) { ((DefaultMutableTreeNode) currentNode).add((DefaultMutableTreeNode) addNode); return chInt + 2; } return i + chInt; }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorUtilities.java
/** * Searches all children of the currentNode and adds the path to it. * // www. j av a 2s .com * @param path * @param currentNode * @param depth * @return */ public int addNodeToModel(TreeNode[] path, TreeNode currentNode, int depth) { int chInt = currentNode.getChildCount(); int i = 0; for (; i < chInt; i++) { String currentNodeIdentifier = ((OIDObject) ((DefaultMutableTreeNode) currentNode.getChildAt(i)) .getUserObject()).getIdentifier(); String pathNodeIdentifer = ((OIDObject) ((DefaultMutableTreeNode) path[depth]).getUserObject()) .getIdentifier(); if (currentNodeIdentifier.equals(pathNodeIdentifer)) { if (depth == path.length) { return -1; //Already added, scenario never occurs. } else { addNodeToModel(path, currentNode.getChildAt(i), depth + 1); return -1; } } else if (containsOID(currentNodeIdentifier, pathNodeIdentifer)) { i = addNodeToModel(path, currentNode.getChildAt(i), depth + 1); //currentNode and pathNode share OID, continue search one level below } } //None of the children of the current node have a child sharing the OID, add the remaining path to the current Node if (i <= chInt) { int k = depth; DefaultMutableTreeNode nodeToAddTo = (DefaultMutableTreeNode) currentNode; for (; k < path.length; k++) { DefaultMutableTreeNode newNode = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) path[k]) .clone(); nodeToAddTo.add(newNode); nodeToAddTo = newNode; } return chInt + 2; } return i + chInt; }
From source file:phex.gui.tabs.library.LibraryTab.java
private JPanel createTreePanel(MouseHandler mouseHandler) { JPanel panel = new JPanel(); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("fill:d:grow", // columns "fill:d:grow, 1dlu, p"); //rows PanelBuilder tabBuilder = new PanelBuilder(layout, panel); sharingTreeModel = new SharingTreeModel(); mainTree = new JTree(sharingTreeModel); mainTree.setMinimumSize(new Dimension(0, 0)); mainTree.setRowHeight(0);/* ww w.ja v a2s .c om*/ mainTree.setCellRenderer(new SharingTreeRenderer()); mainTree.addMouseListener(mouseHandler); mainTree.getSelectionModel().addTreeSelectionListener(new SelectionHandler()); ToolTipManager.sharedInstance().registerComponent(mainTree); // open up first level of nodes TreeNode root = (TreeNode) sharingTreeModel.getRoot(); int count = root.getChildCount(); for (int i = 0; i < count; i++) { mainTree.expandPath(new TreePath(new Object[] { root, root.getChildAt(i) })); } JScrollPane treeScrollPane = new JScrollPane(mainTree); tabBuilder.add(treeScrollPane, cc.xywh(1, 1, 1, 1)); FWToolBar shareToolbar = new FWToolBar(FWToolBar.HORIZONTAL); shareToolbar.setBorderPainted(false); shareToolbar.setFloatable(false); tabBuilder.add(shareToolbar, cc.xy(1, 3)); FWAction action = new AddShareFolderAction(); addTabAction(ADD_SHARE_FOLDER_ACTION_KEY, action); shareToolbar.addAction(action); action = new RemoveShareFolderAction(); addTabAction(REMOVE_SHARE_FOLDER_ACTION_KEY, action); shareToolbar.addAction(action); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { action = new ExploreFolderAction(); addTabAction(EXPLORE_FOLDER_ACTION_KEY, action); } return panel; }
From source file:phex.gui.tabs.library.LibraryTreePane.java
private void prepareComponent() { CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("fill:d:grow", // columns "fill:d:grow, 1dlu, p"); //rows PanelBuilder tabBuilder = new PanelBuilder(layout, this); sharingTreeModel = new SharingTreeModel(); mainTree = new JTree(sharingTreeModel); mainTree.setMinimumSize(new Dimension(0, 0)); mainTree.setRowHeight(0);// w w w . ja va 2 s . co m mainTree.setCellRenderer(new SharingTreeRenderer()); mainTree.addMouseListener(new MouseHandler()); mainTree.getSelectionModel().addTreeSelectionListener(new SelectionHandler()); ToolTipManager.sharedInstance().registerComponent(mainTree); // open up first level of nodes TreeNode root = (TreeNode) sharingTreeModel.getRoot(); int count = root.getChildCount(); for (int i = 0; i < count; i++) { mainTree.expandPath(new TreePath(new Object[] { root, root.getChildAt(i) })); } JScrollPane treeScrollPane = new JScrollPane(mainTree); tabBuilder.add(treeScrollPane, cc.xywh(1, 1, 1, 1)); FWToolBar shareToolbar = new FWToolBar(FWToolBar.HORIZONTAL); shareToolbar.setBorderPainted(false); shareToolbar.setFloatable(false); tabBuilder.add(shareToolbar, cc.xy(1, 3)); addShareFolderAction = new AddShareFolderAction(); shareToolbar.addAction(addShareFolderAction); removeShareFolderAction = new RemoveShareFolderAction(); shareToolbar.addAction(removeShareFolderAction); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { exploreFolderAction = new ExploreFolderAction(); } fileTreePopup = new FWPopupMenu(); fileTreePopup.addAction(addShareFolderAction); fileTreePopup.addAction(removeShareFolderAction); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { fileTreePopup.addAction(exploreFolderAction); } }
From source file:view.CertificatePropertiesDialog.java
private void expandAll(JTree tree, TreePath path) { TreeNode node = (TreeNode) path.getLastPathComponent(); if (node.getChildCount() >= 0) { Enumeration enumeration = node.children(); while (enumeration.hasMoreElements()) { TreeNode n = (TreeNode) enumeration.nextElement(); TreePath p = path.pathByAddingChild(n); expandAll(tree, p);//from ww w. j a v a 2 s. c o m } } tree.expandPath(path); }