[git] IDEA-123859 Revert local changes from checkout/merge dialog

Add the RollbackAction to the dialog's toolbar;
make sure reverted changes disappear from the dialog after reverting.
This commit is contained in:
Kirill Likhodedov
2014-06-23 16:57:57 +04:00
parent 153988bd08
commit 9cc3f6bbfb
@@ -15,24 +15,32 @@
*/
package git4idea.branch;
import com.intellij.openapi.actionSystem.EmptyAction;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.actions.RollbackDialogAction;
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import git4idea.GitPlatformFacade;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import static com.intellij.openapi.util.text.StringUtil.capitalize;
import static com.intellij.openapi.vcs.changes.ui.ChangesBrowser.MyUseCase.LOCAL_CHANGES;
/**
* The dialog that is shown when the error
@@ -106,12 +114,31 @@ public class GitSmartOperationDialog extends DialogWrapper {
@Override
protected JComponent createCenterPanel() {
ChangesBrowser changesBrowser =
new ChangesBrowser(myProject, null, myChanges, null, false, true, null, ChangesBrowser.MyUseCase.LOCAL_CHANGES, null);
ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, myChanges, null, false, true, null, LOCAL_CHANGES, null) {
@Override
public void rebuildList() {
myChangesToDisplay = filterActualChanges();
super.rebuildList();
}
};
RollbackDialogAction rollback = new RollbackDialogAction();
EmptyAction.setupAction(rollback, IdeActions.CHANGES_VIEW_ROLLBACK, changesBrowser);
changesBrowser.addToolbarAction(rollback);
changesBrowser.setChangesToDisplay(myChanges);
return changesBrowser;
}
@NotNull
private List<Change> filterActualChanges() {
final Collection<Change> allChanges = ChangeListManager.getInstance(myProject).getAllChanges();
return ContainerUtil.filter(myChanges, new Condition<Change>() {
@Override
public boolean value(Change change) {
return allChanges.contains(change);
}
});
}
@Override
protected String getDimensionServiceKey() {
return GitSmartOperationDialog.class.getName();