Java 类org.eclipse.core.resources.IResourceDeltaVisitor 实例源码

项目:team-explorer-everywhere    文件:ImportLocalPathStrategy.java   
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    try {
        event.getDelta().accept(new IResourceDeltaVisitor() {
            @Override
            public boolean visit(final IResourceDelta delta) throws CoreException {
                if (delta.getKind() == IResourceDelta.ADDED) {
                    final IResource resource = delta.getResource();
                    if (resource.getType() == IResource.PROJECT) {
                        newProject = (IProject) resource;
                    } else if (resource.getType() == IResource.FILE
                        && PluginResourceFilters.STANDARD_FILTER.filter(
                            resource) == ResourceFilterResult.ACCEPT) {
                        filepaths.add(resource.getLocation().toOSString());
                    }
                }
                return true;
            }
        });
    } catch (final CoreException e) {
        throw new RuntimeException(e);
    }
}
项目:subclipse    文件:StatusCacheManager.java   
public void resourceChanged(IResourceChangeEvent event) {   
    flushCache = false;
    try {
           event.getDelta().accept(new IResourceDeltaVisitor() {
               public boolean visit(IResourceDelta delta) throws CoreException {
                IResource resource = delta.getResource();
                if (resource.getType()==IResource.PROJECT) {
                    IProject project = (IProject)resource;
                    if (!project.isAccessible()) {
                        return false; // i.e., closed project
                    }
                    if (SVNWorkspaceRoot.isManagedBySubclipse(project)) {
                        flushCache = true;
                    }
                    return false; // No need to check deeper than project.
                }
                   return true;
               }
           });          
    } catch (CoreException e) {
      SVNProviderPlugin.log(e.getStatus());
    }
    if (flushCache) {
        statusCache.flushPendingStatuses();
    }
}
项目:hybris-commerce-eclipse-plugin    文件:PlatformHolder.java   
void workspaceChanged(IResourceChangeEvent event) {
    try {
        if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
            if (Platform.isPlatformProject((IProject)event.getResource())) {
                clear();
            }
        }
        else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
            event.getDelta().accept(new IResourceDeltaVisitor() {

                @Override
                public boolean visit(IResourceDelta delta) throws CoreException {
                    if (delta.getKind() == IResourceDelta.ADDED
                            && delta.getResource().getType() == IResource.PROJECT) {
                        projectAdded((IProject) delta.getResource());
                    }
                    return delta.getResource().getType() == IResource.ROOT;
                }

            });
        }
    } catch (CoreException e) {
        log.log(new Status(Status.ERROR, log.getBundle().getSymbolicName(), "Error when handling IResourceChangedEvent", e));
    }
}
项目:che    文件:ResourceChangeValidator.java   
private IResource[] getRootResources(IResourceDelta root) {
  final ChangeDescription changeDescription = new ChangeDescription();
  try {
    root.accept(
        new IResourceDeltaVisitor() {
          public boolean visit(IResourceDelta delta) {
            return changeDescription.recordChange(delta);
          }
        });
  } catch (CoreException e) {
    // Shouldn't happen since the ProposedResourceDelta accept doesn't throw an
    // exception and our visitor doesn't either
    Policy.log(IStatus.ERROR, "Internal error", e); // $NON-NLS-1$
  }
  return changeDescription.getRootResources();
}
项目:che    文件:ResourceChangeChecker.java   
IFile[] getChangedFiles() throws CoreException {
  IResourceDelta root = fDeltaFactory.getDelta();
  final List result = new ArrayList();
  root.accept(
      new IResourceDeltaVisitor() {
        public boolean visit(IResourceDelta delta) throws CoreException {
          final IResource resource = delta.getResource();
          if (resource.getType() == IResource.FILE) {
            final int kind = delta.getKind();
            if (isSet(kind, IResourceDelta.CHANGED)) {
              result.add(resource);
            } else if (isSet(kind, IResourceDelta.ADDED)
                && isSet(delta.getFlags(), IResourceDelta.CONTENT | IResourceDelta.MOVED_FROM)) {
              final IFile movedFrom =
                  resource.getWorkspace().getRoot().getFile(delta.getMovedFromPath());
              result.add(movedFrom);
            }
          }
          return true;
        }
      });
  return (IFile[]) result.toArray(new IFile[result.size()]);
}
项目:che    文件:ResourceChangeChecker.java   
IFile[] getChangedFiles() throws CoreException {
  IResourceDelta root = fDeltaFactory.getDelta();
  final List result = new ArrayList();
  root.accept(
      new IResourceDeltaVisitor() {
        public boolean visit(IResourceDelta delta) throws CoreException {
          final IResource resource = delta.getResource();
          if (resource.getType() == IResource.FILE) {
            final int kind = delta.getKind();
            if (isSet(kind, IResourceDelta.CHANGED)) {
              result.add(resource);
            } else if (isSet(kind, IResourceDelta.ADDED)
                && isSet(delta.getFlags(), IResourceDelta.CONTENT | IResourceDelta.MOVED_FROM)) {
              final IFile movedFrom =
                  resource.getWorkspace().getRoot().getFile(delta.getMovedFromPath());
              result.add(movedFrom);
            }
          }
          return true;
        }
      });
  return (IFile[]) result.toArray(new IFile[result.size()]);
}
项目:synergyview    文件:MediaRootNode.java   
public void resourceChanged(IResourceChangeEvent event) {
try {
    event.getDelta().accept(new IResourceDeltaVisitor() {
    public boolean visit(IResourceDelta delta) throws CoreException {
        if ((delta.getKind() == IResourceDelta.ADDED) && (delta.getResource() instanceof IFile)) {
        IFile mediaFile = (IFile) delta.getResource();
        IFolder resource = MediaRootNode.this.getResource();
        if (mediaFile.getParent().getFullPath().toString().compareTo(resource.getFullPath().toString()) == 0) {
            addNewMedia(mediaFile);
        }
        } else if ((delta.getKind() == IResourceDelta.REMOVED) && (delta.getResource() == MediaRootNode.this.getResource())) {
        MediaRootNode.this.getParent().deleteChildren(new INode[] { MediaRootNode.this });
        }
        return true;
    }
    });
} catch (CoreException ex) {
    IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex);
    logger.log(status);
}
   }
