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