Search in sources :

Example 1 with RollbackProgressModifier

use of com.intellij.openapi.vcs.changes.ui.RollbackProgressModifier in project intellij-community by JetBrains.

the class RollbackAction method rollbackModifiedWithoutEditing.

private static void rollbackModifiedWithoutEditing(final Project project, final LinkedHashSet<VirtualFile> modifiedWithoutEditing) {
    final String operationName = StringUtil.decapitalize(UIUtil.removeMnemonic(RollbackUtil.getRollbackOperationName(project)));
    String message = (modifiedWithoutEditing.size() == 1) ? VcsBundle.message("rollback.modified.without.editing.confirm.single", operationName, modifiedWithoutEditing.iterator().next().getPresentableUrl()) : VcsBundle.message("rollback.modified.without.editing.confirm.multiple", operationName, modifiedWithoutEditing.size());
    int rc = showYesNoDialog(project, message, VcsBundle.message("changes.action.rollback.title", operationName), getQuestionIcon());
    if (rc != Messages.YES) {
        return;
    }
    final List<VcsException> exceptions = new ArrayList<>();
    final ProgressManager progressManager = ProgressManager.getInstance();
    final Runnable action = new Runnable() {

        public void run() {
            final ProgressIndicator indicator = progressManager.getProgressIndicator();
            try {
                ChangesUtil.processVirtualFilesByVcs(project, modifiedWithoutEditing, (vcs, items) -> {
                    final RollbackEnvironment rollbackEnvironment = vcs.getRollbackEnvironment();
                    if (rollbackEnvironment != null) {
                        if (indicator != null) {
                            indicator.setText(vcs.getDisplayName() + ": performing " + UIUtil.removeMnemonic(rollbackEnvironment.getRollbackOperationName()).toLowerCase() + "...");
                            indicator.setIndeterminate(false);
                        }
                        rollbackEnvironment.rollbackModifiedWithoutCheckout(items, exceptions, new RollbackProgressModifier(items.size(), indicator));
                        if (indicator != null) {
                            indicator.setText2("");
                        }
                    }
                });
            } catch (ProcessCanceledException e) {
            // for files refresh  
            }
            if (!exceptions.isEmpty()) {
                AbstractVcsHelper.getInstance(project).showErrors(exceptions, VcsBundle.message("rollback.modified.without.checkout.error.tab", operationName));
            }
            VfsUtil.markDirty(true, false, VfsUtilCore.toVirtualFileArray(modifiedWithoutEditing));
            VirtualFileManager.getInstance().asyncRefresh(new Runnable() {

                public void run() {
                    for (VirtualFile virtualFile : modifiedWithoutEditing) {
                        VcsDirtyScopeManager.getInstance(project).fileDirty(virtualFile);
                    }
                }
            });
        }
    };
    progressManager.runProcessWithProgressSynchronously(action, operationName, true, project);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RollbackProgressModifier(com.intellij.openapi.vcs.changes.ui.RollbackProgressModifier) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) RollbackEnvironment(com.intellij.openapi.vcs.rollback.RollbackEnvironment) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 2 with RollbackProgressModifier

use of com.intellij.openapi.vcs.changes.ui.RollbackProgressModifier in project intellij-community by JetBrains.

the class RollbackDeletionAction method processFiles.

protected List<VcsException> processFiles(final AbstractVcs vcs, final List<FilePath> files) {
    RollbackEnvironment environment = vcs.getRollbackEnvironment();
    if (environment == null)
        return Collections.emptyList();
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null) {
        indicator.setText(vcs.getDisplayName() + ": performing rollback...");
    }
    final List<VcsException> result = new ArrayList<>(0);
    try {
        environment.rollbackMissingFileDeletion(files, result, new RollbackProgressModifier(files.size(), indicator));
    } catch (ProcessCanceledException e) {
    // for files refresh
    }
    LocalFileSystem.getInstance().refreshIoFiles(ChangesUtil.filePathsToFiles(files));
    return result;
}
Also used : RollbackProgressModifier(com.intellij.openapi.vcs.changes.ui.RollbackProgressModifier) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) ArrayList(java.util.ArrayList) RollbackEnvironment(com.intellij.openapi.vcs.rollback.RollbackEnvironment) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 RollbackProgressModifier (com.intellij.openapi.vcs.changes.ui.RollbackProgressModifier)2 RollbackEnvironment (com.intellij.openapi.vcs.rollback.RollbackEnvironment)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 VcsException (com.intellij.openapi.vcs.VcsException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1