コード例 #1
0
 private static boolean hasChanged(IMonitorModelBase model, long timestamp) {
   if (model.getUnderlyingResource() != null) {
     File[] files = new File(model.getInstallLocation()).listFiles();
     if (files != null) {
       for (int i = 0; i < files.length; i++) {
         if (files[i].isDirectory()) continue;
         String name = files[i].getName();
         if (name.startsWith(Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME)
             && name.endsWith(".properties") // $NON-NLS-1$
             && files[i].lastModified() > timestamp) {
           return true;
         }
       }
     }
   }
   return false;
 }
コード例 #2
0
 private boolean isPerfectMatch(IMonitorModelBase model, IPath path) {
   return model == null ? false : path.equals(new Path(model.getInstallLocation()));
 }
コード例 #3
0
  private boolean resourceExists(String location) {
    String bundleJar = null;
    IPath path = new Path(location);
    if ("platform:".equals(path.getDevice()) && path.segmentCount() > 2) { // $NON-NLS-1$
      if ("plugin".equals(path.segment(0))) { // $NON-NLS-1$
        String id = path.segment(1);
        IMonitorModelBase model = MonitorRegistry.findModel(id);
        if (model != null && model.isEnabled()) {
          path = path.setDevice(null).removeFirstSegments(2);
          String bundleLocation = model.getInstallLocation();
          if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$
            bundleJar = bundleLocation;
          } else {
            path = new Path(model.getInstallLocation()).append(path);
          }
          location = path.toString();
        }
      }
    } else if (path.getDevice() == null
        && path.segmentCount() > 3
        && "platform:".equals(path.segment(0))) { // $NON-NLS-1$
      if ("plugin".equals(path.segment(1))) { // $NON-NLS-1$
        String id = path.segment(2);
        IMonitorModelBase model = MonitorRegistry.findModel(id);
        if (model != null && model.isEnabled()) {
          path = path.removeFirstSegments(3);
          String bundleLocation = model.getInstallLocation();
          if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$
            bundleJar = bundleLocation;
          } else {
            path = new Path(model.getInstallLocation()).append(path);
          }
          location = path.toString();
        }
      }
    }

    ArrayList paths = new ArrayList();
    if (location.indexOf("$nl$") != -1) { // $NON-NLS-1$
      StringTokenizer tokenizer = new StringTokenizer(TargetPlatform.getNL(), "_"); // $NON-NLS-1$
      String language = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
      String country = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
      if (language != null && country != null)
        paths.add(
            location.replaceAll(
                "\\$nl\\$",
                "nl"
                    + IPath.SEPARATOR
                    + language
                    + IPath.SEPARATOR
                    + country)); //$NON-NLS-1$ //$NON-NLS-2$
      if (language != null)
        paths.add(
            location.replaceAll(
                "\\$nl\\$", "nl" + IPath.SEPARATOR + language)); // $NON-NLS-1$ //$NON-NLS-2$
      paths.add(location.replaceAll("\\$nl\\$", "")); // $NON-NLS-1$ //$NON-NLS-2$
    } else {
      paths.add(location);
    }

    for (int i = 0; i < paths.size(); i++) {
      if (bundleJar == null) {
        IPath currPath = new Path(paths.get(i).toString());
        if (currPath.isAbsolute() && currPath.toFile().exists()) return true;
        if (PDEProject.getBundleRoot(fFile.getProject()).findMember(currPath) != null) return true;
        if (fBuildModel != null
            && fBuildModel.getEntry("source." + paths.get(i)) != null) // $NON-NLS-1$
        return true;
      } else {
        if (CoreUtility.jarContainsResource(new File(bundleJar), paths.get(i).toString(), false))
          return true;
      }
    }

    return false;
  }