Beispiel #1
0
  // reorder the nodes
  private void reorder(Vector nodes) {

    debug("reorder nodes");

    // remove all the children of topNode (they'll be added back later)
    topNode.removeAllChildren();

    // Create an array of the elements for sorting & copy the elements
    // into the array.
    DefaultMutableTreeNode[] array = new DefaultMutableTreeNode[nodes.size()];
    nodes.copyInto(array);

    // Sort the array (Quick Sort)
    quickSort(array, 0, array.length - 1);

    // Reload the topNode. Everthing is in order now.
    for (int i = 0; i < array.length; i++) {
      topNode.add((DefaultMutableTreeNode) array[i]);
    }

    // Tell the tree to repaint itself
    ((DefaultTreeModel) tree.getModel()).reload();
    tree.invalidate();
    tree.repaint();
  }
 private static void replaceChildren(
     final DefaultMutableTreeNode node, final Collection<? extends ElementNode> arrayList) {
   node.removeAllChildren();
   for (ElementNode child : arrayList) {
     node.add(child);
   }
 }
Beispiel #3
0
  /**
   * Reloads data from new model, creates new search engine to search in new model if model contains
   * view with the same name
   */
  private void reloadData(HelpModel model) {
    debug("reloadData using new model");
    helpsearch = null;
    SearchView view = null;

    newHelpSet = model.getHelpSet();
    SearchView oldView = (SearchView) searchnav.getNavigatorView();
    String oldName = oldView.getName();
    NavigatorView[] navViews = newHelpSet.getNavigatorViews();
    for (int i = 0; i < navViews.length; i++) {
      if ((navViews[i].getName()).equals(oldName)) {
        NavigatorView tempView = navViews[i];
        if (tempView instanceof SearchView) {
          view = (SearchView) tempView;
          break;
        }
      }
    }

    if (view == null) return;

    topNode.removeAllChildren();
    searchnav.setSearchEngine(new MergingSearchEngine(view));

    setCellRenderer(view, tree);
    // add all subhelpsets
    addSubHelpSets(newHelpSet);
  }
Beispiel #4
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) evt.getSource();
      boolean curState = menuItem.isSelected();

      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();

      HyperSearchOperationNode operNodeObj = (HyperSearchOperationNode) operNode.getUserObject();
      if (curState) operNodeObj.cacheResultNodes(operNode);
      operNode.removeAllChildren();
      if (curState) {
        Exception excp = null;
        try {
          operNodeObj.insertTreeNodes(resultTree, operNode);
        } catch (Exception ex) {
          operNodeObj.restoreFlatNodes(resultTree, operNode);
          menuItem.setSelected(false);
          excp = ex;
        } finally {
          ((DefaultTreeModel) resultTree.getModel()).nodeStructureChanged(operNode);
          expandAllNodes(operNode);
          resultTree.scrollPathToVisible(new TreePath(operNode.getPath()));
        }
        if (excp != null) throw new RuntimeException(excp);
      } else operNodeObj.restoreFlatNodes(resultTree, operNode);

      operNodeObj.setTreeViewDisplayed(menuItem.isSelected());
    }
Beispiel #5
0
 public static void sort(final DefaultMutableTreeNode node, final Comparator comparator) {
   final List<TreeNode> children = childrenToArray(node);
   Collections.sort(children, comparator);
   node.removeAllChildren();
   addChildrenTo(node, children);
   for (int i = 0; i < node.getChildCount(); i++) {
     sort((DefaultMutableTreeNode) node.getChildAt(i), comparator);
   }
 }
 private void patchActionsTreeCorrespondingToSchema(DefaultMutableTreeNode root) {
   root.removeAllChildren();
   if (mySelectedSchema != null) {
     mySelectedSchema.fillActionGroups(root);
     for (final ActionUrl actionUrl : mySelectedSchema.getActions()) {
       ActionUrl.changePathInActionsTree(myActionsTree, actionUrl);
     }
   }
   ((DefaultTreeModel) myActionsTree.getModel()).reload();
 }
  private void reset(
      final Keymap keymap,
      final QuickList[] allQuickLists,
      String filter,
      @Nullable KeyboardShortcut shortcut) {
    myKeymap = keymap;

    final PathsKeeper pathsKeeper = new PathsKeeper();
    pathsKeeper.storePaths();

    myRoot.removeAllChildren();

    ActionManager actionManager = ActionManager.getInstance();
    Project project =
        CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myComponent));
    Group mainGroup =
        ActionsTreeUtil.createMainGroup(
            project,
            myKeymap,
            allQuickLists,
            filter,
            true,
            ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut, filter, true));
    if ((filter != null && filter.length() > 0 || shortcut != null)
        && mainGroup.initIds().isEmpty()) {
      mainGroup =
          ActionsTreeUtil.createMainGroup(
              project,
              myKeymap,
              allQuickLists,
              filter,
              false,
              ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut, filter, false));
    }
    myRoot = ActionsTreeUtil.createNode(mainGroup);
    myMainGroup = mainGroup;
    MyModel model = (MyModel) myTree.getModel();
    model.setRoot(myRoot);
    model.nodeStructureChanged(myRoot);

    pathsKeeper.restorePaths();
  }
