Exemplo n.º 1
0
  private static String getNodePathString(final MyNode node) {
    StringBuilder path = new StringBuilder();
    MyNode current = node;
    while (current != null) {
      final Object userObject = current.getUserObject();
      if (!(userObject instanceof NamedConfigurable)) break;
      final String displayName = current.getDisplayName();
      if (StringUtil.isEmptyOrSpaces(displayName)) break;
      if (path.length() > 0) {
        path.append('|');
      }
      path.append(displayName);

      final TreeNode parent = current.getParent();
      if (!(parent instanceof MyNode)) break;
      current = (MyNode) parent;
    }
    return path.toString();
  }
Exemplo n.º 2
0
  private void showDetails(TreePath p) {

    if (p == null) {
      return;
    }

    MyNode selectedNode = (MyNode) p.getLastPathComponent();
    String textPath = textGen(p);

    JOptionPane.showMessageDialog(
        this,
        selectedNode.getLevelName()
            + ": "
            + selectedNode.getUserObject()
            + "\n"
            + selectedNode.getText()
            + "\n"
            + textPath);
  }