/**
  * Retrieves the package portion of the current directory if it is a package, null otherwise.
  *
  * @return String representation of the current package, or null
  */
 private String getPackagePortionOfCurrentDirectory() {
   for (DirectoryResource r : project.getFacet(JavaSourceFacet.class).getSourceFolders()) {
     final DirectoryResource currentDirectory = shell.getCurrentDirectory();
     if (ResourceUtil.isChildOf(r, currentDirectory)) {
       // Have to remember to include the last slash so it's not part of the package
       return currentDirectory
           .getFullyQualifiedName()
           .replace(r.getFullyQualifiedName() + "/", "")
           .replaceAll("/", ".");
     }
   }
   return null;
 }
Пример #2
0
 @Override
 public List<String> getWebPaths(final Resource<?> r) {
   if (r != null) {
     WebResourceFacet web = project.getFacet(WebResourceFacet.class);
     List<DirectoryResource> webRootDirectories = web.getWebRootDirectories();
     for (DirectoryResource d : webRootDirectories) {
       if (r.getFullyQualifiedName().startsWith(d.getFullyQualifiedName())) {
         String path = r.getFullyQualifiedName().substring(d.getFullyQualifiedName().length());
         return getWebPaths(path);
       }
     }
   }
   return new ArrayList<String>();
 }
Пример #3
0
  @Override
  public List<String> getWebPaths(Resource<?> r) {
    List<String> results = new ArrayList<String>();

    if (r != null) {
      WebResourceFacet web = project.getFacet(WebResourceFacet.class);
      List<DirectoryResource> webRootDirectories = web.getWebRootDirectories();
      for (DirectoryResource d : webRootDirectories) {
        if (r.getFullyQualifiedName().startsWith(d.getFullyQualifiedName())) {
          String path = r.getFullyQualifiedName().substring(d.getFullyQualifiedName().length());

          for (String p : getWebPaths(path)) {
            if (!results.contains(p)) results.add(p);
          }
          break;
        }
      }
    }
    return results;
  }