项目:synergyview    文件:MediaNode.java   
public void resourceChanged(IResourceChangeEvent event) {
try {
    event.getDelta().accept(new IResourceDeltaVisitor() {
    public boolean visit(IResourceDelta delta) throws CoreException {
        // IResource affectedResource = delta.getResource();
        // if (delta.getKind() == IResourceDelta.REMOVED &&
        // affectedResource instanceof IFile) {
        // if
        // (affectedResource.getFullPath().toString().compareTo(MediaNode.this.resource.getFullPath().toString())==0)
        // {
        // MediaNode.this.getParent().deleteChildren(new INode[]
        // {MediaNode.this});
        // }
        // }
        return true;
    }
    });
} catch (CoreException ex) {
    IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex);
    logger.log(status);
}

   }
项目:APICloud-Studio    文件:StatusCacheManager.java   
public void resourceChanged(IResourceChangeEvent event) {   
    flushCache = false;
    try {
           event.getDelta().accept(new IResourceDeltaVisitor() {
               public boolean visit(IResourceDelta delta) throws CoreException {
                IResource resource = delta.getResource();
                if (resource.getType()==IResource.PROJECT) {
                    IProject project = (IProject)resource;
                    if (!project.isAccessible()) {
                        return false; // i.e., closed project
                    }
                    if (SVNWorkspaceRoot.isManagedBySubclipse(project)) {
                        flushCache = true;
                    }
                    return false; // No need to check deeper than project.
                }
                   return true;
               }
           });          
    } catch (CoreException e) {
      SVNProviderPlugin.log(e.getStatus());
    }
    if (flushCache) {
        statusCache.flushPendingStatuses();
    }
}
项目:slr-toolkit    文件:BibtexEntryView.java   
/**
 * Returns a list of newly added projects.
 * @param resourceDelta
 * @return List of newly added projects.
 */
