private String getLongName(ITypedElement element) { if (element instanceof FileRevisionTypedElement) { FileRevisionTypedElement fileRevisionElement = (FileRevisionTypedElement) element; return fileRevisionElement.getPath(); } else if (element instanceof LocalResourceTypedElement) { LocalResourceTypedElement typedContent = (LocalResourceTypedElement) element; return typedContent.getResource().getFullPath().toString(); } return element.getName(); }
private String getFileRevisionLabel(FileRevisionTypedElement element) { IFileRevision fileObject = element.getFileRevision(); if (fileObject instanceof LocalFileRevision) { return NLS.bind( Messages.GitCompareFileRevisionEditorInput_localRevision, new Object[] {element.getName(), element.getTimestamp()}); } return NLS.bind( Messages.GitCompareFileRevisionEditorInput_repository, new Object[] {element.getName(), element.getContentIdentifier()}); }
private static void ensureContentsCached( FileRevisionTypedElement left, FileRevisionTypedElement right, IProgressMonitor monitor) { if (left != null) { try { left.cacheContents(monitor); } catch (CoreException e) { GitUIPlugin.logError(e); } } if (right != null) { try { right.cacheContents(monitor); } catch (CoreException e) { GitUIPlugin.logError(e); } } }
private String getContentIdentifier(ITypedElement element) { if (element instanceof FileRevisionTypedElement) { FileRevisionTypedElement fileRevisionElement = (FileRevisionTypedElement) element; Object fileObject = fileRevisionElement.getFileRevision(); if (fileObject instanceof LocalFileRevision) { try { IStorage storage = ((LocalFileRevision) fileObject).getStorage(new NullProgressMonitor()); if (Utils.getAdapter(storage, IFileState.class) != null) { // local revision return Messages.GitCompareFileRevisionEditorInput_0; } else if (Utils.getAdapter(storage, IFile.class) != null) { // current revision return Messages.GitCompareFileRevisionEditorInput_1; } } catch (CoreException e) { GitUIPlugin.logError( Messages.GitCompareFileRevisionEditorInput_ProblemGettingContent_Error, e); } } else { return fileRevisionElement.getContentIdentifier(); } } return Messages.GitCompareFileRevisionEditorInput_2; }