Search in sources :

Example 6 with IDiffContainer

use of org.eclipse.compare.structuremergeviewer.IDiffContainer in project egit by eclipse.

the class GitMergeEditorInput method getFileParent.

private IDiffContainer getFileParent(IDiffContainer root, IPath repositoryPath, IFile file, IPath location) {
    int projectSegment = -1;
    String projectName = null;
    if (file != null) {
        IProject project = file.getProject();
        IPath projectLocation = project.getLocation();
        if (projectLocation != null) {
            IPath projectPath = project.getLocation().makeRelativeTo(repositoryPath);
            projectSegment = projectPath.segmentCount() - 1;
            projectName = project.getName();
        }
    }
    IPath path = location.makeRelativeTo(repositoryPath);
    IDiffContainer child = root;
    for (int i = 0; i < path.segmentCount() - 1; i++) {
        if (i == projectSegment)
            child = getOrCreateChild(child, projectName, true);
        else
            child = getOrCreateChild(child, path.segment(i), false);
    }
    return child;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IDiffContainer(org.eclipse.compare.structuremergeviewer.IDiffContainer) IProject(org.eclipse.core.resources.IProject)

Aggregations

IDiffContainer (org.eclipse.compare.structuremergeviewer.IDiffContainer)6 IPath (org.eclipse.core.runtime.IPath)3 ArrayList (java.util.ArrayList)2 ITypedElement (org.eclipse.compare.ITypedElement)2 DiffNode (org.eclipse.compare.structuremergeviewer.DiffNode)2 Path (org.eclipse.core.runtime.Path)2 GitFileRevision (org.eclipse.egit.core.internal.storage.GitFileRevision)2 FileRevisionTypedElement (org.eclipse.egit.ui.internal.revision.FileRevisionTypedElement)2 DirCacheIterator (org.eclipse.jgit.dircache.DirCacheIterator)2 AbstractTreeIterator (org.eclipse.jgit.treewalk.AbstractTreeIterator)2 FileTreeIterator (org.eclipse.jgit.treewalk.FileTreeIterator)2 TreeWalk (org.eclipse.jgit.treewalk.TreeWalk)2 OrTreeFilter (org.eclipse.jgit.treewalk.filter.OrTreeFilter)2 TreeFilter (org.eclipse.jgit.treewalk.filter.TreeFilter)2 IOException (java.io.IOException)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 WorkingTreeFileRevision (org.eclipse.egit.core.internal.storage.WorkingTreeFileRevision)1 EditableRevision (org.eclipse.egit.ui.internal.revision.EditableRevision)1