From f4e7dd3a034d556d8f552d320102a7ce86fbf704 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Sun, 13 Sep 2020 19:34:11 +0300 Subject: [PATCH] vcs: non-modal: Move "Amend" checkbox and commit toolbar actions above commit message (IDEA-251226) GitOrigin-RevId: 77d493e299c3099f21337a3f19b6be110ae29f49 --- .../resources/META-INF/VcsActions.xml | 5 ++-- .../vcs/actions/ShowCommitOptionsAction.kt | 2 +- .../vcs/commit/ChangesViewCommitPanel.kt | 29 ++++--------------- .../commit/ChangesViewCommitStatusPanel.kt | 7 ++--- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/platform/vcs-impl/resources/META-INF/VcsActions.xml b/platform/vcs-impl/resources/META-INF/VcsActions.xml index ed1537a26b5d..9006ed969524 100644 --- a/platform/vcs-impl/resources/META-INF/VcsActions.xml +++ b/platform/vcs-impl/resources/META-INF/VcsActions.xml @@ -320,11 +320,10 @@ - + + - diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt index af99f266ca57..ad47cb95c6e0 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt @@ -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) { diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt index 91070d01bb7e..8bf7b55689d1 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt @@ -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) diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitStatusPanel.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitStatusPanel.kt index feba126abe72..b3b529078aa4 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitStatusPanel.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitStatusPanel.kt @@ -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() { -- 2.32.0