Esempio n. 1
0
  public static String getProjectName(URI uri) {
    if ("platform".equals(uri.scheme())) {
      if (uri.segmentCount() < 3) {
        return null;
      }

      String[] segments = uri.segments();
      if (!"resource".equals(segments[0])) {
        return null;
      }

      return segments[1];
    }

    if ("file".equals(uri.scheme())) {
      // TODO getLocation() not working for linked projects!!!
      String[] wsSegments = ResourcesHelper.ROOT.getLocation().segments();
      String[] uriSegments = uri.segments();
      if (uriSegments.length - 1 < wsSegments.length) {
        return null;
      }

      for (int i = 0; i < wsSegments.length; i++) {
        String wsSegment = wsSegments[i];
        String uriSegment = uriSegments[i];
        if (!uriSegment.equals(wsSegment)) {
          return null;
        }
      }

      return uriSegments[wsSegments.length];
    }

    return null;
  }
  public Set<IProject> getAllProjects() {
    Set<IProject> result = new HashSet<IProject>();
    result.add(getProject());

    for (IPath fullPath : inputToGenAppsMap.keySet()) {
      IResource resource = ResourcesHelper.ROOT.findMember(fullPath);
      if (resource != null) result.add(resource.getProject());
    }

    for (IPath fullPath : targetToGenAppsMap.keySet()) {
      IResource resource = ResourcesHelper.ROOT.findMember(fullPath);
      if (resource != null) result.add(resource.getProject());
    }

    return result;
  }
Esempio n. 3
0
  public static IFile getFile(Resource resource) {
    URI uri = resource.getURI();
    if (!"platform".equals(uri.scheme())) {
      return null;
    }
    if (uri.segmentCount() < 3) {
      return null;
    }

    String[] segments = uri.segments();
    if (!"resource".equals(segments[0])) {
      return null;
    }

    IPath path = new Path("/");
    for (int i = 1; i < segments.length; i++) {
      path = path.append(segments[i]);
    }

    return ResourcesHelper.ROOT.getFile(path);
  }