protected void collectFiles(IContainer parent, List result) {
   try {
     IResource[] resources = parent.members();
     for (int i = 0; i < resources.length; i++) {
       IResource resource = resources[i];
       if (resource instanceof IFile) {
         result.add(resource);
       } else if (resource instanceof IContainer) {
         collectFiles((IContainer) resource, result);
       }
     }
   } catch (CoreException e) {
     MakeCorePlugin.log(e.getStatus());
   }
 }
예제 #2
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
   */
  public Object[] getChildren(Object obj) {
    if (obj instanceof IWorkspaceRoot) {
      try {
        return MakeCorePlugin.getDefault().getTargetManager().getTargetBuilderProjects();
      } catch (CoreException e) {
        MakeCorePlugin.log(e);
      }
    } else if (obj instanceof IContainer) {
      IContainer container = (IContainer) obj;
      ArrayList<Object> children = new ArrayList<Object>();

      boolean isAddingSourceRoots =
          !bFlatten
              && (container instanceof IProject)
              && CCorePlugin.showSourceRootsAtTopOfProject();

      // add source roots if necessary
      if (isAddingSourceRoots) {
        IProject project = (IProject) container;
        ICSourceEntry[] srcEntries = getSourceEntries(project);
        for (ICSourceEntry srcEntry : srcEntries) {
          if (!srcEntry.getFullPath().equals(project.getFullPath())) {
            children.add(new TargetSourceContainer(srcEntry));
          }
        }
      }

      // add regular folders
      try {
        IResource[] resources = container.members();
        for (IResource rc : resources) {
          if (rc instanceof IContainer) {
            if (!(isAddingSourceRoots && isSourceEntry(rc))) {
              children.add(rc);
            }
          }
        }
      } catch (CoreException e) {
        MakeCorePlugin.log(e);
      }

      // finally add targets
      try {
        IMakeTarget[] targets =
            MakeCorePlugin.getDefault().getTargetManager().getTargets(container);
        children.addAll(Arrays.asList(targets));
      } catch (CoreException e) {
        MakeCorePlugin.log(e);
      }
      return children.toArray();

    } else if (obj instanceof TargetSourceContainer) {
      ArrayList<Object> children = new ArrayList<Object>();
      try {
        IContainer container = ((TargetSourceContainer) obj).getContainer();
        IResource[] resources = container.members();
        for (IResource rc : resources) {
          if (rc instanceof IContainer) {
            children.add(rc);
          }
        }
        children.addAll(
            Arrays.asList(MakeCorePlugin.getDefault().getTargetManager().getTargets(container)));
      } catch (CoreException e) {
        MakeCorePlugin.log(e);
      }
      return children.toArray();
    }
    return new Object[0];
  }