mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: non-modal: Disable commit-related actions if commit panel is hidden
GitOrigin-RevId: 471103bea9e07f52abe0e778d95ff8782faca444
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c2857a75a5
commit
a2397a44b7
@@ -14,7 +14,7 @@ class ShowCommitOptionsAction : AnAction() {
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabled = e.getProjectCommitWorkflowHandler() != null
|
||||
e.presentation.isEnabled = e.getProjectCommitWorkflowHandler()?.isActive == true
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
|
||||
@@ -69,7 +69,7 @@ abstract class AbstractCommitWorkflowHandler<W : AbstractCommitWorkflow, U : Com
|
||||
|
||||
fun getCommitActionName() = getDefaultCommitActionName(workflow.vcses)
|
||||
|
||||
protected fun createDataProvider() = DataProvider { dataId ->
|
||||
protected open fun createDataProvider() = DataProvider { dataId ->
|
||||
when {
|
||||
COMMIT_WORKFLOW_HANDLER.`is`(dataId) -> this
|
||||
Refreshable.PANEL_KEY.`is`(dataId) -> commitPanel
|
||||
|
||||
@@ -180,9 +180,7 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v
|
||||
|
||||
private fun setupShortcuts(component: JComponent) {
|
||||
DefaultCommitAction().registerCustomShortcutSet(DEFAULT_COMMIT_ACTION_SHORTCUT, component, this)
|
||||
DumbAwareAction.create {
|
||||
if (commitButton.isEnabled) commitButton.showPopup()
|
||||
}.registerCustomShortcutSet(getDefaultShowPopupShortcut(), component, this)
|
||||
ShowCustomCommitActions().registerCustomShortcutSet(getDefaultShowPopupShortcut(), component, this)
|
||||
}
|
||||
|
||||
override fun globalSchemeChange(scheme: EditorColorsScheme?) {
|
||||
@@ -325,9 +323,17 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v
|
||||
|
||||
inner class DefaultCommitAction : DumbAwareAction() {
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = defaultCommitAction.isEnabled
|
||||
e.presentation.isEnabledAndVisible = isActive && defaultCommitAction.isEnabled
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) = fireDefaultExecutorCalled()
|
||||
}
|
||||
|
||||
private inner class ShowCustomCommitActions : DumbAwareAction() {
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = isActive && commitButton.isEnabled
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) = commitButton.showPopup()
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,12 @@
|
||||
package com.intellij.vcs.commit
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.ActionGroup
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.VcsConfiguration
|
||||
import com.intellij.openapi.vcs.VcsDataKeys.COMMIT_WORKFLOW_HANDLER
|
||||
import com.intellij.openapi.vcs.VcsException
|
||||
import com.intellij.openapi.vcs.changes.*
|
||||
import com.intellij.openapi.vcs.changes.actions.DefaultCommitExecutorAction
|
||||
@@ -53,6 +51,14 @@ class ChangesViewCommitWorkflowHandler(
|
||||
vcsesChanged() // as currently vcses are set before handler subscribes to corresponding event
|
||||
}
|
||||
|
||||
override fun createDataProvider(): DataProvider = object : DataProvider {
|
||||
private val superProvider = super@ChangesViewCommitWorkflowHandler.createDataProvider()
|
||||
|
||||
override fun getData(dataId: String): Any? =
|
||||
if (COMMIT_WORKFLOW_HANDLER.`is`(dataId)) this@ChangesViewCommitWorkflowHandler.takeIf { it.isActive }
|
||||
else superProvider.getData(dataId)
|
||||
}
|
||||
|
||||
private fun ensureCommitOptions(): CommitOptions {
|
||||
if (!areCommitOptionsCreated) {
|
||||
areCommitOptionsCreated = true
|
||||
|
||||
Reference in New Issue
Block a user