Esempio n. 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;
      }
    }
  }
Esempio n. 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;
  }