Search in sources :

Example 1 with VcsVirtualFile

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

the class OpenOutputAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Editor editor = CommonDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext(myConsole.getComponent()));
    if (editor != null) {
        final byte[] content = editor.getDocument().getText().getBytes(CharsetToolkit.UTF8_CHARSET);
        // TODO: get from output type
        final String extension = "xml";
        final VcsVirtualFile file = new VcsVirtualFile("XSLT Output." + extension, content, null, VcsFileSystem.getInstance()) {

            @NotNull
            @Override
            public Charset getCharset() {
                return CharsetToolkit.UTF8_CHARSET;
            }
        };
        FileEditorManager.getInstance(e.getProject()).openFile(file, true);
    }
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) Editor(com.intellij.openapi.editor.Editor)

Example 2 with VcsVirtualFile

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

the class AnnotateRevisionAction method getFile.

@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
    VcsFileRevision revision = getFileRevision(e);
    if (revision == null)
        return null;
    final FileType currentFileType = myAnnotation.getFile().getFileType();
    FilePath filePath = (revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx) revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
    return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {

        @NotNull
        @Override
        public FileType getFileType() {
            FileType type = super.getFileType();
            if (!type.isBinary())
                return type;
            if (!currentFileType.isBinary())
                return currentFileType;
            return PlainTextFileType.INSTANCE;
        }
    };
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsFileRevisionEx(com.intellij.openapi.vcs.history.VcsFileRevisionEx) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) FileType(com.intellij.openapi.fileTypes.FileType) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with VcsVirtualFile

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

the class CvsServicesImpl method openInEditor.

public void openInEditor(Project project, CvsModule cvsFile) {
    CvsRepository repository = cvsFile.getRepository();
    RevisionOrDate revisionOrDate = RevisionOrDateImpl.createOn(new DateOrRevisionSettings().updateFrom(repository.getDateOrRevision()));
    GetFileContentOperation operation = new GetFileContentOperation(new File(cvsFile.getPathInCvs()), CvsRootConfiguration.createOn(repository), revisionOrDate);
    ComparableVcsRevisionOnOperation revision = new ComparableVcsRevisionOnOperation(operation, project);
    VcsVirtualFile vcsVirtualFile = new VcsVirtualFile(cvsFile.getPathInCvs(), revision, VcsFileSystem.getInstance());
    OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(project, vcsVirtualFile);
    FileEditorManager.getInstance(project).openTextEditor(openFileDescriptor, false);
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) DateOrRevisionSettings(com.intellij.cvsSupport2.config.DateOrRevisionSettings) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) CvsRepository(com.intellij.openapi.cvsIntegration.CvsRepository) ComparableVcsRevisionOnOperation(com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation) RevisionOrDate(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate) File(java.io.File) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile)

Example 4 with VcsVirtualFile

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

the class AbstractVcsHelperImpl method loadAndShowCommittedChangesDetails.

@Override
public void loadAndShowCommittedChangesDetails(@NotNull final Project project, @NotNull final VcsRevisionNumber revision, @NotNull final VirtualFile virtualFile, @NotNull VcsKey vcsKey, @Nullable final RepositoryLocation location, final boolean isNonLocal) {
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
    if (vcs == null)
        return;
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    if (provider == null)
        return;
    if (isNonLocal && provider.getForNonLocal(virtualFile) == null)
        return;
    final String title = VcsBundle.message("paths.affected.in.revision", revision instanceof ShortVcsRevisionNumber ? ((ShortVcsRevisionNumber) revision).toShortString() : revision.asString());
    final CommittedChangeList[] list = new CommittedChangeList[1];
    final FilePath[] targetPath = new FilePath[1];
    final VcsException[] exc = new VcsException[1];
    final BackgroundableActionLock lock = BackgroundableActionLock.getLock(project, VcsBackgroundableActions.COMMITTED_CHANGES_DETAILS, revision, virtualFile.getPath());
    if (lock.isLocked())
        return;
    lock.lock();
    Task.Backgroundable task = new Task.Backgroundable(project, title, true) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            try {
                if (!isNonLocal) {
                    final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
                    if (pair != null) {
                        list[0] = pair.getFirst();
                        targetPath[0] = pair.getSecond();
                    }
                } else {
                    if (location != null) {
                        final ChangeBrowserSettings settings = provider.createDefaultSettings();
                        settings.USE_CHANGE_BEFORE_FILTER = true;
                        settings.CHANGE_BEFORE = revision.asString();
                        final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
                        if (changes != null && changes.size() == 1) {
                            list[0] = changes.get(0);
                        }
                    } else {
                        list[0] = getRemoteList(vcs, revision, virtualFile);
                    }
                }
            } catch (VcsException e) {
                exc[0] = e;
            }
        }

        @Override
        public void onCancel() {
            lock.unlock();
        }

        @Override
        public void onSuccess() {
            lock.unlock();
            if (exc[0] != null) {
                showError(exc[0], failedText(virtualFile, revision));
            } else if (list[0] == null) {
                Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
            } else {
                VirtualFile navigateToFile = targetPath[0] != null ? new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) : virtualFile;
                showChangesListBrowser(list[0], navigateToFile, title);
            }
        }
    };
    // we can's use runProcessWithProgressAsynchronously(task) because then ModalityState.NON_MODAL would be used
    CoreProgressManager progressManager = (CoreProgressManager) ProgressManager.getInstance();
    progressManager.runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task), null, ModalityState.current());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) Task(com.intellij.openapi.progress.Task) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) NotNull(org.jetbrains.annotations.NotNull) ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)

Example 5 with VcsVirtualFile

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

the class GitAnnotationProvider method annotate.

@NotNull
@Override
public FileAnnotation annotate(@NotNull final FilePath path, @NotNull final VcsRevisionNumber revision) throws VcsException {
    GitFileRevision fileRevision = new GitFileRevision(myProject, path, (GitRevisionNumber) revision);
    VcsVirtualFile file = new VcsVirtualFile(path.getPath(), fileRevision, VcsFileSystem.getInstance());
    return annotate(path, revision, file);
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) GitFileRevision(git4idea.GitFileRevision) NotNull(org.jetbrains.annotations.NotNull)

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