Search in sources :

Example 1 with GetFileContentOperation

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation in project intellij-community by JetBrains.

the class CvsServicesImpl method getFileContent.

public byte[] getFileContent(Project project, CvsModule cvsFile) throws IOException {
    final GetFileContentOperation operation = new GetFileContentOperation(new File(cvsFile.getPathInCvs()), CvsRootConfiguration.createOn(cvsFile.getRepository()), new SimpleRevision(cvsFile.getRevision()));
    final CvsOperationExecutor executor = new CvsOperationExecutor(project);
    executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), operation, false), CvsOperationExecutorCallback.EMPTY);
    if (!executor.hasNoErrors())
        throw new RuntimeException(executor.getFirstError());
    if (operation.isDeleted())
        throw new IOException(CvsBundle.message("exception.text.revision.has.been.deleted"));
    return operation.getFileBytes();
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) IOException(java.io.IOException) File(java.io.File) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Example 2 with GetFileContentOperation

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation 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 3 with GetFileContentOperation

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation in project intellij-community by JetBrains.

the class CvsContentRevision method getContentAsBytes.

@Nullable
@Override
public byte[] getContentAsBytes() throws VcsException {
    if (myContent == null) {
        final GetFileContentOperation operation = new GetFileContentOperation(myFile, myEnvironment, myRevision);
        CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
        executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file"), operation), CvsOperationExecutorCallback.EMPTY);
        CvsResult result = executor.getResult();
        if (result.isCanceled()) {
            throw new ProcessCanceledException();
        }
        if (result.hasErrors()) {
            throw result.composeError();
        }
        if (!operation.isLoaded()) {
            throw new VcsException("Network problem");
        }
        myContent = operation.getFileBytes();
    }
    return myContent;
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) VcsException(com.intellij.openapi.vcs.VcsException) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with GetFileContentOperation

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation in project intellij-community by JetBrains.

the class CvsServicesImpl method createCvsVersionOn.

private static ComparableVcsRevisionOnOperation createCvsVersionOn(CvsModule module, Project project) {
    final CvsRootConfiguration rootConfiguration = CvsApplicationLevelConfiguration.getInstance().getConfigurationForCvsRoot(module.getRepository().getStringRepresentation());
    CvsConnectionSettings env = new IDEARootFormatter(rootConfiguration).createConfiguration();
    GetFileContentOperation operation = new GetFileContentOperation(new File(module.getPathInCvs()), env, new SimpleRevision(module.getRevision()));
    return new ComparableVcsRevisionOnOperation(operation, project);
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings) ComparableVcsRevisionOnOperation(com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation) File(java.io.File) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CvsRootConfiguration(com.intellij.cvsSupport2.config.CvsRootConfiguration) IDEARootFormatter(com.intellij.cvsSupport2.connections.IDEARootFormatter) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Aggregations

GetFileContentOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation)4 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)3 File (java.io.File)3 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)2 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)2 SimpleRevision (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)2 ComparableVcsRevisionOnOperation (com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation)2 CvsRootConfiguration (com.intellij.cvsSupport2.config.CvsRootConfiguration)1 DateOrRevisionSettings (com.intellij.cvsSupport2.config.DateOrRevisionSettings)1 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)1 IDEARootFormatter (com.intellij.cvsSupport2.connections.IDEARootFormatter)1 RevisionOrDate (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate)1 CvsRepository (com.intellij.openapi.cvsIntegration.CvsRepository)1 CvsResult (com.intellij.openapi.cvsIntegration.CvsResult)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VcsException (com.intellij.openapi.vcs.VcsException)1 IOException (java.io.IOException)1 Nullable (org.jetbrains.annotations.Nullable)1