Java Code Examples for javax.swing.tree.DefaultMutableTreeNode#preorderEnumeration()

The following examples show how to use javax.swing.tree.DefaultMutableTreeNode#preorderEnumeration() . 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: InspectionComboModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public InspectionComboModel(Collection<? extends HintMetadata> hints) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) constructTM(hints, false).getRoot();
    Enumeration enumeration = root.preorderEnumeration();
    
    hintsList = new ArrayList<Object>();
    while (enumeration.hasMoreElements()) {
        Object userObject = ((DefaultMutableTreeNode) enumeration.nextElement()).getUserObject();
        if (userObject!=null)
            hintsList.add(userObject);
    }
    if (getSize() > 0) {
        selected = getElementAt(Math.min(getSize(), 1));
    }
}
 
Example 2
Source File: CVariablesPanel.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Given a node in the {@link JTree tree} finds all instructions below the given node.
 *
 * @param node The {@link DefaultMutableTreeNode node} which is the root of the sub tree where
 *        to collect all {@link INaviInstruction instructions}.
 * @return The {@link INaviInstruction instructions} below the given
 *         {@link DefaultMutableTreeNode node}.
 */
private Set<INaviInstruction> findInstructions(final DefaultMutableTreeNode node) {
  final Set<INaviInstruction> instructions = Sets.newHashSet();
  Enumeration<?> enumeration = node.preorderEnumeration();
  while (enumeration.hasMoreElements()) {
    final DefaultMutableTreeNode currentNode =
        (DefaultMutableTreeNode) enumeration.nextElement();
    if (currentNode.isLeaf() && currentNode instanceof InstructionNode) {
      instructions.add(((InstructionNode) currentNode).getInstruction());
    }
  }
  return instructions;
}
 
Example 3
Source File: FuzzerPayloadGeneratorUIHandler.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public void reload() {
    rows.clear();

    DefaultMutableTreeNode rootNode =
            (DefaultMutableTreeNode) tree.getModel().getRoot();
    @SuppressWarnings("unchecked")
    Enumeration<TreeNode> nodes = rootNode.preorderEnumeration();
    for (int i = 0; nodes.hasMoreElements(); i++) {
        rows.put(
                i,
                new TreePath(((DefaultMutableTreeNode) nodes.nextElement()).getPath()));
    }
}
 
Example 4
Source File: PropertiesPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
private void expandAll() {
  DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel()
      .getRoot();

  for (Enumeration enumeration = root.preorderEnumeration(); enumeration
      .hasMoreElements();) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration
        .nextElement();
    if (node.getChildCount() != 0)
        tree.expandPath(new TreePath(node.getPath()));
  }
}
 
Example 5
Source File: TreeTestBase.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void preorderIterator() {
	final T tree = newTree(5, new Random(123));
	final DefaultMutableTreeNode stree = newSwingTree(5, new Random(123));

	final Iterator<T> treeIt = tree.preorderIterator();
	final Enumeration<?> streeIt = stree.preorderEnumeration();

	while (treeIt.hasNext()) {
		final T node = treeIt.next();
		final DefaultMutableTreeNode snode = (DefaultMutableTreeNode)streeIt.nextElement();

		Assert.assertEquals(node.value(), snode.getUserObject());
	}
}