use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.
the class BasicAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (isEmpty(files))
return;
SvnVcs vcs = SvnVcs.getInstance(project);
if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, files))
return;
project.save();
String actionName = getActionName();
LocalHistoryAction action = LocalHistory.getInstance().startAction(actionName);
AbstractVcsHelper helper = AbstractVcsHelper.getInstance(project);
try {
List<VcsException> exceptions = helper.runTransactionRunnable(vcs, exceptionList -> {
VirtualFile badFile = null;
try {
if (isBatchAction()) {
batchExecute(vcs, files, e.getDataContext());
} else {
for (VirtualFile file : files) {
badFile = file;
execute(vcs, file, e.getDataContext());
}
}
} catch (VcsException ex) {
ex.setVirtualFile(badFile);
exceptionList.add(ex);
}
}, null);
helper.showErrors(exceptions, actionName);
} finally {
action.finish();
}
}
use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.
the class ResolveWorker method execute.
// on EDT, dispose checked
public void execute(final UpdatedFiles updatedFiles) {
if (myConflictedVirtualFiles.isEmpty()) {
return;
}
final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(myProject);
List<VirtualFile> mergedFiles = vcsHelper.showMergeDialog(myConflictedVirtualFiles, new SvnMergeProvider(myProject));
final FileGroup mergedGroup = updatedFiles.getGroupById(FileGroup.MERGED_ID);
final FileGroup conflictedGroup = updatedFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID);
final VcsKey vcsKey = SvnVcs.getKey();
for (final VirtualFile mergedFile : mergedFiles) {
String path = FileUtil.toSystemDependentName(mergedFile.getPresentableUrl());
conflictedGroup.remove(path);
mergedGroup.add(path, vcsKey, null);
mergedFile.refresh(false, false);
// for additionally created files removal to be detected
mergedFile.getParent().refresh(false, false);
if (myChangesUnderProjectRoot) {
myDirtyScopeManager.fileDirty(mergedFile);
}
}
}
use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.
the class RemoveLocallyFileOrDirectoryAction method getCvsHandler.
private static CvsHandler getCvsHandler(final Project project, final Collection<File> filesToRemove, final boolean showDialog) {
final ArrayList<File> files = new ArrayList<>();
for (final File file : filesToRemove) {
if (CvsUtil.fileIsLocallyAdded(file)) {
CvsUtil.removeEntryFor(file);
} else {
files.add(file);
}
}
if (files.isEmpty())
return CvsHandler.NULL;
Collection<FilePath> filesToBeRemoved = filesToFilePaths(files);
if (showDialog) {
final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
filesToBeRemoved = vcsHelper.selectFilePathsToProcess(filesToFilePaths(files), CvsBundle.message("dialog.title.delete.files.from.cvs"), null, CvsBundle.message("dialog.title.delete.file.from.cvs"), CvsBundle.message("confirmation.text.delete.file.from.cvs"), VcsShowConfirmationOption.STATIC_SHOW_CONFIRMATION, CvsBundle.message("button.text.delete.from.cvs"), CommonBundle.getCancelButtonText());
if (filesToBeRemoved == null || filesToBeRemoved.isEmpty())
return CvsHandler.NULL;
}
return CommandCvsHandler.createRemoveFilesHandler(project, ChangesUtil.filePathsToFiles(filesToBeRemoved));
}
use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.
the class HgAbstractFilesAction method actionPerformed.
public final void actionPerformed(AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
if (project == null || files == null || files.length == 0) {
return;
}
project.save();
final HgVcs vcs = HgVcs.getInstance(project);
if ((vcs == null) || !ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, files)) {
return;
}
final AbstractVcsHelper helper = AbstractVcsHelper.getInstance(project);
List<VcsException> exceptions = helper.runTransactionRunnable(vcs, new TransactionRunnable() {
public void run(List<VcsException> exceptions) {
try {
execute(project, vcs, files, dataContext);
} catch (VcsException ex) {
exceptions.add(ex);
}
}
}, null);
helper.showErrors(exceptions, vcs.getName());
}
Aggregations