Ejemplo n.º 1
0
 /**
  * Gather the resources of the specified type that match the current pattern string. Gather the
  * resources using the proxy visitor since this is quicker than getting the entire resource.
  *
  * @param resources resources that match
  */
 private void getMatchingResources(final ArrayList resources) {
   try {
     container.accept(
         new IResourceProxyVisitor() {
           public boolean visit(IResourceProxy proxy) {
             // optionally exclude derived resources (bugs 38085 and 81333)
             if (!getShowDerived() && proxy.isDerived()) {
               return false;
             }
             int type = proxy.getType();
             if ((typeMask & type) != 0) {
               if (match(proxy.getName())) {
                 IResource res = proxy.requestResource();
                 if (select(res)) {
                   resources.add(res);
                   return true;
                 }
                 return false;
               }
             }
             if (type == IResource.FILE) {
               return false;
             }
             return true;
           }
         },
         IResource.NONE);
   } catch (CoreException e) {
     // ignore
   }
 }
Ejemplo n.º 2
0
    /**
     * file color changed. reevaluate everything affected by this file TODO: for now only reevaluate
     * checks in this file
     */
    public void fileColorChanged(FileColorChangedEvent event) {
      final HashSet<ColoredSourceFile> toCheck = new HashSet<ColoredSourceFile>();
      for (IContainer folder : event.getAffectedFolders()) {
        try {
          if (folder.exists())
            folder.accept(
                new IResourceVisitor() {

                  public boolean visit(IResource resource) throws CoreException {
                    if (resource instanceof IFile)
                      try {
                        toCheck.add(ColoredSourceFile.getColoredSourceFile((IFile) resource));
                      } catch (FeatureModelNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                      }
                    return true;
                  }
                });
        } catch (CoreException e) {
          e.printStackTrace();
        }
      }

      reevaluateFileChecks(toCheck);
    }
Ejemplo n.º 3
0
 private void shrubOutFolder(final IProgressMonitor mon) throws CoreException {
   mon.subTask(CoreTexts.cleanOutFoldersOperation_shrubbingOut);
   IContainer outFolder = project.getFolder(ScionPlugin.DIST_FOLDER);
   // ResourceUtil.getOutFolder( project );
   if (outFolder != null && !outFolder.equals(project)) {
     outFolder.accept(folderCleaner, IContainer.INCLUDE_PHANTOMS);
   }
   mon.worked(12);
 }
Ejemplo n.º 4
0
 private static IResource findResource(
     final IContainer container, final String fileName, final int how) {
   final FindResourceVisitor visitor = new FindResourceVisitor(fileName, how);
   try {
     container.accept(visitor);
   } catch (final CoreException e) {
     return null;
   }
   return visitor.getFound();
 }
  private List<IResource> getChildResources(final IContainer parent, int depth)
      throws CoreException {
    final List<IResource> result = new ArrayList<IResource>();

    parent.accept(
        new IResourceVisitor() {
          public boolean visit(IResource resource) throws CoreException {
            if (!resource.equals(parent)) {
              result.add(resource);
            }

            return true;
          }
        },
        depth,
        IResource.NONE);

    return result;
  }
Ejemplo n.º 6
0
    /**
     * file color changed. reevaluate everything affected by this file TODO: for now only reevaluate
     * checks in this file
     */
    public void fileColorChanged(FileColorChangedEvent event) {
      final HashSet<CLRAnnotatedSourceFile> toCheck = new HashSet<CLRAnnotatedSourceFile>();
      for (IContainer folder : event.getAffectedFolders()) {
        try {
          if (folder.exists())
            folder.accept(
                new IResourceVisitor() {

                  public boolean visit(IResource resource) throws CoreException {
                    if (resource instanceof IFile)
                      toCheck.add(
                          (CLRAnnotatedSourceFile)
                              CLRAnnotatedSourceFile.getColoredJavaSourceFile((IFile) resource));

                    return true;
                  }
                });
        } catch (CoreException e) {
          e.printStackTrace();
        }
      }

      reevaluateFileChecks(toCheck);
    }