private List<IProject> getAddedProjects(IResourceDelta resourceDelta){
    final List<IProject> projects = new ArrayList<IProject>();
    try {
        resourceDelta.accept(new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) throws CoreException {
                if (delta.getKind() == IResourceDelta.ADDED && delta.getResource().getType() == IResource.PROJECT) {
                    IProject project = (IProject) delta.getResource();
                    projects.add(project);
                    return false;
                }
                return delta.getResource().getType() == IResource.ROOT;
            }
        });
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return projects;
}
项目:cmake-eclipse-helper    文件:CMakeProjectResourceChangeListener.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    try {
        IResourceDelta delta = event.getDelta();

        CMakeTouchDeltaVisitor touchVisitor = new CMakeTouchDeltaVisitor();

        delta.accept(touchVisitor);
        touchVisitor.postProcess();

        for(IResourceDeltaVisitor visitor : reusableVisitors) {
            delta.accept(visitor);
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
项目:rustyeclipse    文件:Decorators.java   
@Override
public void resourceChanged(@Nullable IResourceChangeEvent event) {
    Preconditions.checkNotNull(event);
    if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
        IResourceDelta delta = event.getDelta();


        IResourceDeltaVisitor visitor = delta1 -> {
            resources.add(delta1.getResource());
            return true;
        };
        try {
            synchronized (this) {
                visitor.visit(delta);
            }
        } catch (CoreException e) {
            e.printStackTrace();
        }
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
                fireLabelChangedEvent();
            }
        });
    }
}
项目:robovm-eclipse    文件:RoboVMProjectObserver.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event == null || event.getDelta() == null) {
        return;
    }

    try {
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(final IResourceDelta delta) throws CoreException {
                IResource resource = delta.getResource();                    
                if ((resource.getType() & IResource.PROJECT) != 0) {
                    IProject project = (IProject) resource;                        
                    if (project.isOpen()) {                            
                        projectChanged(project);
                        return false;
                    }
                }
                return true;
            }                
        });

    } catch (Throwable t) {
        RoboVMPlugin.log(t);
    }
}
项目:Pydev    文件:SearchResultUpdater.java   
private void handleDelta(IResourceDelta d) {
    try {
        d.accept(new IResourceDeltaVisitor() {
            @Override
            public boolean visit(IResourceDelta delta) throws CoreException {
                switch (delta.getKind()) {
                    case IResourceDelta.ADDED:
                        return false;
                    case IResourceDelta.REMOVED:
                        IResource res = delta.getResource();
                        if (res instanceof IFile) {
                            Match[] matches = fResult.getMatches(res);
                            fResult.removeMatches(matches);
                        }
                        break;
                    case IResourceDelta.CHANGED:
                        // handle changed resource (remove existing matches and redo search in file).
                        break;
                }
                return true;
            }
        });
    } catch (CoreException e) {
        Log.log(e);
    }
}
项目:Pydev    文件:SearchResultUpdater.java   
private void handleDelta(IResourceDelta d) {
    try {
        d.accept(new IResourceDeltaVisitor() {
            @Override
            public boolean visit(IResourceDelta delta) throws CoreException {
                switch (delta.getKind()) {
                    case IResourceDelta.ADDED:
                        return false;
                    case IResourceDelta.REMOVED:
                        IResource res = delta.getResource();
                        if (res instanceof IFile) {
                            Match[] matches = fResult.getMatches(res);
                            fResult.removeMatches(matches);
                        }
                        break;
                    case IResourceDelta.CHANGED:
                        // handle changed resource
                        break;
                }
                return true;
            }
        });
    } catch (CoreException e) {
        Log.log(e);
    }
}
项目:clickwatch    文件:EmfToolsPlugin.java   
public void resourceChanged(final IResourceChangeEvent event) {
    try {
        // under special circumstances (e.g. renaming a project) the
        // event.getDelta() can be null. Avoid NPE.
        if (event.getDelta() == null)
            return;

        // collect changed projects. only ecore files and jars in the
        // classpath are relevant
        final Set<IProject> changedProjects = new HashSet<IProject>();
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(final IResourceDelta delta) throws CoreException {
                if ((isEcoreFile(delta.getResource()) || isJarFile(delta.getResource()))
                        && JavaCore.create(delta.getResource().getProject()).isOnClasspath(delta.getResource())) {
                    changedProjects.add(delta.getResource().getProject());
                }
                return true;
            }
        });

        analyzeAndRebuildProjects(changedProjects);
    }
    catch (final CoreException e) {
        EmfToolsLog.logError(e);
    }
}
项目:transformAuthoring    文件:XformAccess.java   
public void resourceChanged(IResourceChangeEvent event) {
    IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
        public boolean visit(IResourceDelta delta) {
            IResource affected = delta.getResource();
            if (affected.getType() != IResource.PROJECT) {
                return true;
            }
            if ((delta.getKind() == IResourceDelta.OPEN)|(delta.getKind() == IResourceDelta.REMOVED)) {
                IProject project = (IProject) affected;
                models.remove(project.getName());
            }
              return true;
           }
        };

        try {
        event.getDelta().accept(visitor);
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
项目:neoscada    文件:PreviewEditorImpl.java   
protected void handleResourceChanged ( final IResourceChangeEvent event )
{
    try
    {
        event.getDelta ().accept ( new IResourceDeltaVisitor () {

            @Override
            public boolean visit ( final IResourceDelta delta ) throws CoreException
            {
                return handleResource ( delta );
            }
        } );
    }
    catch ( final CoreException e )
    {
        StatusManager.getManager ().handle ( e.getStatus () );
    }

    if ( this.needReload )
    {
        this.needReload = false;

        getSite ().getShell ().getDisplay ().asyncExec ( new Runnable () {

            @Override
            public void run ()
            {
                reload ();
            }
        } );
    }
}
项目:vertigo-chroma-kspplugin    文件:LegacyManager.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (event == null || event.getDelta() == null || event.getType() != IResourceChangeEvent.POST_CHANGE) {
        return;
    }

    try {
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) throws CoreException {
                final IResource resource = delta.getResource();

                /* Visite le workspace. */
                if (resource instanceof IWorkspaceRoot) {
                    return true;
                }

                /* Visite le projet. */
                if (resource instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) {
                    /* Cas d'un changement : potentiellement une ouverture de projet. */
                    handleProject(resource.getProject());
                }

                return false;
            }
        });
    } catch (CoreException e) {
        ErrorUtils.handle(e);
    }
}
项目:ProtoGen    文件:ResourceChangeListener.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
    try {
        if (event.getType() != IResourceChangeEvent.POST_CHANGE)
            return;
        IResourceDelta rootDelta = event.getDelta();
        rootDelta.accept(new IResourceDeltaVisitor() {
            @Override
            public boolean visit(IResourceDelta delta) throws CoreException {
                if (delta.getKind() != IResourceDelta.CHANGED)
                    return true;
                if ((delta.getFlags() & IResourceDelta.CONTENT) == 0)
                    return true;
                IResource resource = delta.getResource();
                if (resource.getType() == IResource.FILE 
                        && "proto".equalsIgnoreCase(resource.getFileExtension())) {
                    String projectPathStr = workspacePathStr + "/" + resource.getFullPath().segment(0).toString();
                    String protoPathStr = workspacePathStr + resource.getFullPath().toString();
                    executor.execute(new ProtocRunnable(log, genDirName, projectPathStr, protoPathStr));
                }
                return true;
            }
        });
    } catch (Throwable th) {
        log.error(th);
    }
}
项目:subclipse    文件:TeamPrivateListener.java   
/**
 * Listen for file modifications
 * 
 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
 */
