コード例 #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
 private void checkHelpSetURL(
     URL hsURL,
     ClassLoader globalClassLoader,
     ClassLoader moduleClassLoader,
     Map<String, URLClassLoader> classLoaderMap,
     String cnb) {
   HelpSet hs = null;
   try {
     hs = new HelpSet(moduleClassLoader, hsURL);
   } catch (HelpSetException ex) {
     throw new BuildException("Failed to parse " + hsURL + ": " + ex, ex, getLocation());
   }
   javax.help.Map map = hs.getCombinedMap();
   Enumeration<?> e = map.getAllIDs();
   Set<URI> okurls = new HashSet<URI>(1000);
   Set<URI> badurls = new HashSet<URI>(1000);
   Set<URI> cleanurls = new HashSet<URI>(1000);
   while (e.hasMoreElements()) {
     javax.help.Map.ID id = (javax.help.Map.ID) e.nextElement();
     URL u = null;
     try {
       u = id.getURL();
     } catch (MalformedURLException ex) {
       log("id:" + id, Project.MSG_WARN);
       ex.printStackTrace();
     }
     if (u == null) {
       throw new BuildException("Bogus map ID: " + id.id + " in: " + cnb);
     }
     log("Checking ID " + id.id, Project.MSG_VERBOSE);
     try {
       // System.out.println("CALL OF CheckLinks.scan");
       List<String> errors = new ArrayList<String>();
       CheckLinks.scan(
           this,
           globalClassLoader,
           classLoaderMap,
           id.id,
           "",
           new URI(u.toExternalForm()),
           okurls,
           badurls,
           cleanurls,
           false,
           false,
           false,
           2,
           Collections.<Mapper>emptyList(),
           errors);
       for (String error : errors) {
         log(error, Project.MSG_WARN);
       }
       // System.out.println("RETURN OF CheckLinks.scan");
     } catch (URISyntaxException ex) {
       ex.printStackTrace();
     } catch (IOException ex) {
       ex.printStackTrace();
     }
   }
 }