Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see core.resources.ICoreResource#seek(core.resources.IResourceLocationRequestor)
   */
  public void lookup(IResourceAcceptor requestor, LookupDepth depth) {
    String packageName = fRoot.toPackageName(this);
    IPackageFragment[] fragments = fRoot.getAllPackageFragments(packageName);
    for (int i = 0; i < fragments.length; i++) {
      Object[] nonJavaResources = null;
      try {
        if (fragments[i].isReadOnly()) {
          // TODO - is this the correct check for a package in a jar file?
          nonJavaResources = fragments[i].getNonJavaResources();
        } else {
          IContainer container = (IContainer) fragments[i].getUnderlyingResource();
          if (container != null && container.exists()) {
            IResource[] members = container.members(false);
            ArrayList<IResource> resultList = new ArrayList<IResource>();
            for (int j = 0; j < members.length; j++) {
              if (members[j] instanceof IFile) resultList.add(members[j]);
            }
            nonJavaResources = resultList.toArray();
          }
        }
      } catch (CoreException e) {
        TapestryCore.log(e);
      }
      if (nonJavaResources == null) continue;

      for (int j = 0; j < nonJavaResources.length; j++) {
        IStorage storage = (IStorage) nonJavaResources[j];
        ICoreResource loc = new ClasspathResource(fRoot, getPath() + storage.getName());
        if (!requestor.accept(loc)) break;
      }
    }
  }
Пример #2
0
  public boolean exists() {
    if (!isFolder()) {
      IStorage storage = getStorage();
      if (storage != null) {
        if (storage instanceof IResource) {
          IResource resource = (IResource) storage;
          return resource.exists();
        } else {
          return true;
        }
      }
    } else {

      IPath path = new Path(getPath()).makeAbsolute().removeTrailingSeparator();
      if (path.segmentCount() == 0) // default package
      return true;
      IPackageFragment[] fragments = fRoot.getAllPackageFragments(fRoot.toPackageName(this));
      return fragments != null && fragments.length > 0 && fragments[0].exists();
    }
    return false;
  }
Пример #3
0
  /*
   * (non-Javadoc)
   *
   * @see core.resources.eclipse.IEclipseResource#getStorage()
   */
  @SuppressWarnings("unchecked")
  public IStorage getStorage() {
    // if we are in a build, the storages get cached for speed.
    Map cache = EclipseBuildInfrastructure.getStorageCache();

    if (cache != null && cache.containsKey(this)) return (IStorage) cache.get(this);

    IStorage result = fRoot.findStorage(this);

    if (cache != null) cache.put(this, result);

    return result;
  }
Пример #4
0
 public ClasspathResource(ClasspathRoot root, IPackageFragment fragment, IStorage storage) {
   super(root.getPath(fragment, storage));
   fRoot = root;
 }
Пример #5
0
 public ClasspathResource(ClasspathRoot root, IStorage storage) {
   super(root.findRelativePath(storage));
   fRoot = root;
 }
Пример #6
0
 public boolean equals(Object obj) {
   if (super.equals(obj)) return fRoot.equals(((ClasspathResource) obj).fRoot);
   return false;
 }
Пример #7
0
 /*
  * (non-Javadoc)
  *
  * @see core.resources.ICoreResource#getProject()
  */
 public IProject getProject() {
   IPackageFragment fragment = fRoot.findExactPackageFragment(this);
   return fragment == null ? null : fragment.getJavaProject().getProject();
 }
Пример #8
0
 public ISearch getSearch() throws TapestryCoreException {
   return fRoot.getSearch();
 }