vcs: non-modal: Make "Switch to Commit Dialog" action available in search everywhere
authorKonstantin Kolosovsky <konstantin.kolosovsky@jetbrains.com>
Tue, 8 Dec 2020 11:19:58 +0000 (14:19 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sun, 13 Dec 2020 16:56:27 +0000 (16:56 +0000)
GitOrigin-RevId: c2a465080aac7d4c3b22e98c9da70adc5fbe324b

platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties
platform/vcs-impl/resources/META-INF/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewToolWindowFactory.kt
platform/vcs-impl/src/com/intellij/vcs/commit/SwitchToCommitDialogAction.kt [new file with mode: 0644]

index 609c6206dc594ea76564e62842b84ce5e355bdad..935ab2fbc239b0b52ff610ffb6ed45b82052c437 100644 (file)
@@ -1437,6 +1437,7 @@ group.Shelve.KeymapGroup.text=Shelve
 action.Vcs.CopyRevisionNumberAction.text=Copy Revision Number
 action.Vcs.CopyRevisionNumberAction.description=Copy revision numbers of selected commits to the clipboard
 action.VcsToolbarLabelAction.text=VCS Label
+action.CommitView.SwitchToCommitDialog.text=Switch to Commit Dialog
 action.Vcs.ToggleAmendCommitMode.text=Amend Commit
 action.Vcs.ToggleAmendCommitMode.description=Modify the latest commit of the current branch
 action.ChangesView.ShowCommitOptions.text=Show Commit Options
index 4a46bfc7775d546dd023de736eead168da8fc03b..eeb462df99401ed4293bddbbb18a21a834ebd67f 100644 (file)
@@ -267,7 +267,6 @@ amend.commit.load.message.error.text=Couldn't load commit message of the commit
 checkbox.amend=A_mend
 label.by.author=By
 
-action.switch.to.commit.dialog.text=Switch to Commit Dialog
 non.modal.commit.promoter.text=New non-modal commit interface is available. Commit from a tool window and view diff in the editor.
 non.modal.commit.promoter.use.non.modal.action.text=Switch to tool window
 non.modal.commit.promoter.dont.show.again.action.text=Don't show again
index 6d693d3f1f74c955ead1912c33dfde909b44f195..563816341329d34e16bb4c2f2f141cde07ce7997 100644 (file)
       <add-to-group group-id="Diff.KeymapGroup" anchor="after" relative-to-action="CompareClipboardWithSelection"/>
     </group>
 
+    <group id="CommitView.GearActions">
+      <action id="CommitView.SwitchToCommitDialog" class="com.intellij.vcs.commit.SwitchToCommitDialogAction"/>
+
+      <add-to-group group-id="VcsGeneral.KeymapGroup"/>
+    </group>
+
     <group id="Vcs.Show.Toolwindow.Tab">
       <add-to-group group-id="VcsGeneral.KeymapGroup"/>
       <action id="Vcs.Show.Local.Changes" class="com.intellij.vcs.VcsShowLocalChangesAction"/>
index 828ca81f018ae58c3f23c2bd67a13986bbc44056..a02af8d99fe097964bdf2c1ff4fb0a0e2b0f92ce 100644 (file)
@@ -4,14 +4,10 @@ package com.intellij.openapi.vcs.changes.ui
 import com.intellij.icons.AllIcons
 import com.intellij.internal.statistic.collectors.fus.ui.GotItUsageCollector
 import com.intellij.internal.statistic.collectors.fus.ui.GotItUsageCollectorGroup
+import com.intellij.openapi.actionSystem.ActionGroup
 import com.intellij.openapi.actionSystem.ActionManager
 import com.intellij.openapi.actionSystem.ActionToolbar
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.DefaultActionGroup
-import com.intellij.openapi.actionSystem.IdeActions.ACTION_CHECKIN_PROJECT
-import com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction
 import com.intellij.openapi.actionSystem.impl.ActionButton
-import com.intellij.openapi.project.DumbAwareAction
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.ui.popup.Balloon
 import com.intellij.openapi.util.Disposer
@@ -28,7 +24,6 @@ import com.intellij.util.ui.PositionTracker
 import com.intellij.util.ui.UIUtil.uiTraverser
 import com.intellij.util.ui.update.Activatable
 import com.intellij.util.ui.update.UiNotifyConnector
-import com.intellij.vcs.commit.CommitWorkflowManager.Companion.setCommitFromLocalChanges
 import javax.swing.JComponent
 
 private class ChangesViewToolWindowFactory : VcsToolWindowFactory() {
@@ -43,7 +38,7 @@ private class CommitToolWindowFactory : VcsToolWindowFactory() {
     super.init(window)
 
     window as ToolWindowEx
-    window.setAdditionalGearActions(DefaultActionGroup(SwitchToCommitDialogAction()))
+    window.setAdditionalGearActions(ActionManager.getInstance().getAction("CommitView.GearActions") as ActionGroup)
   }
 
   override fun shouldBeAvailable(project: Project): Boolean {
@@ -56,19 +51,6 @@ private class CommitToolWindowFactory : VcsToolWindowFactory() {
   }
 }
 
-private class SwitchToCommitDialogAction : DumbAwareAction() {
-  init {
-    templatePresentation.text = message("action.switch.to.commit.dialog.text")
-  }
-
-  override fun actionPerformed(e: AnActionEvent) {
-    setCommitFromLocalChanges(false)
-
-    val commitAction = ActionManager.getInstance().getAction(ACTION_CHECKIN_PROJECT) ?: return
-    invokeAction(commitAction, e.dataContext, e.place, e.inputEvent, null)
-  }
-}
-
 internal class SwitchToCommitDialogHint(private val toolWindow: ToolWindowEx, private val toolbar: ActionToolbar) :
   ChangesViewContentManagerListener,
   Activatable {
diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/SwitchToCommitDialogAction.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/SwitchToCommitDialogAction.kt
new file mode 100644 (file)
index 0000000..a07c9d7
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package com.intellij.vcs.commit
+
+import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.IdeActions.ACTION_CHECKIN_PROJECT
+import com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction
+import com.intellij.openapi.project.DumbAwareAction
+import com.intellij.openapi.vcs.actions.isProjectUsesNonModalCommit
+import com.intellij.vcs.commit.CommitWorkflowManager.Companion.setCommitFromLocalChanges
+
+private class SwitchToCommitDialogAction : DumbAwareAction() {
+  override fun update(e: AnActionEvent) {
+    e.presentation.isEnabledAndVisible = e.isProjectUsesNonModalCommit()
+  }
+
+  override fun actionPerformed(e: AnActionEvent) {
+    setCommitFromLocalChanges(false)
+
+    val commitAction = ActionManager.getInstance().getAction(ACTION_CHECKIN_PROJECT) ?: return
+    invokeAction(commitAction, e.dataContext, e.place, e.inputEvent, null)
+  }
+}
\ No newline at end of file