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);
}
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();
}
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);
}
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);
}
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()]);
}
Aggregations