vcs: non-modal: Move "Amend" checkbox and commit toolbar actions above commit message...
authorKonstantin Kolosovsky <konstantin.kolosovsky@jetbrains.com>
Sun, 13 Sep 2020 16:34:11 +0000 (19:34 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Tue, 22 Sep 2020 20:16:38 +0000 (20:16 +0000)
GitOrigin-RevId: 77d493e299c3099f21337a3f19b6be110ae29f49

platform/vcs-impl/resources/META-INF/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt
platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt
platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitStatusPanel.kt

index ed1537a26b5dfbdefa725a5694194dee517ec278..9006ed9695247a5a2a00c4a126e42a7836c2cd4b 100644 (file)
     <group id="Vcs.CommitExecutor.Actions"/>
 
     <group id="ChangesView.CommitToolbar">
-      <action id="ChangesView.ShowCommitOptions"
-              class="com.intellij.openapi.vcs.actions.ShowCommitOptionsAction"/>
+      <action id="Vcs.ToggleAmendCommitMode" class="com.intellij.vcs.commit.ToggleAmendCommitModeAction"/>
+      <action id="ChangesView.ShowCommitOptions" class="com.intellij.openapi.vcs.actions.ShowCommitOptionsAction"/>
       <reference id="Vcs.MessageActionGroup"/>
     </group>
-    <action id="Vcs.ToggleAmendCommitMode" class="com.intellij.vcs.commit.ToggleAmendCommitModeAction"/>
 
     <action class="com.intellij.openapi.vcs.actions.VcsToolbarLabelAction" id="VcsToolbarLabelAction"/>
 
index af99f266ca5779d1f0e4b3d34d502f4bde2ee7f6..ad47cb95c6e048cb660abb54f57481ea66c51117 100644 (file)
@@ -12,7 +12,7 @@ class ShowCommitOptionsAction : AnAction() {
   }
 
   override fun update(e: AnActionEvent) {
-    e.presentation.isEnabled = e.getProjectCommitWorkflowHandler()?.isActive == true
+    e.presentation.isEnabledAndVisible = e.getProjectCommitWorkflowHandler()?.isActive == true
   }
 
   override fun actionPerformed(e: AnActionEvent) {
index 91070d01bb7ee403d17b570760a1902240c30987..8bf7b55689d1348abec86c9525b14fd164c87da6 100644 (file)
@@ -36,8 +36,6 @@ import com.intellij.ui.awt.RelativePoint
 import com.intellij.ui.components.JBOptionButton
 import com.intellij.ui.components.JBOptionButton.Companion.getDefaultShowPopupShortcut
 import com.intellij.ui.components.JBPanel
-import com.intellij.ui.components.panels.HorizontalLayout
-import com.intellij.ui.components.panels.NonOpaquePanel
 import com.intellij.ui.components.panels.VerticalLayout
 import com.intellij.util.EventDispatcher
 import com.intellij.util.IJSwingUtilities.updateComponentTreeUI
@@ -108,24 +106,15 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel, priv
 
   private val centerPanel = simplePanel()
   private val buttonPanel = simplePanel().apply { isOpaque = false }
-  private val toolbarPanel = simplePanel().apply { isOpaque = false }
-  private var verticalToolbarBorder: Border? = null
+  private val toolbarPanel = simplePanel().apply {
+    isOpaque = false
+    border = emptyLeft(1)
+  }
   private val actions = ActionManager.getInstance().getAction("ChangesView.CommitToolbar") as ActionGroup
   private val toolbar = ActionManager.getInstance().createActionToolbar(COMMIT_TOOLBAR_PLACE, actions, false).apply {
     setTargetComponent(this@ChangesViewCommitPanel)
     component.isOpaque = false
   }
-  private val commitActionToolbar =
-    ActionManager.getInstance().createActionToolbar(
-      ActionPlaces.UNKNOWN,
-      DefaultActionGroup(ActionManager.getInstance().getAction("Vcs.ToggleAmendCommitMode")),
-      true
-    ).apply {
-      setTargetComponent(this@ChangesViewCommitPanel)
-      setReservePlaceAutoPopupIcon(false)
-      component.isOpaque = false
-      component.border = emptyLeft(6)
-    }
 
   private val commitMessage = CommitMessage(project, false, false, true).apply {
     editorField.addSettingsProvider { it.setBorder(emptyLeft(6)) }
@@ -167,7 +156,8 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel, priv
       setInclusionListener { inclusionEventDispatcher.multicaster.inclusionChanged() }
       isShowCheckboxes = true
     }
-    changesViewHost.statusComponent = ChangesViewCommitStatusPanel(changesView, this)
+    changesViewHost.statusComponent =
+      ChangesViewCommitStatusPanel(changesView, this).apply { addToLeft(toolbarPanel) }
 
     setupShortcuts(rootComponent)
   }
@@ -177,10 +167,6 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel, priv
       border = getButtonPanelBorder()
 
       addToLeft(commitButton)
-      addToRight(NonOpaquePanel(HorizontalLayout(0)).apply {
-        add(commitActionToolbar.component)
-        add(toolbarPanel)
-      })
     }
     centerPanel
       .addToCenter(commitMessage)
@@ -200,8 +186,6 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel, priv
     if (isHorizontal) {
       toolbar.setOrientation(SwingConstants.HORIZONTAL)
       toolbar.setReservePlaceAutoPopupIcon(false)
-      verticalToolbarBorder = toolbar.component.border
-      toolbar.component.border = null
 
       centerPanel.border = null
       toolbarPanel.addToCenter(toolbar.component)
@@ -209,7 +193,6 @@ class ChangesViewCommitPanel(private val changesViewHost: ChangesViewPanel, priv
     else {
       toolbar.setOrientation(SwingConstants.VERTICAL)
       toolbar.setReservePlaceAutoPopupIcon(true)
-      verticalToolbarBorder?.let { toolbar.component.border = it }
 
       centerPanel.border = createBorder(JBColor.border(), SideBorder.LEFT)
       addToLeft(toolbar.component)
index feba126abe72d2799984bb572a279fbb39be2de2..b3b529078aa470d12eb83ca2c36017e6942dfd75 100644 (file)
@@ -12,10 +12,9 @@ import com.intellij.openapi.vcs.changes.ui.*
 import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.Companion.LOCAL_CHANGES
 import com.intellij.ui.content.Content
 import com.intellij.util.ui.JBUI.Borders.empty
+import com.intellij.util.ui.JBUI.Borders.emptyRight
 import com.intellij.util.ui.JBUI.emptyInsets
-import com.intellij.util.ui.JBUI.emptySize
 import com.intellij.util.ui.components.BorderLayoutPanel
-import java.awt.Dimension
 
 private val isCompactCommitLegend get() = Registry.get("vcs.non.modal.commit.legend.compact")
 
@@ -39,7 +38,7 @@ internal class ChangesViewCommitStatusPanel(tree: ChangesTree, private val commi
     setupLegend()
 
     addToRight(commitLegend.component)
-    border = empty(6)
+    border = emptyRight(6)
     background = tree.background
 
     commitWorkflowUi.addInclusionListener(this, commitWorkflowUi)
@@ -69,8 +68,6 @@ internal class ChangesViewCommitStatusPanel(tree: ChangesTree, private val commi
     tab.description = branchComponent.toolTipText
   }
 
-  override fun getPreferredSize(): Dimension? = if (commitLegend.component.isVisible) super.getPreferredSize() else emptySize()
-
   override fun inclusionChanged() = updateLegend()
 
   private fun setupLegend() {