fix: prevent some issues
This commit is contained in:
parent
ab513fb0e9
commit
9f1d36f2b1
@ -31,7 +31,7 @@ class DbusmenuImpl(windowId: Long, private val menuHolder: MenuHolder) : Dbusmen
|
||||
for (sm in it) {
|
||||
children.add(Variant(getLayout(parentId, recursionDepth, propertyNames, sm)))
|
||||
}
|
||||
if (it.isNotEmpty()) properties["children-display"] = Variant("submenu")
|
||||
properties["children-display"] = Variant("submenu")
|
||||
}
|
||||
|
||||
return GetLayoutStruct(menu.id, properties, children)
|
||||
|
@ -88,9 +88,10 @@ class SwingMenu(private val menuItem: JMenuItem?, private val holder: SwingMenuH
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
for (it in menuItem.actionListeners) it.actionPerformed(event)
|
||||
}
|
||||
menuItem.doClick()
|
||||
ApplicationManager.getApplication().invokeLater(menuItem::doClick)
|
||||
GlobalMenu.Log.warn("Event $event for menu $id (${menuItem.javaClass})")
|
||||
when (menuItem) {
|
||||
is ActionMenuItem -> {}
|
||||
is JCheckBoxMenuItem -> menuItem.isSelected = !menuItem.isSelected
|
||||
is JRadioButtonMenuItem -> menuItem.isSelected = true
|
||||
}
|
||||
@ -127,10 +128,12 @@ class SwingMenu(private val menuItem: JMenuItem?, private val holder: SwingMenuH
|
||||
}
|
||||
if (each !is JMenuItem) continue
|
||||
val cmi = SwingMenu(each, holder)
|
||||
if (deepness > 1 && each is ActionMenu) {
|
||||
each.removeAll()
|
||||
each.isSelected = true
|
||||
each.fillMenu()
|
||||
if (deepness > 1) {
|
||||
if (each is ActionMenu) {
|
||||
each.removeAll()
|
||||
each.isSelected = true
|
||||
each.fillMenu()
|
||||
}
|
||||
cmi.syncChildren(deepness - 1)
|
||||
}
|
||||
ch.add(cmi)
|
||||
@ -142,6 +145,10 @@ class SwingMenu(private val menuItem: JMenuItem?, private val holder: SwingMenuH
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "SwingMenu(id=$id, menuItem=$menuItem)"
|
||||
}
|
||||
|
||||
companion object {
|
||||
val keyEvents: Map<Int, String> = KeyEvent::class.java.fields
|
||||
.filter { it.modifiers == Modifier.PUBLIC or Modifier.STATIC or Modifier.FINAL && it.name.startsWith("VK_") }
|
||||
|
@ -1,6 +1,10 @@
|
||||
package io.gitlab.jfronny.globalmenu.proxy
|
||||
|
||||
import com.intellij.openapi.actionSystem.impl.ActionMenu
|
||||
import com.intellij.openapi.application.EDT
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import javax.swing.JMenuItem
|
||||
|
||||
class SwingRootMenu(private var menuItems: List<JMenuItem>?, private val name: String, private val holder: SwingMenuHolder): Menu {
|
||||
@ -20,7 +24,11 @@ class SwingRootMenu(private var menuItems: List<JMenuItem>?, private val name: S
|
||||
}
|
||||
|
||||
override fun update() {
|
||||
syncChildren()
|
||||
runBlocking {
|
||||
launch(Dispatchers.EDT) {
|
||||
syncChildren()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun update(items: List<ActionMenu>) {
|
||||
@ -33,6 +41,6 @@ class SwingRootMenu(private var menuItems: List<JMenuItem>?, private val name: S
|
||||
}
|
||||
|
||||
private fun syncChildren() {
|
||||
_children = menuItems?.map { SwingMenu(it, holder).apply { syncChildren(1) } }
|
||||
_children = menuItems?.map { SwingMenu(it, holder).apply { syncChildren(2) } }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user