public void resourceChanged(IResourceChangeEvent event) {       
    try {
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) throws CoreException {
                IResource resource = delta.getResource();
                int type = resource.getType();

                if(type==IResource.FOLDER) {
                    if (delta.getKind() != IResourceDelta.ADDED)
                        return true;
                    if (provider.isAdminDirectory(resource.getName())) {
                        if (handleSVNDir((IContainer)resource)) {
                            return false;
                        }
                    }
                    return true;
                }               
                else if (type==IResource.PROJECT) {
                    IProject project = (IProject)resource;
                    if (!project.isAccessible()) {
                        return false;
                    }
                    if (!SVNWorkspaceRoot.isManagedBySubclipse(project)) {
                        return false; // not a svn handled project
                    }
                }
                return true;
            }
        });
    } catch (CoreException e) {
        SVNProviderPlugin.log(e.getStatus());
    }           
}
项目:mesfavoris    文件:BookmarksMarkers.java   
public void resourceChanged(final IResourceChangeEvent event) {
    try {
        if (event.getDelta() == null) {
            return;
        }
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(final IResourceDelta delta) throws CoreException {
                IResource resource = delta.getResource();
                if ((resource.getType() & IResource.PROJECT) != 0) {
                    if (resource.getProject().isOpen() && delta.getKind() == IResourceDelta.CHANGED
                            && ((delta.getFlags() & IResourceDelta.OPEN) != 0)) {

                        final IProject project = (IProject) resource;
                        new Job("Updating project markers") {

                            @Override
                            protected IStatus run(IProgressMonitor monitor) {
                                projectOpened(project, monitor);
                                return Status.OK_STATUS;
                            }
                        }.schedule();
                    }
                    return false;
                }
                return true;
            }
        });
    } catch (CoreException e) {
        StatusHelper.logWarn("Error while listening to project opened events", e);
    }
}
项目:scribble-eclipse    文件:Activator.java   
/**
 * {@inheritDoc}
 */
