Skip to content

Commit

Permalink
fix NonEmptyActionGroup.actionUpdateThread
Browse files Browse the repository at this point in the history
GitOrigin-RevId: b9afaea7b74e1da4f0c724bc36bb3c905ed1de80
  • Loading branch information
gregsh authored and intellij-monorepo-bot committed Mar 23, 2024
1 parent ff57a08 commit 411f72a
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ class TemplateManager private constructor() {
// Create the menu group item
val categoryGroup: NonEmptyActionGroup = object : NonEmptyActionGroup() {
override fun update(e: AnActionEvent) {
updateAction(e, category.name, childrenCount > 0, false)
super.update(e)
updateAction(e, category.name, e.presentation.isEnabled, false)
}

override fun getActionUpdateThread() = ActionUpdateThread.BGT
}
categoryGroup.isPopup = true
fillCategory(categoryGroup, category, am)
Expand Down Expand Up @@ -182,14 +181,14 @@ class TemplateManager private constructor() {
@JvmStatic
val instance = TemplateManager()

private fun updateAction(event: AnActionEvent, actionText: String?, visible: Boolean, disableIfNotReady: Boolean) {
private fun updateAction(event: AnActionEvent, actionText: String?, notEmpty: Boolean, disableIfNotReady: Boolean) {
val module = event.getData(PlatformCoreDataKeys.MODULE)
val facet = module?.androidFacet
val isProjectReady = facet != null && AndroidModel.get(facet) != null
event.presentation.apply {
text = actionText + (" (Project not ready)".takeUnless { isProjectReady } ?: "")
isVisible = visible && facet != null && AndroidModel.isRequired(facet)
isEnabled = !disableIfNotReady || isProjectReady
isVisible = notEmpty && facet != null && AndroidModel.isRequired(facet)
isEnabled = notEmpty && (!disableIfNotReady || isProjectReady)
}
}

Expand Down

0 comments on commit 411f72a

Please sign in to comment.