mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Show non-modal commit button as default button only if focus is in "Local Changes" (IDEA-215858)
GitOrigin-RevId: 6e7a30cfe05d7a4fb55620c23102a65d2781a864
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7a069d9127
commit
8a63d28003
@@ -199,12 +199,11 @@ public class ChangesViewManager implements ChangesViewI, ProjectComponent, Persi
|
||||
public void updateCommitWorkflow(boolean isNonModal) {
|
||||
if (isNonModal) {
|
||||
if (myCommitPanel == null) {
|
||||
myCommitPanel = new ChangesViewCommitPanel(myView);
|
||||
myCommitPanel = new ChangesViewCommitPanel(myView, myToolWindowPanel);
|
||||
myCommitWorkflowHandler = new ChangesViewCommitWorkflowHandler(new ChangesViewCommitWorkflow(myProject), myCommitPanel);
|
||||
Disposer.register(myContent, myCommitPanel);
|
||||
|
||||
myCommitPanelSplitter.setSecondComponent(myCommitPanel);
|
||||
myCommitPanel.setupShortcuts(myToolWindowPanel);
|
||||
}
|
||||
}
|
||||
else if (myCommitPanel != null) {
|
||||
|
||||
@@ -70,7 +70,9 @@ private fun JBPopup.showAbove(component: JComponent) {
|
||||
show(northWest)
|
||||
}
|
||||
|
||||
class ChangesViewCommitPanel(private val changesView: ChangesListView) : BorderLayoutPanel(), ChangesViewCommitWorkflowUi, ComponentContainer, DataProvider {
|
||||
class ChangesViewCommitPanel(private val changesView: ChangesListView, private val rootComponent: JComponent) :
|
||||
BorderLayoutPanel(), ChangesViewCommitWorkflowUi, ComponentContainer, DataProvider {
|
||||
|
||||
private val project get() = changesView.project
|
||||
|
||||
private val dataProviders = mutableListOf<DataProvider>()
|
||||
@@ -91,13 +93,15 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView) : BorderL
|
||||
override fun actionPerformed(e: ActionEvent) = fireDefaultExecutorCalled()
|
||||
}
|
||||
private val commitButton = object : JBOptionButton(defaultCommitAction, emptyArray()) {
|
||||
private val focusManager = IdeFocusManager.getInstance(project)
|
||||
|
||||
init {
|
||||
background = BACKGROUND_COLOR
|
||||
optionTooltipText = getDefaultTooltip()
|
||||
isOkToProcessDefaultMnemonics = false
|
||||
}
|
||||
|
||||
override fun isDefaultButton() = true
|
||||
override fun isDefaultButton(): Boolean = focusManager.getFocusedDescendantFor(rootComponent) != null
|
||||
}
|
||||
private val commitLegendCalculator = ChangeInfoCalculator()
|
||||
private val commitLegend = CommitLegendPanel(commitLegendCalculator)
|
||||
@@ -116,6 +120,8 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView) : BorderL
|
||||
addInclusionListener(object : InclusionListener {
|
||||
override fun inclusionChanged() = this@ChangesViewCommitPanel.inclusionChanged()
|
||||
}, this)
|
||||
|
||||
setupShortcuts(rootComponent)
|
||||
}
|
||||
|
||||
private fun buildLayout() {
|
||||
@@ -143,7 +149,7 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView) : BorderL
|
||||
|
||||
private fun fireDefaultExecutorCalled() = executorEventDispatcher.multicaster.executorCalled(null)
|
||||
|
||||
fun setupShortcuts(component: JComponent) {
|
||||
private fun setupShortcuts(component: JComponent) {
|
||||
DefaultCommitAction().registerCustomShortcutSet(DEFAULT_COMMIT_ACTION_SHORTCUT, component, this)
|
||||
DumbAwareAction.create {
|
||||
if (commitButton.isEnabled) commitButton.showPopup()
|
||||
|
||||
Reference in New Issue
Block a user