Search in sources :

Example 1 with GitModelCacheFile

use of org.eclipse.egit.ui.internal.synchronize.model.GitModelCacheFile in project egit by eclipse.

the class GitOpenInCompareAction method handleGitObjectComparison.

private void handleGitObjectComparison(GitModelBlob obj, boolean reuseEditor) {
    ITypedElement left;
    ITypedElement right;
    if (obj instanceof GitModelWorkingFile) {
        IPath location = obj.getLocation();
        if (location == null) {
            return;
        }
        IFile file = ResourceUtil.getFileForLocation(location, false);
        if (file == null) {
            Repository repository = null;
            GitModelObject modelObject = obj;
            while (modelObject != null) {
                if (modelObject instanceof GitModelRepository) {
                    repository = ((GitModelRepository) modelObject).getRepository();
                    break;
                }
                modelObject = modelObject.getParent();
            }
            if (repository == null) {
                return;
            }
            left = new LocalNonWorkspaceTypedElement(repository, location);
        } else {
            left = SaveableCompareEditorInput.createFileElement(file);
        }
        right = getCachedFileElement(obj);
    } else if (obj instanceof GitModelCacheFile) {
        left = getCachedFileElement(obj);
        right = getHeadFileElement(obj);
        if (right == null)
            return;
    } else {
        oldAction.run();
        return;
    }
    GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(left, right, null);
    IWorkbenchPage page = getWorkbenchPage(conf.getSite());
    OpenInCompareAction.openCompareEditor(in, page, reuseEditor);
}
Also used : GitModelRepository(org.eclipse.egit.ui.internal.synchronize.model.GitModelRepository) Repository(org.eclipse.jgit.lib.Repository) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) GitModelWorkingFile(org.eclipse.egit.ui.internal.synchronize.model.GitModelWorkingFile) GitCompareFileRevisionEditorInput(org.eclipse.egit.ui.internal.revision.GitCompareFileRevisionEditorInput) ITypedElement(org.eclipse.compare.ITypedElement) LocalNonWorkspaceTypedElement(org.eclipse.egit.ui.internal.synchronize.compare.LocalNonWorkspaceTypedElement) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) GitModelRepository(org.eclipse.egit.ui.internal.synchronize.model.GitModelRepository) GitModelCacheFile(org.eclipse.egit.ui.internal.synchronize.model.GitModelCacheFile) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)

Aggregations

ITypedElement (org.eclipse.compare.ITypedElement)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 GitCompareFileRevisionEditorInput (org.eclipse.egit.ui.internal.revision.GitCompareFileRevisionEditorInput)1 LocalNonWorkspaceTypedElement (org.eclipse.egit.ui.internal.synchronize.compare.LocalNonWorkspaceTypedElement)1 GitModelCacheFile (org.eclipse.egit.ui.internal.synchronize.model.GitModelCacheFile)1 GitModelObject (org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)1 GitModelRepository (org.eclipse.egit.ui.internal.synchronize.model.GitModelRepository)1 GitModelWorkingFile (org.eclipse.egit.ui.internal.synchronize.model.GitModelWorkingFile)1 Repository (org.eclipse.jgit.lib.Repository)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1