Search in sources :

Example 1 with TransactionRunnable

use of com.intellij.openapi.vcs.TransactionRunnable 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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HgVcs(org.zmlx.hg4idea.HgVcs) AbstractVcsHelper(com.intellij.openapi.vcs.AbstractVcsHelper) VcsException(com.intellij.openapi.vcs.VcsException) TransactionRunnable(com.intellij.openapi.vcs.TransactionRunnable)

Aggregations

Project (com.intellij.openapi.project.Project)1 AbstractVcsHelper (com.intellij.openapi.vcs.AbstractVcsHelper)1 TransactionRunnable (com.intellij.openapi.vcs.TransactionRunnable)1 VcsException (com.intellij.openapi.vcs.VcsException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HgVcs (org.zmlx.hg4idea.HgVcs)1