public void start(final BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    // Register resource change listener
    IResourceChangeListener rcl=new IResourceChangeListener() {
        public void resourceChanged(IResourceChangeEvent evt) {       
            try {
                evt.getDelta().accept(new IResourceDeltaVisitor() {                        
                    public boolean visit(IResourceDelta delta) {
                        boolean ret=true;
                        IResource res = delta.getResource();                           
                        // Determine if the change is relevant
                        if (isChangeRelevant(res, delta)) {
                            // Validate the resource
                            _validator.validateResource(res);
                        }
                        return (ret);
                    }
                 });
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Failed to process resource change event", e);
            }
        }
    };

    // Register the resource change listener
    ResourcesPlugin.getWorkspace().addResourceChangeListener(rcl,
            IResourceChangeEvent.POST_CHANGE);        
}
项目:che    文件:TestModelProvider.java   
private static void assertCopySource(IResourceDelta delta) {
  try {
    delta.accept(
        new IResourceDeltaVisitor() {
          public boolean visit(IResourceDelta d) throws CoreException {
            Assert.assertTrue("Not a copy delta", (d.getKind() & ~IResourceDelta.CHANGED) == 0);
            return true;
          }
        });
  } catch (CoreException e) {
    Assert.assertTrue("Shouldn't happen", false);
  }
}
项目:che    文件:ProposedResourceDelta.java   
public void accept(IResourceDeltaVisitor visitor, int memberFlags) throws CoreException {
  if (!visitor.visit(this)) return;
  for (Iterator<ProposedResourceDelta> iter = children.values().iterator(); iter.hasNext(); ) {
    ProposedResourceDelta childDelta = iter.next();
    childDelta.accept(visitor, memberFlags);
  }
}
项目:che    文件:ResourceDeltaImpl.java   
@Override
public void accept(IResourceDeltaVisitor visitor, int memberFlags) throws CoreException {
  final boolean includePhantoms = (memberFlags & IContainer.INCLUDE_PHANTOMS) != 0;
  //        final boolean includeTeamPrivate = (memberFlags &
  // IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS) != 0;
  //        final boolean includeHidden = (memberFlags & IContainer.INCLUDE_HIDDEN) != 0;
  //        int mask = includePhantoms ? ALL_WITH_PHANTOMS : REMOVED | ADDED | CHANGED;
  //        if ((getKind() & mask) == 0)
  //            return;
  //        if (!visitor.visit(this))
  //            return;
  visitor.visit(this);
}
项目:depan    文件:ResourceCache.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {
  try {
    IResourceDeltaVisitor visitor = new ForgetResources();
    event.getDelta().accept(visitor);
  } catch (CoreException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}
项目:Swiper    文件:SwiperPostSyncBuilder.java   
private boolean isRelevant(IResourceDelta delta) throws CoreException {
    final boolean[] arrayOfBoolean = new boolean[1];
    delta.accept(new IResourceDeltaVisitor() {
        public boolean visit(IResourceDelta paramAnonymousIResourceDelta) {
            switch (paramAnonymousIResourceDelta.getKind()) {
            case 1:
                if ((paramAnonymousIResourceDelta.getResource() instanceof IFile)) {
                    arrayOfBoolean[0] = true;
                    return false;
                }
                break;
            case 4:
                if ((paramAnonymousIResourceDelta.getResource() instanceof IFile)) {
                    arrayOfBoolean[0] = true;
                    return false;
                }
                break;
            case 2:
                IResource localIResource = paramAnonymousIResourceDelta
                        .getResource();
                if (localIResource.getType() == 1) {
                    arrayOfBoolean[0] = true;
                    return false;
                }
                break;
            }
            return true;
        }
    });
    return arrayOfBoolean[0];
}
项目:Swiper    文件:SwiperPreSyncBuilder.java   
private boolean isRelevant(IResourceDelta delta) throws CoreException {
    final boolean[] arrayOfBoolean = new boolean[1];
    delta.accept(new IResourceDeltaVisitor() {
        public boolean visit(IResourceDelta paramAnonymousIResourceDelta) {
            switch (paramAnonymousIResourceDelta.getKind()) {
            case 1:
                if ((paramAnonymousIResourceDelta.getResource() instanceof IFile)) {
                    arrayOfBoolean[0] = true;
                    return false;
                }
                break;
            case 4:
                if ((paramAnonymousIResourceDelta.getResource() instanceof IFile)) {
                    arrayOfBoolean[0] = true;
                    return false;
                }
                break;
            case 2:
                IResource localIResource = paramAnonymousIResourceDelta
                        .getResource();
                if (localIResource.getType() == 1) {
                    arrayOfBoolean[0] = true;
                    return false;
                }
                break;
            }
            return true;
        }
    });
    return arrayOfBoolean[0];
}
项目:APICloud-Studio    文件:TeamPrivateListener.java   
/**
 * Listen for file modifications
 * 
 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
 */
public void resourceChanged(IResourceChangeEvent event) {       
    try {
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) throws CoreException {
                IResource resource = delta.getResource();
                int type = resource.getType();

                if(type==IResource.FOLDER) {
                    if (delta.getKind() != IResourceDelta.ADDED)
                        return true;
                    if (provider.isAdminDirectory(resource.getName())) {
                        if (handleSVNDir((IContainer)resource)) {
                            return false;
                        }
                    }
                    return true;
                }               
                else if (type==IResource.PROJECT) {
                    IProject project = (IProject)resource;
                    if (!project.isAccessible()) {
                        return false;
                    }
                    if (!SVNWorkspaceRoot.isManagedBySubclipse(project)) {
                        return false; // not a svn handled project
                    }
                }
                return true;
            }
        });
    } catch (CoreException e) {
        SVNProviderPlugin.log(e.getStatus());
    }           
}
项目:OpenSPIFe    文件:ResourceModificationWatcher.java   
public void watch(final IWorkspaceRunnable runnable, final IProgressMonitor monitor) throws CoreException {
    runAndListen(runnable, new IResourceDeltaVisitor() {
        @Override
        public boolean visit(IResourceDelta delta) {
            final IResource resource = delta.getResource();
            final long modificationStamp = resource.getLocalTimeStamp();
            modStamps.put(resource, modificationStamp);
            return true;
        }
    }, monitor);
}
项目:XPagesExtensionLibrary    文件:ExtLibDesignElementLookup.java   
public void resourceChanged(IResourceChangeEvent event) {
            // @TODO: need to filter resource events!
            try {
                IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {

                    boolean keepVisiting = true;

                    public boolean visit(IResourceDelta delta) {

                        if (!keepVisiting || null == designerProject)
                            return false;

                        int k = delta.getKind();
                        if ( ! (IResourceDelta.ADDED == k || 
                                IResourceDelta.REMOVED == k || 
                                IResourceDelta.CHANGED == k) )  // an update could be a name change
                           return true;

//                       if ((delta.getFlags() ...?
                       IResource resource = delta.getResource();
                       if (resource.getType() == IResource.FILE && resource.getProject().equals(designerProject.getProject())) {
                           String resExt = resource.getFileExtension();
                           String typeExt = extForType(); 
                           if (typeExt.length() > 0 && resExt.length() > 0 &&
                               typeExt.equalsIgnoreCase(resExt)) {
                               keepVisiting = false;
                               updateDesignElements();
                           }
                       }
                       return keepVisiting;
                    }
                 };

                 event.getDelta().accept(visitor);
            }
            catch(Exception e) {
                ExtLibToolingLogger.EXT_LIB_TOOLING_LOGGER.error(e, e.toString());            }
        }
