static {
   FILE_UTILS = FileUtils.getFileUtils();
   AntClassLoader.pathMap = Collections.synchronizedMap(new HashMap<String, String>());
   AntClassLoader.subClassToLoad = null;
   CONSTRUCTOR_ARGS = new Class[] {ClassLoader.class, Project.class, Path.class, Boolean.TYPE};
   if (JavaEnvUtils.isAtLeastJavaVersion("1.5")) {
     try {
       AntClassLoader.subClassToLoad =
           Class.forName("org.apache.tools.ant.loader.AntClassLoader5");
     } catch (ClassNotFoundException ex) {
     }
   }
 }
Пример #2
0
  private void mapAndTocForFile(File f, File path, String underscore) {
    // we get the single name of the file and the urlname
    int under_index2 = f.getName().indexOf("_");
    int point_index2 = f.getName().indexOf(".");
    String named = f.getName().substring(under_index2 + 1, point_index2);
    String tmp = path.getAbsolutePath() + "Main_pages/fr/";
    String url_name = f.getPath().replace("\\", "/").substring(tmp.length());
    String targetName = url_name.substring(0, url_name.lastIndexOf(".html"));

    // now we will add into the map and the toc
    print.println("<mapID target=\"" + targetName + "\" url=\"pages/" + url_name + "\"/>");
    File dir_associated = new File(f.getParent(), named);

    if ((dir_associated.exists() && dir_associated.isDirectory()) || named.equals("objects")) {
      print2.println(
          "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"tamicon\">");
      if (dir_associated.exists()) {
        // Apres on fait pareil pour tous les sous fichiers
        File[] sub_files = dir_associated.listFiles();
        for (int i = 0; i < sub_files.length; i++) {
          if (!sub_files[i].getName().equals("CVS") && sub_files[i].isFile()) {
            if (sub_files[i].getName().endsWith(".html"))
              mapAndTocForFile(sub_files[i], path, underscore);
            else {
              try {
                copyFile(
                    sub_files[i], new File(path, "pages/" + named + "/" + sub_files[i].getName()));
              } catch (IOException e) {
                LOG.error("Error while copying normal files in help " + e);
              }
            }
          }
        }
      }
      if (named.equals("objects")) {
        // Specialement pour les objets on les rajoute tous
        File objects_dir =
            new File(
                Configuration.instance()
                        .getTangaraPath()
                        .getParentFile()
                        .getAbsolutePath()
                        .replace("\\", "/")
                    + "/objects/");
        File[] listfiles = objects_dir.listFiles();
        Vector<String> list_names = new Vector<String>();
        HashMap<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < listfiles.length; i++) {
          try {
            if (listfiles[i].getName().endsWith(".jar")) {
              int point_index = listfiles[i].getName().lastIndexOf(".");
              String name = listfiles[i].getName().substring(0, point_index);

              // Copy the pages in the right directory
              File object_dir = new File(path, "pages/" + name);
              object_dir.mkdir();
              File object_ressource =
                  new File(
                      Configuration.instance()
                              .getTangaraPath()
                              .getParentFile()
                              .getAbsolutePath()
                              .replace("\\", "/")
                          + "/objects/resources/"
                          + name
                          + "/Help");
              if (object_ressource.exists()) {
                File[] list_html_object = object_ressource.listFiles();
                for (int e = 0; e < list_html_object.length; e++) {
                  if (list_html_object[e].getName().endsWith(".html")) {
                    int under_index = list_html_object[e].getName().lastIndexOf("_");
                    if (underscore.equals("") && under_index == -1)
                      copyFile(
                          list_html_object[e],
                          new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                    else if (!underscore.equals("")) {
                      if (list_html_object[e].getName().contains(underscore))
                        copyFile(
                            list_html_object[e],
                            new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                    }
                  } else
                    copyFile(
                        list_html_object[e],
                        new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                }
                // Gets the name of the object in the selected language
                String name_lang = null;
                if (underscore.equals("")) name_lang = name;
                else {
                  name_lang = getLangName(listfiles[i]);
                }
                if (name_lang != null) {
                  list_names.add(name_lang);
                  map.put(name_lang, name);
                  // Add to the map file
                  print.println(
                      "<mapID target=\""
                          + name
                          + "\" url=\"pages/"
                          + name
                          + "/index"
                          + underscore
                          + ".html\" />");
                }
              }
            }
          } catch (Exception e2) {
            LOG.error("Error2 getHelp " + e2);
          }
        }
        // Add to the tam file
        Collections.sort(list_names);
        for (String s : list_names) {
          print2.println(
              "<tocitem text=\"" + s + "\" target=\"" + map.get(s) + "\" image=\"fileicon\" />");
        }
      }
      print2.println("</tocitem>");
    } else {
      // pas de sous fichiers
      print2.println(
          "<tocitem text=\""
              + getTitle(f)
              + "\" target=\""
              + targetName
              + "\" image=\"fileicon\"/>");
    }

    File parent = new File(path, "pages/" + url_name.substring(0, url_name.lastIndexOf(named) - 3));
    if (!parent.exists()) parent.mkdirs();
    File in_pages = new File(path, "pages/" + url_name);
    try {
      in_pages.createNewFile();
      copyFile(f, in_pages);
    } catch (IOException e3) {
      LOG.error("Error 3 getHelp " + e3 + " " + f.getName());
    }
  }