public void doRollback( final Collection<Change> changes, final boolean deleteLocallyAddedFiles, @Nullable final Runnable afterVcsRefreshInAwt, @Nullable final String localHistoryActionName) { final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final Runnable notifier = changeListManager.prepareForChangeDeletion(changes); final Runnable afterRefresh = new Runnable() { public void run() { changeListManager.invokeAfterUpdate( new Runnable() { public void run() { notifier.run(); if (afterVcsRefreshInAwt != null) { afterVcsRefreshInAwt.run(); } } }, InvokeAfterUpdateMode.SILENT, "Refresh change lists after update", ModalityState.current()); } }; final Runnable rollbackAction = new MyRollbackRunnable( changes, deleteLocallyAddedFiles, afterRefresh, localHistoryActionName); if (ApplicationManager.getApplication().isDispatchThread()) { ProgressManager.getInstance() .run( new Task.Backgroundable( myProject, VcsBundle.message("changes.action.rollback.text"), true, new PerformInBackgroundOption() { public boolean shouldStartInBackground() { return VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND; } public void processSentToBackground() { VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND = true; } }) { public void run(@NotNull ProgressIndicator indicator) { rollbackAction.run(); } }); } else { rollbackAction.run(); } ((ChangeListManagerImpl) changeListManager).showLocalChangesInvalidated(); }
private void doRun() { myIndicator = ProgressManager.getInstance().getProgressIndicator(); final List<Change> changesToRefresh = new ArrayList<Change>(); try { ChangesUtil.processChangesByVcs( myProject, myChanges, new ChangesUtil.PerVcsProcessor<Change>() { public void process(AbstractVcs vcs, List<Change> changes) { final RollbackEnvironment environment = vcs.getRollbackEnvironment(); if (environment != null) { changesToRefresh.addAll(changes); if (myIndicator != null) { myIndicator.setText(vcs.getDisplayName() + ": performing rollback..."); myIndicator.setIndeterminate(false); myIndicator.checkCanceled(); } environment.rollbackChanges( changes, myExceptions, new RollbackProgressModifier(changes.size(), myIndicator)); if (myIndicator != null) { myIndicator.setText2(""); myIndicator.checkCanceled(); } if (myExceptions.isEmpty() && myDeleteLocallyAddedFiles) { deleteAddedFilesLocally(changes); } } } }); } catch (ProcessCanceledException e) { // still do refresh } if (myIndicator != null) { myIndicator.startNonCancelableSection(); myIndicator.setIndeterminate(true); myIndicator.setText2(""); myIndicator.setText(VcsBundle.message("progress.text.synchronizing.files")); } doRefresh(myProject, changesToRefresh); AbstractVcsHelper.getInstance(myProject) .showErrors(myExceptions, VcsBundle.message("changes.action.rollback.text")); }