예제 #1
1
    public void run() {
      SearchTOCItem tocitem;
      Vector nodes = new Vector();

      // Add all the children of the topnode to the Vector of nodes.
      Enumeration children = topNode.children();
      while (children.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();
        nodes.addElement(node);
      }

      debug("items found");
      HelpModel helpmodel = searchnav.getModel();
      HelpSet hs = helpmodel.getHelpSet();
      debug("hs:" + hs.toString());
      Map map = hs.getCombinedMap();
      Enumeration itemEnum = e.getSearchItems();
      while (itemEnum.hasMoreElements()) {
        SearchItem item = (SearchItem) itemEnum.nextElement();
        debug("  item: " + item);
        URL url;
        try {
          url = new URL(item.getBase(), item.getFilename());
        } catch (MalformedURLException me) {
          System.err.println(
              "Failed to create URL from " + item.getBase() + "|" + item.getFilename());
          continue;
        }
        boolean foundNode = false;
        DefaultMutableTreeNode node = null;
        Enumeration nodesEnum = nodes.elements();
        while (nodesEnum.hasMoreElements()) {
          node = (DefaultMutableTreeNode) nodesEnum.nextElement();
          tocitem = (SearchTOCItem) node.getUserObject();
          URL testURL = tocitem.getURL();
          if (testURL != null && url != null && url.sameFile(testURL)) {
            tocitem = (SearchTOCItem) node.getUserObject();
            tocitem.addSearchHit(
                new SearchHit(item.getConfidence(), item.getBegin(), item.getEnd()));
            foundNode = true;
            break;
          }
        }
        if (!foundNode) {
          tocitem = new SearchTOCItem(item);
          node = new DefaultMutableTreeNode(tocitem);
          nodes.addElement(node);
        }
      }
      reorder(nodes);
      ((DefaultTreeModel) tree.getModel()).reload();
    }
예제 #2
0
 /**
  * Adds subhelpsets
  *
  * @param hs The HelpSet which subhelpsets will be added
  */
 protected void addSubHelpSets(HelpSet hs) {
   for (Enumeration e = hs.getHelpSets(); e.hasMoreElements(); ) {
     HelpSet ehs = (HelpSet) e.nextElement();
     // merge views
     NavigatorView[] views = ehs.getNavigatorViews();
     for (int i = 0; i < views.length; i++) {
       if (searchnav.canMerge(views[i])) searchnav.merge(views[i]);
     }
     addSubHelpSets(ehs);
   }
 }
예제 #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);
  }