Пример #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();
    }
  } // }}}
    private void myDoubleClick(int row, TreePath path) {
      if (path != null) {
        JFrame infoFrame = new JFrame("Object Info for: " + path);
        JLabel objectLabel;
        JLabel parentPathLabel;

        // Display Selected Object Name;
        objectLabel = new JLabel("Object: " + path.getLastPathComponent().toString());
        objectLabel.setHorizontalAlignment(SwingConstants.CENTER);

        // Display specific object information
        parentPathLabel = new JLabel("Parent Path: " + path.getParentPath());
        parentPathLabel.setHorizontalAlignment(SwingConstants.CENTER);

        // Construct infoFrame
        infoFrame.getContentPane().add(objectLabel, BorderLayout.CENTER);
        infoFrame.getContentPane().add(parentPathLabel, BorderLayout.SOUTH);
        infoFrame.pack();
        infoFrame.setVisible(true);
      }
    }