コード例 #1
0
 public IRuntimeDetector findRuntimeDetector(String id) {
   for (IRuntimeDetector detector : getRuntimeDetectors()) {
     if (id.equals(detector.getId())) {
       return detector;
     }
   }
   return null;
 }
コード例 #2
0
  /**
   * Allows a given set or subset of runtime detectors the ability to search through a folder
   *
   * @param directory
   * @param runtimeCollector
   * @param depth
   * @param runtimeDetectors
   * @param monitor
   */
  public void searchDirectory(
      File directory,
      List<RuntimeDefinition> runtimeCollector,
      int depth,
      Set<IRuntimeDetector> runtimeDetectors,
      IProgressMonitor monitor) {

    if (depth == 0 || monitor.isCanceled() || directory == null || !directory.isDirectory()) {
      return;
    }

    int workSize = (1000 + (10 * runtimeDetectors.size()));
    monitor.beginTask(
        Messages.JBossRuntimeLocator_Searching + directory.getAbsolutePath(), workSize);
    monitor.setTaskName(Messages.JBossRuntimeLocator_Searching + directory.getAbsolutePath());

    for (IRuntimeDetector detector : runtimeDetectors) {
      if (monitor.isCanceled()) {
        return;
      }
      if (!detector.isEnabled()) {
        monitor.worked(10);
        continue;
      }
      RuntimeDefinition runtimeDefinition =
          detector.getRuntimeDefinition(directory, new SubProgressMonitor(monitor, 10));
      if (runtimeDefinition != null) {
        runtimeCollector.add(runtimeDefinition);
        monitor.done();
        return;
      }
    }

    File[] files =
        directory.listFiles(
            new FileFilter() {
              public boolean accept(File file) {
                return file.isDirectory();
              }
            });

    SubProgressMonitor childrenMonitor = new SubProgressMonitor(monitor, 1000);
    childrenMonitor.beginTask("", 100 * files.length);
    if (files != null) {
      int size = files.length;
      for (int i = 0; i < size; i++) {
        if (monitor.isCanceled()) return;
        searchDirectory(
            files[i],
            runtimeCollector,
            depth - 1,
            runtimeDetectors,
            new SubProgressMonitor(childrenMonitor, 100));
      }
    }
    childrenMonitor.done();
  }