Search in sources :

Example 6 with VcsVirtualFile

use of com.intellij.openapi.vcs.vfs.VcsVirtualFile in project intellij-community by JetBrains.

the class AnnotateVcsVirtualFileAction method extractData.

@Nullable
private static AnnotationData extractData(@NotNull Project project, @NotNull VirtualFile file) {
    FilePath filePath = null;
    VcsRevisionNumber revisionNumber = null;
    if (file instanceof VcsVirtualFile) {
        filePath = VcsUtil.getFilePath(file.getPath());
        VcsFileRevision revision = ((VcsVirtualFile) file).getFileRevision();
        revisionNumber = revision != null ? revision.getRevisionNumber() : null;
    } else if (file instanceof ContentRevisionVirtualFile) {
        ContentRevision revision = ((ContentRevisionVirtualFile) file).getContentRevision();
        filePath = revision.getFile();
        revisionNumber = revision.getRevisionNumber();
    }
    if (filePath == null || revisionNumber == null)
        return null;
    AbstractVcs vcs = VcsUtil.getVcsFor(project, filePath);
    return vcs != null ? new AnnotationData(vcs, filePath, revisionNumber) : null;
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) ContentRevisionVirtualFile(com.intellij.openapi.vcs.vfs.ContentRevisionVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with VcsVirtualFile

use of com.intellij.openapi.vcs.vfs.VcsVirtualFile in project intellij-community by JetBrains.

the class HgUtil method convertToLocalVirtualFile.

/**
   * Convert {@link VcsVirtualFile} to the {@link LocalFileSystem local} Virtual File.
   *
   * TODO
   * It is a workaround for the following problem: VcsVirtualFiles returned from the {@link FileHistoryPanelImpl} contain the current path
   * of the file, not the path that was in certain revision. This has to be fixed by making {@link HgFileRevision} implement
   * {@link VcsFileRevisionEx}.
   */
@Nullable
public static VirtualFile convertToLocalVirtualFile(@Nullable VirtualFile file) {
    if (!(file instanceof AbstractVcsVirtualFile)) {
        return file;
    }
    LocalFileSystem lfs = LocalFileSystem.getInstance();
    VirtualFile resultFile = lfs.findFileByPath(file.getPath());
    if (resultFile == null) {
        resultFile = lfs.refreshAndFindFileByPath(file.getPath());
    }
    return resultFile;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with VcsVirtualFile

use of com.intellij.openapi.vcs.vfs.VcsVirtualFile in project intellij-community by JetBrains.

the class RepositoryBrowserComponent method getSelectedVcsFile.

@Nullable
public VirtualFile getSelectedVcsFile() {
    final RepositoryTreeNode node = getSelectedNode();
    if (node == null)
        return null;
    DirectoryEntry entry = node.getSVNDirEntry();
    if (entry == null || !entry.isFile()) {
        return null;
    }
    String name = entry.getName();
    FileTypeManager manager = FileTypeManager.getInstance();
    if (entry.getName().lastIndexOf('.') > 0 && !manager.getFileTypeByFileName(name).isBinary()) {
        SVNURL url = node.getURL();
        final SvnFileRevision revision = new SvnFileRevision(myVCS, SVNRevision.UNDEFINED, SVNRevision.HEAD, url.toString(), entry.getAuthor(), entry.getDate(), null, null);
        return new VcsVirtualFile(node.getSVNDirEntry().getName(), revision, VcsFileSystem.getInstance());
    } else {
        return null;
    }
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) SVNURL(org.tmatesoft.svn.core.SVNURL) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)8 Nullable (org.jetbrains.annotations.Nullable)4 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 DateOrRevisionSettings (com.intellij.cvsSupport2.config.DateOrRevisionSettings)1 GetFileContentOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation)1 RevisionOrDate (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate)1 ComparableVcsRevisionOnOperation (com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation)1 CvsRepository (com.intellij.openapi.cvsIntegration.CvsRepository)1 Editor (com.intellij.openapi.editor.Editor)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 FileType (com.intellij.openapi.fileTypes.FileType)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 PlainTextFileType (com.intellij.openapi.fileTypes.PlainTextFileType)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 BackgroundableProcessIndicator (com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)1 CoreProgressManager (com.intellij.openapi.progress.impl.CoreProgressManager)1 FilePath (com.intellij.openapi.vcs.FilePath)1