Beispiel #8
0
 // {{{ removeAllNodes() method
 private void removeAllNodes() {
   resultTreeRoot.removeAllChildren();
   resultTreeModel.reload(resultTreeRoot);
   setSearchStatus(null);
   hideDockable();
 } // }}}
  /* Clear all existing nodes from the tree model and rebuild from scratch.
   */
  protected void refreshTree() {

    DefaultMutableTreeNode propertiesNode;
    DefaultMutableTreeNode leaf;

    // First clear the existing tree by simply enumerating
    // over the root node's children and removing them one by one.
    while (treeModel.getChildCount(rootNode) > 0) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode) treeModel.getChild(rootNode, 0);

      treeModel.removeNodeFromParent(child);
      child.removeAllChildren();
      child.removeFromParent();
    }

    treeModel.nodeStructureChanged(rootNode);
    treeModel.reload();
    tScrollPane.repaint();

    // Now rebuild the tree below its root
    try {

      // Start by naming the root node from its URL:
      rootNode.setUserObject(dMeta.getURL());

      // get metadata about user tables by building a vector of table names
      String usertables[] = {"TABLE", "GLOBAL TEMPORARY", "VIEW"};
      ResultSet result = dMeta.getTables(null, null, null, usertables);
      Vector tables = new Vector();

      // sqlbob@users Added remarks.
      Vector remarks = new Vector();

      while (result.next()) {
        tables.addElement(result.getString(3));
        remarks.addElement(result.getString(5));
      }

      result.close();

      // For each table, build a tree node with interesting info
      for (int i = 0; i < tables.size(); i++) {
        String name = (String) tables.elementAt(i);
        DefaultMutableTreeNode tableNode = makeNode(name, rootNode);
        ResultSet col = dMeta.getColumns(null, null, name, null);

        // sqlbob@users Added remarks.
        String remark = (String) remarks.elementAt(i);

        if ((remark != null) && !remark.trim().equals("")) {
          makeNode(remark, tableNode);
        }

        // With a child for each column containing pertinent attributes
        while (col.next()) {
          String c = col.getString(4);
          DefaultMutableTreeNode columnNode = makeNode(c, tableNode);
          String type = col.getString(6);

          makeNode("Type: " + type, columnNode);

          boolean nullable = col.getInt(11) != DatabaseMetaData.columnNoNulls;

          makeNode("Nullable: " + nullable, columnNode);
        }

        col.close();

        DefaultMutableTreeNode indexesNode = makeNode("Indices", tableNode);
        ResultSet ind = dMeta.getIndexInfo(null, null, name, false, false);
        String oldiname = null;

        // A child node to contain each index - and its attributes
        while (ind.next()) {
          DefaultMutableTreeNode indexNode = null;
          boolean nonunique = ind.getBoolean(4);
          String iname = ind.getString(6);

          if ((oldiname == null || !oldiname.equals(iname))) {
            indexNode = makeNode(iname, indexesNode);

            makeNode("Unique: " + !nonunique, indexNode);

            oldiname = iname;
          }

          // And the ordered column list for index components
          makeNode(ind.getString(9), indexNode);
        }

        ind.close();
      }

      // Finally - a little additional metadata on this connection
      propertiesNode = makeNode("Properties", rootNode);

      makeNode("User: "******"ReadOnly: " + cConn.isReadOnly(), propertiesNode);
      makeNode("AutoCommit: " + cConn.getAutoCommit(), propertiesNode);
      makeNode("Driver: " + dMeta.getDriverName(), propertiesNode);
      makeNode("Product: " + dMeta.getDatabaseProductName(), propertiesNode);
      makeNode("Version: " + dMeta.getDatabaseProductVersion(), propertiesNode);
    } catch (SQLException se) {
      propertiesNode = makeNode("Error getting metadata:", rootNode);

      makeNode(se.getMessage(), propertiesNode);
      makeNode(se.getSQLState(), propertiesNode);
    }

    treeModel.nodeStructureChanged(rootNode);
    treeModel.reload();
    tScrollPane.repaint();
  }