Search in sources :

Example 1 with GitResourceDeltaVisitor

use of org.eclipse.egit.core.internal.indexdiff.GitResourceDeltaVisitor in project egit by eclipse.

the class GitSubscriberMergeContext method scanDeltaAndRefresh.

private void scanDeltaAndRefresh(RepositoryMapping mapping, IResourceDelta delta) {
    Repository repo = mapping.getRepository();
    GitResourceDeltaVisitor visitor = new GitResourceDeltaVisitor(repo);
    try {
        delta.accept(visitor);
        Collection<IFile> files = visitor.getFileResourcesToUpdate();
        if (files != null && files.isEmpty())
            return;
        for (GitSynchronizeData gsd : gsds) {
            if (repo.equals(gsd.getRepository()))
                refreshResources(files);
        }
    } catch (CoreException e) {
        Activator.logError(e.getMessage(), e);
    }
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) Repository(org.eclipse.jgit.lib.Repository) GitResourceDeltaVisitor(org.eclipse.egit.core.internal.indexdiff.GitResourceDeltaVisitor) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with GitResourceDeltaVisitor

use of org.eclipse.egit.core.internal.indexdiff.GitResourceDeltaVisitor in project egit by eclipse.

the class GitResourceDeltaTestHelper method setUp.

public void setUp() {
    resourceChangeListener = new IResourceChangeListener() {

        @Override
        public void resourceChanged(final IResourceChangeEvent event) {
            try {
                event.getDelta().accept(new IResourceDeltaVisitor() {

                    @Override
                    public boolean visit(IResourceDelta delta) throws CoreException {
                        final IResource resource = delta.getResource();
                        IProject project = resource.getProject();
                        if (project == null)
                            return true;
                        RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
                        if (mapping == null)
                            return true;
                        if (mapping.getRepository() != repository)
                            return false;
                        GitResourceDeltaVisitor visitor = new GitResourceDeltaVisitor(repository);
                        try {
                            event.getDelta().accept(visitor);
                        } catch (CoreException e) {
                            String msg = "Exception during accept of GitResourceDeltaVisitor for resource delta";
                            throw new RuntimeException(msg, e);
                        }
                        IPath gitDirAbsolutePath = mapping.getGitDirAbsolutePath();
                        for (IResource res : visitor.getResourcesToUpdate()) {
                            if (ignoreTeamPrivateMember && (res.isTeamPrivateMember() || gitDirAbsolutePath.isPrefixOf(res.getRawLocation().makeAbsolute())))
                                continue;
                            changedResources.add(res);
                        }
                        return false;
                    }
                });
            } catch (CoreException e) {
                throw new RuntimeException("Exception during accept of test visitor for resource delta", e);
            }
        }
    };
    ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
}
Also used : IPath(org.eclipse.core.runtime.IPath) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) IProject(org.eclipse.core.resources.IProject) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) GitResourceDeltaVisitor(org.eclipse.egit.core.internal.indexdiff.GitResourceDeltaVisitor) CoreException(org.eclipse.core.runtime.CoreException) IResourceDeltaVisitor(org.eclipse.core.resources.IResourceDeltaVisitor) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)2 GitResourceDeltaVisitor (org.eclipse.egit.core.internal.indexdiff.GitResourceDeltaVisitor)2 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 IResourceDelta (org.eclipse.core.resources.IResourceDelta)1 IResourceDeltaVisitor (org.eclipse.core.resources.IResourceDeltaVisitor)1 IPath (org.eclipse.core.runtime.IPath)1 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)1 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)1 Repository (org.eclipse.jgit.lib.Repository)1