Example #1
0
 /**
  * Check if the resource is in the list of source entries.
  *
  * @param rc - resource to check.
  * @return {@code true} if the resource is a source folder, {@code false} otherwise.
  * @since 7.1
  */
 public static boolean isSourceEntry(IResource rc) {
   IProject project = rc.getProject();
   ICSourceEntry[] srcEntries = getSourceEntries(project);
   for (ICSourceEntry srcEntry : srcEntries) {
     if (srcEntry.getFullPath().equals(rc.getFullPath())) return true;
   }
   return false;
 }
  public Map<String, String> getSourceDirsAndExclusionPatterns() {
    ICSourceEntry[] sources = config.getSourceEntries();
    Map<String, String> dirsAndExclusions = new LinkedHashMap<String, String>();

    for (ICSourceEntry s : sources) {
      String path =
          s.getFullPath().segmentCount() == 0 ? project.getName() : s.getFullPath().toString();
      dirsAndExclusions.put(path, transformExclusionPatterns(s.getExclusionPatterns()));
    }

    return dirsAndExclusions;
  }
Example #3
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];
  }