Esempio n. 1
0
  // {{{ removeSelectedNode() method
  private void removeSelectedNode() {
    TreePath path = resultTree.getSelectionPath();
    if (path == null) return;

    MutableTreeNode value = (MutableTreeNode) path.getLastPathComponent();

    if (path.getPathCount() > 1) {
      // Adjust selection so that repeating some removals
      // behave naturally.
      TreePath parentPath = path.getParentPath();
      MutableTreeNode parent = (MutableTreeNode) parentPath.getLastPathComponent();
      int removingIndex = parent.getIndex(value);
      int nextIndex = removingIndex + 1;
      if (nextIndex < parent.getChildCount()) {
        TreeNode next = parent.getChildAt(nextIndex);
        resultTree.setSelectionPath(parentPath.pathByAddingChild(next));
      } else {
        resultTree.setSelectionPath(parentPath);
      }

      resultTreeModel.removeNodeFromParent(value);
    }

    HyperSearchOperationNode.removeNodeFromCache(value);
    if (resultTreeRoot.getChildCount() == 0) {
      hideDockable();
    }
  } // }}}
Esempio n. 2
0
    public void valueChanged(TreeSelectionEvent evt) {
      TreePath path = evt.getPath();
      String fqn = SEP;
      String component_name;
      HashMap data = null;

      for (int i = 0; i < path.getPathCount(); i++) {
        component_name = ((MyNode) path.getPathComponent(i)).name;
        if (component_name.equals(SEP)) continue;
        if (fqn.equals(SEP)) fqn += component_name;
        else fqn = fqn + SEP + component_name;
      }
      data = getData(tree, fqn);
      if (data != null) {
        getContentPane().add(tablePanel, BorderLayout.SOUTH);
        populateTable(data);
        validate();
      } else {
        clearTable();
        getContentPane().remove(tablePanel);
        validate();
      }
    }