项目:SPLevo    文件:SPLevoProjectWorkspaceObserver.java   
private IResourceChangeListener createProjectOpenCloseListener() {
    return new IResourceChangeListener() {
        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
                handleClosedProject((IProject) event.getResource());
                return;
            }

            if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
                try {
                    event.getDelta().accept(new IResourceDeltaVisitor() {
                        @Override
                        public boolean visit(IResourceDelta delta) throws CoreException {
                            if (delta.getResource() instanceof IWorkspaceRoot) {
                                return true;
                            }

                            if ((delta.getFlags() & IResourceDelta.OPEN) != 0
                                    && delta.getResource() instanceof IProject) {
                                IProject project = (IProject) delta.getResource();
                                if (project.isOpen()) {
                                    handleOpenedProject(project);
                                }
                            }

                            return false;
                        }

                    });
                } catch (CoreException e) {
                    LOGGER.warn(
                            "Error processing a resource change. The VPM loading composite might not be up to date anymore.",
                            e);
                }
            }
        }
    };
}
项目:SPLevo    文件:LoadVPMCompositeHandler.java   
private IResourceChangeListener createProjectOpenCloseListener() {
    return new IResourceChangeListener() {
        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
                projectClosed((IProject) event.getResource());
            }  

            if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
                projectClosed((IProject) event.getResource());
                try {

                    event.getDelta().accept(new IResourceDeltaVisitor() {
                        @Override
                        public boolean visit(IResourceDelta delta) throws CoreException {
                            if (delta.getResource() instanceof IWorkspaceRoot) {
                                return true;
                            }

                            if ((delta.getFlags() & IResourceDelta.OPEN) != 0
                                    && delta.getResource() instanceof IProject) {
                                projectOpened((IProject) delta.getResource());
                            }

                            return false;
                        }

                    });
                } catch (CoreException e) {
                    LOGGER.warn(
                            "Error processing a resource change. The VPM loading composite might not be up to date anymore.",
                            e);
                }
            }
        }
    };
}
项目:FindBug-for-Domino-Designer    文件:FindBugs2Eclipse.java   
public void resourceChanged(IResourceChangeEvent event) {
    if(event.getSource() instanceof IProject) {
        cleanClassClache((IProject) event.getSource());
    } else if (event.getResource() instanceof IProject) {
        cleanClassClache((IProject) event.getResource());
    } else if(event.getDelta() != null) {
        final Set<IProject> affectedProjects = new HashSet<IProject>();
        final IResourceDelta delta = event.getDelta();
        try {
            delta.accept(new IResourceDeltaVisitor() {
                public boolean visit(IResourceDelta d1) throws CoreException {
                    if(d1 == delta || d1.getFlags() == 0 || d1.getFlags() == IResourceDelta.MARKERS) {
                        return true;
                    }
                    IResource resource = d1.getResource();
                    if(resource instanceof IProject) {
                        affectedProjects.add((IProject) resource);
                        return false;
                    }
                    return true;
                }
            });
        } catch (CoreException e) {
            FindbugsPlugin.getDefault().logException(e, "Error traversing resource delta");
        }
        for (IProject iProject : affectedProjects) {
            cleanClassClache(iProject);
        }
    }
}
项目:2uml    文件:ChangeListener.java   
protected void handleDeltaChanges(IResourceDelta rootDelta) {

        Set<IJavaProject> javaProjects = getJavaProjects();

        for (IJavaProject javaProject : javaProjects) {
            IResourceDelta resourceDelta = rootDelta.findMember(javaProject.getPath());
            if (resourceDelta != null) {
                IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
                    public boolean visit(IResourceDelta delta) {
                        // only interested in changed resources (not added or removed)
                        if (delta.getKind() == IResourceDelta.CHANGED) {
                            IResource resource = delta.getResource();
                            if (delta.getKind() == IResourceDelta.ADDED) {
                                handleAddedResource(resource);
                            } else if (delta.getKind() == IResourceDelta.REMOVED) {
                                handleRemovedResource(resource);
                            } else {
                                handleChangedResource(resource);
                            }
                            return true;
                        } else {
                            System.out.println(delta.getKind());
                        }

                        return false;
                    }
                };
                try {
                    resourceDelta.accept(visitor);
                } catch (CoreException e) {
                    // TODO Auto-generated catch block
                    CoreActivator.logUnexpectedError(e);
                }
            }
        }
    }
