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")); }
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 doRefresh(final Project project, final List<Change> changesToRefresh) { final String actionName = VcsBundle.message("changes.action.rollback.text"); final LocalHistoryAction action = LocalHistory.getInstance().startAction(actionName); final Runnable forAwtThread = new Runnable() { public void run() { action.finish(); LocalHistory.getInstance() .putSystemLabel( myProject, (myLocalHistoryActionName == null) ? actionName : myLocalHistoryActionName, -1); final VcsDirtyScopeManager manager = PeriodicalTasksCloser.getInstance() .safeGetComponent(project, VcsDirtyScopeManager.class); for (Change change : changesToRefresh) { final ContentRevision beforeRevision = change.getBeforeRevision(); final ContentRevision afterRevision = change.getAfterRevision(); if ((!change.isIsReplaced()) && beforeRevision != null && Comparing.equal(beforeRevision, afterRevision)) { manager.fileDirty(beforeRevision.getFile()); } else { if (beforeRevision != null) { final FilePath parent = beforeRevision.getFile().getParentPath(); if (parent != null) { manager.dirDirtyRecursively(parent); } } if (afterRevision != null) { final FilePath parent = afterRevision.getFile().getParentPath(); if (parent != null) { manager.dirDirtyRecursively(parent); } } } } myAfterRefresh.run(); } }; RefreshVFsSynchronously.updateChangesForRollback(changesToRefresh); WaitForProgressToShow.runOrInvokeLaterAboveProgress(forAwtThread, null, project); }