From eac5448e1cb92932a85eecb8e0491b73d0a0b1dd Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 13 Feb 2018 22:34:27 +0300 Subject: [PATCH] IDEA-186651 diff: shortcut for "Move to Another Changelist" should not affect whole file * do not use same shortcut for "Move to Another Changelist" and "Move Lines to Another Changelist" --- .../src/messages/ActionsBundle.properties | 6 ++--- .../src/idea/VcsActions.xml | 6 ++--- .../lst/SimpleLocalChangeListDiffViewer.java | 22 +++++++++++++++---- .../vcs/ex/MoveChangesLineStatusAction.java | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index c99e2d994900..0a47569e220f 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1171,9 +1171,9 @@ action.Vcs.ShowDiffAction.text=Show Changes action.Vcs.ShowDiffAction.description=Show changes action.Vcs.RollbackChanges.text=Rollback Changes action.Vcs.RollbackChanges.description=Rollback changes -action.Vcs.MoveChangedLinesToChangelist.text=Move to Another Changelist... -action.Vcs.MoveChangedLinesToChangelist.description=Move selected changes to another changelist -action.Vcs.RollbackChangedLines.text=Rollback +action.Vcs.MoveChangedLinesToChangelist.text=Move Lines to Another Changelist... +action.Vcs.MoveChangedLinesToChangelist.description=Move changes in selected lines to another changelist +action.Vcs.RollbackChangedLines.text=Rollback Lines action.Vcs.RollbackChangedLines.description=Rollback changes in selected lines action.Vcs.EditSourceAction.text=Edit Source action.Vcs.EditSourceAction.description=Edit source diff --git a/platform/platform-resources/src/idea/VcsActions.xml b/platform/platform-resources/src/idea/VcsActions.xml index 0e2e1e4af162..3dccc7e1de7b 100644 --- a/platform/platform-resources/src/idea/VcsActions.xml +++ b/platform/platform-resources/src/idea/VcsActions.xml @@ -312,8 +312,7 @@ - + @@ -370,6 +369,8 @@ + + @@ -413,7 +414,6 @@ - diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java index 701ac2d7dbe5..e5606df0a016 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java @@ -12,6 +12,7 @@ import com.intellij.diff.util.Range; import com.intellij.diff.util.Side; import com.intellij.icons.AllIcons; import com.intellij.idea.ActionsBundle; +import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -36,7 +37,6 @@ import java.util.ArrayList; import java.util.BitSet; import java.util.List; -import static com.intellij.util.ObjectUtils.assertNotNull; import static com.intellij.util.ObjectUtils.notNull; public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { @@ -53,7 +53,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { myTracker.addListener(new MyTrackerListener(), this); - DiffUtil.registerAction(new MoveSelectedChangesToAnotherChangelistAction(), myPanel); + DiffUtil.registerAction(new MoveSelectedChangesToAnotherChangelistAction(true), myPanel); } @NotNull @@ -68,7 +68,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { protected List createEditorPopupActions() { List group = new ArrayList<>(super.createEditorPopupActions()); - group.add(new MoveSelectedChangesToAnotherChangelistAction()); + group.add(new MoveSelectedChangesToAnotherChangelistAction(false)); return group; } @@ -185,8 +185,20 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { } private class MoveSelectedChangesToAnotherChangelistAction extends DumbAwareAction { + private final boolean myShortcut; + + public MoveSelectedChangesToAnotherChangelistAction(boolean shortcut) { + myShortcut = shortcut; + copyShortcutFrom(ActionManager.getInstance().getAction("Vcs.MoveChangedLinesToChangelist")); + } + @Override public void update(@NotNull AnActionEvent e) { + if (myShortcut) { + e.getPresentation().setEnabledAndVisible(true); + return; + } + Editor editor = e.getData(CommonDataKeys.EDITOR); Side side = Side.fromValue(getEditors(), editor); if (side == null) { @@ -215,7 +227,9 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { @Override public void actionPerformed(@NotNull AnActionEvent e) { Editor editor = e.getData(CommonDataKeys.EDITOR); - Side side = assertNotNull(Side.fromValue(getEditors(), editor)); + Side side = Side.fromValue(getEditors(), editor); + if (editor == null || side == null) return; + List selectedChanges = getSelectedChanges(side); if (selectedChanges.isEmpty()) return; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java index e5643d574a6a..b4c18c6f123e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java @@ -97,7 +97,7 @@ public class MoveChangesLineStatusAction extends LineStatusActionBase { ChangeListChooser chooser = new ChangeListChooser(project, suggestedLists, defaultSelection, - ActionsBundle.message("action.ChangesView.Move.text"), + ActionsBundle.message("action.Vcs.MoveChangedLinesToChangelist.text"), null); chooser.show();