private TreePath find(DefaultMutableTreeNode root, String s) { @SuppressWarnings("unchecked") Enumeration<DefaultMutableTreeNode> e = root.depthFirstEnumeration(); while (e.hasMoreElements()) { DefaultMutableTreeNode node = e.nextElement(); if (node.toString().equalsIgnoreCase(s)) { return new TreePath(node.getPath()); } } return null; }
/** Returns the result of sending <code>toString()</code> to this node's * user object, or null if this node has no user object. * * @see #getUserObject * */ public String toString() { String retValue; retValue = (file == null) ? "File Systems" : super.toString(); return retValue; }
/** * Checks if the node is the root node. * * @param value the value to be checked. * @since 1.0 */ protected boolean isCloud(Object value) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; if (node.toString().equalsIgnoreCase("CloudReports")) return true; return false; }
/** * Checks if the node is the providers root node. * * @param value the value to be checked. * @since 1.0 */ protected boolean isProvider(Object value) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; if (node.toString().equalsIgnoreCase("Provider")) return true; return false; } }
private DefaultMutableTreeNode getNode(String nodeName, DefaultMutableTreeNode root) { if (root != null) { Enumeration children = root.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); if (nodeName.equals(child.toString())) { return child; } } } return null; }
private boolean isNodeContained(String nodeName, DefaultMutableTreeNode root) { Enumeration children = root.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); if (nodeName.equals(child.toString())) { return true; } } return false; }
private boolean isNodeContained(String nodeName, DefaultMutableTreeNode root) { Enumeration children = root.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); if (nodeName.equals(child.toString())) { return true; } } return false; }
private DefaultMutableTreeNode getNode(String nodeName, DefaultMutableTreeNode root) { if (root != null) { Enumeration children = root.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); if (nodeName.equals(child.toString())) { return child; } } } return null; }
public void printNode(DefaultMutableTreeNode node) { int childCount = node.getChildCount(); System.out.println("---" + node.toString() + "---"); for (int i = 0; i < childCount; i++) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) node.getChildAt(i); if (childNode.getChildCount() > 0) { printNode(childNode); } else { System.out.println(childNode.toString()); } } System.out.println("+++" + node.toString() + "+++"); }
public TreePath findTreePath(String s) { Enumeration<DefaultMutableTreeNode> e = ((DefaultMutableTreeNode) tree.getModel().getRoot()).depthFirstEnumeration(); while (e.hasMoreElements()) { DefaultMutableTreeNode node = e.nextElement(); if (node.toString().equalsIgnoreCase(s)) { return new TreePath(node.getPath()); } } return null; }
public java.util.List<TreePath> find(DefaultMutableTreeNode root, Set<String> s) { java.util.List<TreePath> paths = new ArrayList<>(); @SuppressWarnings("unchecked") Enumeration<DefaultMutableTreeNode> e = root.depthFirstEnumeration(); while (e.hasMoreElements()) { DefaultMutableTreeNode node = e.nextElement(); if (s.contains(node.toString())) { paths.add(new TreePath(node.getPath())); } } return paths; }
public static String printTree(DefaultMutableTreeNode node) { StringBuilder sb = new StringBuilder(); sb.append(indent(node.getLevel())); sb.append(node.toString()); sb.append(NEW_LINE); Enumeration<?> enumeration = node.children(); while (enumeration.hasMoreElements()) { sb.append(printTree((DefaultMutableTreeNode) enumeration.nextElement())); } return sb.toString(); }
@Override public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean phasFocus) { super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, phasFocus); DefaultMutableTreeNode valueTreeNode = (DefaultMutableTreeNode) value; setToolTipText(getHTML(valueTreeNode.toString(), "<br>", 100)); // $NON-NLS-1$ return this; }
/** Fires an ActionEvent upon double-click on the plugin item (leaf node) in the JTree */ void toAction() { DefaultMutableTreeNode nde=(DefaultMutableTreeNode)pTree.getLastSelectedPathComponent(); // if the node has children then do nothing (return) if (nde.getChildCount()>0) return; String aCmd=nde.toString(); String cmd= aCmd; if(pcp.treeCommands.containsKey(aCmd)) cmd = (String)pcp.treeCommands.get(aCmd); processEvent(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,cmd)); }
/** Fires an ActionEvent upon double-click on the plugin item (leaf node) in the JTree */ void toAction() { DefaultMutableTreeNode nde=(DefaultMutableTreeNode)pTree.getLastSelectedPathComponent(); // if the node has children then do nothing (return) if (nde.getChildCount()>0) return; String aCmd=nde.toString(); String cmd= aCmd; if(pcp.treeCommands.containsKey(aCmd)) cmd = (String)pcp.treeCommands.get(aCmd); processEvent(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,cmd)); }
private static DefaultMutableTreeNode findItem(DefaultMutableTreeNode parentItem, String filterName) { if (!parentItem.isLeaf()) { final Enumeration enumeration = parentItem.children(); while (enumeration.hasMoreElements()) { final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) enumeration.nextElement(); final DefaultMutableTreeNode found = findItem(treeNode, filterName); if (found != null) return found; } } if (parentItem.toString().equals(filterName)) return parentItem; return null; }
private static Element createTree(Document doc, TreeModel model, Object node) { Element el = doc.createElement(node.toString()); for(int i=0;i<model.getChildCount(node);i++){ DefaultMutableTreeNode child = (DefaultMutableTreeNode)model.getChild(node, i); if (child.isLeaf()) { el.setTextContent(child.toString()); } else { el.appendChild(createTree(doc,model,child)); } } return el; }
public void valueChanged(final TreeSelectionEvent e) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree .getLastSelectedPathComponent(); if (node == null) { return; } final String coderName = node.toString(); decode.setEnabled(EncoderHashCore.isDecoded(coderName)); commentPanel.setText(EncoderHashCore.getComment(coderName)); } });
/** * provides the right name of the node for display */ @Override public String toString() { // return movieSet name if (getUserObject() instanceof MovieSet) { MovieSet movieSet = (MovieSet) getUserObject(); return movieSet.getTitle(); } // fallback: call super return super.toString(); }
/** * provides the right name of the node for display. * * @return the string */ @Override public String toString() { // return movie name if (getUserObject() instanceof Movie) { Movie movie = (Movie) getUserObject(); return movie.getTitleSortable(); } // fallback: call super return super.toString(); }