项目:mule-tooling-incubator    文件:GraphicalMulePropertiesEditor.java   
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    if(event.getType() != IResourceChangeEvent.POST_CHANGE){
        return;
    }

    try {
        final IFile currentFile = ((IFileEditorInput) getEditorInput()).getFile();
        event.getDelta().accept(new IResourceDeltaVisitor() {

            @Override
            public boolean visit(IResourceDelta delta) throws CoreException {

                if(currentFile.equals(delta.getResource())) {
                    Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            updatePartControl(getEditorInput());                        
                        }
                    });
                }
                return true;
            }
        });

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:convertigo-eclipse    文件:ProjectTreeObject.java   
public void resourceChanged(IResourceChangeEvent event) {
        //we are only interested in POST_CHANGE events
        if (event.getType() != IResourceChangeEvent.POST_CHANGE) {
            return;
        }

//      final ProjectTreeObject projectTreeObject = this;
        final String projectName = getName();
        IPath path = new Path(projectName);
        IResourceDelta projectDelta = event.getDelta().findMember(path);
        if (projectDelta == null) {
            return;
        }

        IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) {
                //only interested in changed resources (not added or removed)
                if (delta.getKind() != IResourceDelta.CHANGED) {
                    return true;
                }
                //only interested in content changes
                if ((delta.getFlags() & IResourceDelta.CONTENT) == 0) {
                    return true;
                }

                IResource resource = delta.getResource();

                //only interested in files
                if (resource.getType() == IResource.FILE) {
                    if ("xsd".equalsIgnoreCase(resource.getFileExtension())) {
//                      Project project = getObject();
//                      project.setXsdDirty(true);
//                      TreeObjectEvent treeObjectEvent1 = new TreeObjectEvent(projectTreeObject, "schemaType", null, null, 0);
//                      ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent1);
//                      TreeObjectEvent treeObjectEvent2 = new TreeObjectEvent(projectTreeObject, "xsdFile", null, null, 0);
//                      ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent2);
                    }
                }
                return true;
            }
        };
        try {
            projectDelta.accept(visitor);
        } catch (CoreException e) {

        }
    }
