Beispiel #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();
    }
  } // }}}
Beispiel #2
0
  private void goToSelectedNode(int mode) {
    TreePath path = resultTree.getSelectionPath();
    if (path == null) return;

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    Object value = node.getUserObject();

    // do nothing if clicked "foo (showing n occurrences in m files)"
    if (node.getParent() != resultTreeRoot && value instanceof HyperSearchNode) {
      HyperSearchNode n = (HyperSearchNode) value;
      Buffer buffer = n.getBuffer(view);
      if (buffer == null) return;

      EditPane pane;

      switch (mode) {
        case M_OPEN:
          pane = view.goToBuffer(buffer);
          break;
        case M_OPEN_NEW_VIEW:
          pane = jEdit.newView(view, buffer, false).getEditPane();
          break;
        case M_OPEN_NEW_PLAIN_VIEW:
          pane = jEdit.newView(view, buffer, true).getEditPane();
          break;
        case M_OPEN_NEW_SPLIT:
          pane = view.splitHorizontally();
          break;
        default:
          throw new IllegalArgumentException("Bad mode: " + mode);
      }

      n.goTo(pane);
    }
  } // }}}
Beispiel #3
0
 public void actionPerformed(ActionEvent event) {
   JTree tree = getTree();
   TreePath path = tree.getSelectionPath();
   if (path == null) {
     sheet.getLogger().warning("Warning: User must select a node to attach a new config to");
     // XXX add a message telling users to select a node
   } else {
     createAttrConfigForNode((Node) path.getLastPathComponent());
   }
 }
Beispiel #4
0
 public void editSelected() {
   TreePath selected = tree.getSelectionPath();
   if (selected != null) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) selected.getLastPathComponent();
     Object obj = node.getUserObject();
     if (obj instanceof CavityDBObject) {
       CavityDBObject dbObj = (CavityDBObject) obj;
       new ObjectEditingFrame(new ObjectEditingPanel(dbObj));
     }
   }
 }
Beispiel #5
0
 public void actionPerformed(ActionEvent event) {
   JTree tree = getTree();
   TreePath path = tree.getSelectionPath();
   if (path == null) {
     sheet.getLogger().warning("Warning: User must select a node to delete");
     // XXX add message telling users to select a node
   } else {
     Node selected = (Node) path.getLastPathComponent();
     try {
       Node parent = selected.getParent();
       if (parent != null) {
         parent.removeChild(selected);
         select(parent);
       }
     } catch (UnsupportedOperationException uox) {
       sheet.getLogger().warning("Cannot delete node: " + selected);
     }
   }
 }
Beispiel #6
0
  /**
   * Processes an idChanged event. Search is different from all other navigators in that you while
   * search tree is synchronized the highlighting doesn't occur unless selected from the search
   * navigator.
   */
  public void idChanged(HelpModelEvent e) {
    ID id = e.getID();
    URL url = e.getURL();
    HelpModel helpModel = searchnav.getModel();
    debug("idChanged(" + e + ")");

    if (e.getSource() != helpModel) {
      debug("Internal inconsistency!");
      debug("  " + e.getSource() + " != " + helpModel);
      throw new Error("Internal error");
    }

    TreePath s = tree.getSelectionPath();
    if (s != null) {
      Object o = s.getLastPathComponent();
      // should require only a TreeNode
      if (o instanceof DefaultMutableTreeNode) {
        DefaultMutableTreeNode tn = (DefaultMutableTreeNode) o;
        SearchTOCItem item = (SearchTOCItem) tn.getUserObject();
        if (item != null) {
          ID nId = item.getID();
          if (nId != null && nId.equals(id)) {
            return;
          }
        }
      }
    }

    DefaultMutableTreeNode node = findIDorURL(topNode, id, url);
    if (node == null) {
      // node doesn't exist. Need to clear the selection.
      debug("node didn't exist");
      tree.clearSelection();
      return;
    }
    TreePath path = new TreePath(node.getPath());
    tree.expandPath(path);
    tree.setSelectionPath(path);
    tree.scrollPathToVisible(path);
  }