예제 #1
0
  /** initialization. load all files. */
  private void init() {
    URL home = getClass().getResource("..");
    File local;
    if (home != null) {
      System.out.println("looks like you are not starting from a jar-package");
      local = new File(home.getPath() + "/" + helproot + "/" + language + "/");
      System.out.println("local: " + local.getAbsolutePath());
      initFile(local);
      try {
        local =
            new File(
                new File(home.getPath()).getParentFile().getParentFile(),
                helproot + "/" + language);
        System.out.println("local: " + local.getAbsolutePath());
        initFile(local);
      } catch (Exception e) {
        System.out.println("but not loading from the developer workbench?!");
      }

    } else {
      System.out.println("looks like you are starting from a jar-package");
      local = CommandLoader.getLocation();
      initJar(local);
    }
    List<String> l = getLanguages();
    for (String aL : l) {
      System.out.println("language found: " + aL);
    }
  }
예제 #2
0
  /**
   * scans for possible help directories (languages)
   *
   * @return a list of possible language directories
   */
  public List<String> getLanguages() {
    List<String> paths = new ArrayList<>();
    URL home = getClass().getResource("..");
    File local;
    if (home != null) {
      System.out.println("looks like you are not starting from a jar-package");
      try {
        local = new File(new File(home.getPath()).getParentFile().getParentFile(), helproot);
        System.out.println("local: " + local.getAbsolutePath());
        for (File s : local.listFiles()) {
          if (s.isDirectory() && (s.listFiles().length > 0)) {
            addToList(paths, s.getName());
          }
        }
      } catch (Exception e) {
        System.out.println("but not loading from the developer workbench?!");
      }

    } else {
      System.out.println("looks like you are starting from a jar-package");
      local = CommandLoader.getLocation();
      File helpDir = new File(local, helproot);
      if (helpDir.exists() && helpDir.isDirectory() && (helpDir.listFiles().length > 0)) {
        for (File s : helpDir.listFiles()) {
          if (s.isDirectory()) {
            addToList(paths, s.getName());
          }
        }
      }

      File jar = new File(CommandLoader.classPath());
      for (File file : local.listFiles()) {
        try {
          if (!jar.getCanonicalPath().equals(file.getCanonicalPath())) {
            searchJarPath(file, paths);
          }
        } catch (IOException ignored) {
        }
        searchJarPath(jar, paths);
      }
    }
    return paths;
  }