项目:gw4e.project    文件:ResourceManager.java   
@Override
public void resourceChanged(IResourceChangeEvent event) {

    // we are only interested in POST_CHANGE events
    if (event.getType() != IResourceChangeEvent.POST_CHANGE)
        return;
    IResourceDelta rootDelta = event.getDelta();

    final ArrayList changed = new ArrayList();
    IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
        public boolean visit(IResourceDelta delta) {
            // only interested in changed resources (not added or
            // removed)
            if (delta.getKind() != IResourceDelta.CHANGED)
                return true;
            // only interested in content changes
            if ((delta.getFlags() & IResourceDelta.CONTENT) == 0)
                return true;
            IResource resource = delta.getResource();
            // only interested in files with the "java" extension
            if (resource.getType() == IResource.FILE && "java".equalsIgnoreCase(resource.getFileExtension())) {
                changed.add(resource);
            }
            return true;
        }
    };
    try {
        rootDelta.accept(visitor);
    } catch (CoreException e) {
        ResourceManager.logException(e);
    }
    //
    if (changed.size() != 0) {
        for (Object object : changed) {
            if (object instanceof IFile) {
                IFile iFile = (IFile) object;
                IProject project = iFile.getProject();
                if (PreferenceManager.isBuildPoliciesSynchronisationWithTestsAuthrorized(project.getName())) {
                    updateBuildPolicyFileFor(iFile);
                }
            }
        }
    }
}
项目:team-explorer-everywhere    文件:IgnoreFileResourceChangeListener.java   
/**
 * {@inheritDoc}
 */
@Override
public void resourceChanged(final IResourceChangeEvent event) {
    /*
     * See TFSResourceChangeListener for why we do this check.
     */
    if (!TFSEclipseClientPlugin.getDefault().getProjectManager().isStarted()) {
        log.warn("Resource change event called before workbench has started, ignoring resource changes"); //$NON-NLS-1$
        return;
    }

    try {
        event.getDelta().accept(new IResourceDeltaVisitor() {
            @Override
            public boolean visit(final IResourceDelta delta) throws CoreException {
                final IResource resource = delta.getResource();

                if (resource.getType() == IResource.FILE) {
                    if (resource.getProjectRelativePath().equals(TPIGNORE_PROJECT_RELATIVE_PATH)) {
                        TFSLabelDecorator.refreshTFSLabelDecorator();
                        return false;
                    }

                    if (resource.getName().equals(LocalItemExclusionEvaluator.IGNORE_FILE_NAME)) {
                        // Must clear the cached evaluators before
                        // redecorating
                        PluginResourceFilters.TFS_IGNORE_FILTER.clearCachedEvaluators();
                        TFSLabelDecorator.refreshTFSLabelDecorator();
                        return false;
                    }
                }

                // Continue visiting children
                return true;
            }
        });
    } catch (final CoreException e) {
        TFSEclipseClientPlugin.getDefault().getLog().log(e.getStatus());
        return;
    }
}