Search in sources :

Example 1 with CvsFile

use of com.intellij.cvsSupport2.cvsBrowser.CvsFile in project intellij-community by JetBrains.

the class ChooseCheckoutMode method rebuildList.

private void rebuildList() {
    final File selected = myCvsPaths.iterator().next();
    setStepTitle(CvsBundle.message("dialog.title.check.out.to", selected));
    myCheckoutModeModel.removeAllElements();
    final boolean forFile = getWizard().getSelectedElements()[0] instanceof CvsFile;
    final CheckoutStrategy[] strategies = CheckoutStrategy.createAllStrategies(mySelectedLocation, selected, forFile);
    final Collection<File> results = new HashSet();
    final List<CheckoutStrategy> resultModes = new ArrayList();
    for (CheckoutStrategy strategy : strategies) {
        final File resultFile = strategy.getResult();
        if (resultFile != null && !results.contains(resultFile)) {
            results.add(resultFile);
            resultModes.add(strategy);
        }
    }
    Collections.sort(resultModes);
    for (CheckoutStrategy resultMode : resultModes) {
        myCheckoutModeModel.addElement(resultMode);
    }
    myCheckoutModeList.setSelectedIndex(0);
}
Also used : CheckoutStrategy(com.intellij.openapi.vcs.checkout.CheckoutStrategy) File(java.io.File) CvsFile(com.intellij.cvsSupport2.cvsBrowser.CvsFile) CvsFile(com.intellij.cvsSupport2.cvsBrowser.CvsFile) HashSet(com.intellij.util.containers.HashSet)

Example 2 with CvsFile

use of com.intellij.cvsSupport2.cvsBrowser.CvsFile 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 3 with CvsFile

use of com.intellij.cvsSupport2.cvsBrowser.CvsFile 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 CvsFile

use of com.intellij.cvsSupport2.cvsBrowser.CvsFile in project intellij-community by JetBrains.

the class CvsAnnotationProvider method annotate.

public FileAnnotation annotate(VirtualFile cvsVirtualFile, String revision, CvsEnvironment environment) throws VcsException {
    // the VirtualFile has a full path if annotate is called from history (when we have a real file on disk),
    // and has the path equal to a CVS module name if annotate is called from the CVS repository browser
    // (when there's no real path)
    boolean hasLocalFile = false;
    File cvsFile = new File(cvsVirtualFile.getPath());
    if (cvsFile.isAbsolute()) {
        hasLocalFile = true;
        cvsFile = new File(CvsUtil.getModuleName(cvsVirtualFile));
    }
    final boolean binary = annotateBinary(cvsVirtualFile, environment);
    final AnnotateOperation annotateOperation = executeOperation(cvsFile, revision, environment, binary, true);
    final Annotation[] lineAnnotations = annotateOperation.getLineAnnotations();
    final List<VcsFileRevision> revisions;
    if (hasLocalFile) {
        final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(cvsVirtualFile);
        revisions = myCvsHistoryProvider.createRevisions(filePath);
        // in annotation cvs returns only 8 symbols of username
        // try to find usernames in history and use them
        adjustAnnotation(revisions, lineAnnotations);
    } else {
        // imitation
        revisions = new ArrayList<>();
        final Set<String> usedRevisions = new HashSet<>();
        for (Annotation annotation : lineAnnotations) {
            if (!usedRevisions.contains(annotation.getRevision())) {
                revisions.add(new RevisionPresentation(annotation.getRevision(), annotation.getUserName(), annotation.getDate()));
                usedRevisions.add(annotation.getRevision());
            }
        }
    }
    return new CvsFileAnnotation(annotateOperation.getContent(), lineAnnotations, revisions, cvsVirtualFile, revision, myProject);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AnnotateOperation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 5 with CvsFile

use of com.intellij.cvsSupport2.cvsBrowser.CvsFile in project intellij-community by JetBrains.

the class ModuleChooser method getSelectedModules.

public CvsModule[] getSelectedModules() {
    CvsRepository repository = getSelectedRepository();
    CvsElement[] selectedCvsElement = mySelectCvsElementStep.getSelectedCvsElements();
    ArrayList<CvsModule> result = new ArrayList<>();
    for (CvsElement cvsElement : selectedCvsElement) {
        result.add(new CvsModule(repository, cvsElement.getElementPath(), cvsElement instanceof CvsFile));
    }
    return result.toArray(new CvsModule[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) CvsElement(com.intellij.cvsSupport2.cvsBrowser.CvsElement) CvsRepository(com.intellij.openapi.cvsIntegration.CvsRepository) CvsModule(com.intellij.openapi.cvsIntegration.CvsModule) CvsFile(com.intellij.cvsSupport2.cvsBrowser.CvsFile)

Aggregations

File (java.io.File)4 CvsFile (com.intellij.cvsSupport2.cvsBrowser.CvsFile)2 GetFileContentOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation)2 CvsRepository (com.intellij.openapi.cvsIntegration.CvsRepository)2 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)2 DateOrRevisionSettings (com.intellij.cvsSupport2.config.DateOrRevisionSettings)1 CvsElement (com.intellij.cvsSupport2.cvsBrowser.CvsElement)1 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)1 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)1 AnnotateOperation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation)1 Annotation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)1 RevisionOrDate (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate)1 SimpleRevision (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)1 ComparableVcsRevisionOnOperation (com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation)1 CvsModule (com.intellij.openapi.cvsIntegration.CvsModule)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 FilePath (com.intellij.openapi.vcs.FilePath)1 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)1 CheckoutStrategy (com.intellij.openapi.vcs.checkout.CheckoutStrategy)1 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)1