[vcs] Fix Move Changes To Another List from rollback and diff dialogs

* Add text, description and icon back to the constructor, so that
MultipleChangeListBrowser#MoveAction (which extends
MoveChangesToAnotherListAction) could reuse the data.
* Use existing instance in the other place where moveAction is needed.
* Define ChangesView.Move action id in IdeActions,
since it is already referenced from too many places.
This commit is contained in:
Kirill Likhodedov
2013-04-23 16:21:27 +04:00
parent 44620c57ed
commit e22ab9fea1
6 changed files with 24 additions and 14 deletions
@@ -260,4 +260,5 @@ public interface IdeActions {
String CHANGES_VIEW_ROLLBACK = "ChangesView.Rollback";
String CONSOLE_CLEAR_ALL = "ConsoleView.ClearAll";
String MOVE_TO_ANOTHER_CHANGE_LIST = "ChangesView.Move";
}
@@ -113,7 +113,7 @@ public class VcsQuickListPopupAction extends QuickSwitchSchemeAction implements
// additional stuff
addSeparator(group);
addAction("ChangesView.Move", group);
addAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, group);
// local history
addLocalHistoryActions(group);
@@ -247,7 +247,7 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
ActionManager.getInstance().getAction("ChangesView.Refresh").registerCustomShortcutSet(CommonShortcuts.getRerun(), panel);
ActionManager.getInstance().getAction("ChangesView.NewChangeList").registerCustomShortcutSet(CommonShortcuts.getNew(), panel);
ActionManager.getInstance().getAction("ChangesView.RemoveChangeList").registerCustomShortcutSet(CommonShortcuts.DELETE, panel);
ActionManager.getInstance().getAction("ChangesView.Move").registerCustomShortcutSet(CommonShortcuts.getMove(), panel);
ActionManager.getInstance().getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST).registerCustomShortcutSet(CommonShortcuts.getMove(), panel);
ActionManager.getInstance().getAction("ChangesView.Rename").registerCustomShortcutSet(CommonShortcuts.getRename(), panel);
ActionManager.getInstance().getAction("ChangesView.SetDefault").registerCustomShortcutSet(
new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.ALT_DOWN_MASK | ctrlMask())), panel);
@@ -120,7 +120,7 @@ public class UnversionedViewDialog extends DialogWrapper {
actions.add(new ToggleShowFlattenAction());
AnAction addAction = ActionManager.getInstance().getAction("ChangesView.AddUnversioned.From.Dialog");
AnAction moveAction = ActionManager.getInstance().getAction("ChangesView.Move");
AnAction moveAction = ActionManager.getInstance().getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST);
AnAction deleteAction = ActionManager.getInstance().getAction("ChangesView.DeleteUnversioned.From.Dialog");
AnAction ignoreAction = ActionManager.getInstance().getAction("ChangesView.Ignore");
@@ -15,11 +15,9 @@
*/
package com.intellij.openapi.vcs.changes.actions;
import com.intellij.icons.AllIcons;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
@@ -42,6 +40,12 @@ import java.util.*;
*/
public class MoveChangesToAnotherListAction extends AnAction implements DumbAware {
public MoveChangesToAnotherListAction() {
super(ActionsBundle.actionText(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST),
ActionsBundle.actionDescription(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST),
AllIcons.Actions.MoveToAnotherChangelist);
}
public void update(AnActionEvent e) {
final boolean isEnabled = isEnabled(e);
if (ActionPlaces.isPopupPlace(e.getPlace())) {
@@ -51,7 +55,7 @@ public class MoveChangesToAnotherListAction extends AnAction implements DumbAwar
e.getPresentation().setEnabled(isEnabled);
}
}
private static boolean isEnabled(final AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
if (project == null) return false;
@@ -76,7 +80,7 @@ public class MoveChangesToAnotherListAction extends AnAction implements DumbAwar
if (ProjectLevelVcsManager.getInstance(project).getAllActiveVcss().length == 0) {
return null;
}
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
VirtualFile[] virtualFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
if (virtualFiles != null) {
@@ -24,6 +24,7 @@ package com.intellij.openapi.vcs.changes.ui;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.AnActionListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
@@ -205,12 +206,16 @@ public class MultipleChangeListBrowser extends ChangesBrowser {
protected void buildToolBar(final DefaultActionGroup toolBarGroup) {
super.buildToolBar(toolBarGroup);
final MoveChangesToAnotherListAction moveAction = new MoveChangesToAnotherListAction() {
public void actionPerformed(AnActionEvent e) {
super.actionPerformed(e);
rebuildList();
ActionManager actionManager = ActionManager.getInstance();
final AnAction moveAction = actionManager.getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST);
actionManager.addAnActionListener(new AnActionListener.Adapter() {
@Override
public void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
if (moveAction.equals(action)) {
rebuildList();
}
}
};
});
moveAction.registerCustomShortcutSet(CommonShortcuts.getMove(), myViewer);
toolBarGroup.add(moveAction);