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) {
|
for (sm in it) {
|
||||||
children.add(Variant(getLayout(parentId, recursionDepth, propertyNames, sm)))
|
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)
|
return GetLayoutStruct(menu.id, properties, children)
|
||||||
|
@ -88,9 +88,10 @@ class SwingMenu(private val menuItem: JMenuItem?, private val holder: SwingMenuH
|
|||||||
ApplicationManager.getApplication().invokeLater {
|
ApplicationManager.getApplication().invokeLater {
|
||||||
for (it in menuItem.actionListeners) it.actionPerformed(event)
|
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})")
|
GlobalMenu.Log.warn("Event $event for menu $id (${menuItem.javaClass})")
|
||||||
when (menuItem) {
|
when (menuItem) {
|
||||||
|
is ActionMenuItem -> {}
|
||||||
is JCheckBoxMenuItem -> menuItem.isSelected = !menuItem.isSelected
|
is JCheckBoxMenuItem -> menuItem.isSelected = !menuItem.isSelected
|
||||||
is JRadioButtonMenuItem -> menuItem.isSelected = true
|
is JRadioButtonMenuItem -> menuItem.isSelected = true
|
||||||
}
|
}
|
||||||
@ -127,10 +128,12 @@ class SwingMenu(private val menuItem: JMenuItem?, private val holder: SwingMenuH
|
|||||||
}
|
}
|
||||||
if (each !is JMenuItem) continue
|
if (each !is JMenuItem) continue
|
||||||
val cmi = SwingMenu(each, holder)
|
val cmi = SwingMenu(each, holder)
|
||||||
if (deepness > 1 && each is ActionMenu) {
|
if (deepness > 1) {
|
||||||
each.removeAll()
|
if (each is ActionMenu) {
|
||||||
each.isSelected = true
|
each.removeAll()
|
||||||
each.fillMenu()
|
each.isSelected = true
|
||||||
|
each.fillMenu()
|
||||||
|
}
|
||||||
cmi.syncChildren(deepness - 1)
|
cmi.syncChildren(deepness - 1)
|
||||||
}
|
}
|
||||||
ch.add(cmi)
|
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 {
|
companion object {
|
||||||
val keyEvents: Map<Int, String> = KeyEvent::class.java.fields
|
val keyEvents: Map<Int, String> = KeyEvent::class.java.fields
|
||||||
.filter { it.modifiers == Modifier.PUBLIC or Modifier.STATIC or Modifier.FINAL && it.name.startsWith("VK_") }
|
.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
|
package io.gitlab.jfronny.globalmenu.proxy
|
||||||
|
|
||||||
import com.intellij.openapi.actionSystem.impl.ActionMenu
|
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
|
import javax.swing.JMenuItem
|
||||||
|
|
||||||
class SwingRootMenu(private var menuItems: List<JMenuItem>?, private val name: String, private val holder: SwingMenuHolder): Menu {
|
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() {
|
override fun update() {
|
||||||
syncChildren()
|
runBlocking {
|
||||||
|
launch(Dispatchers.EDT) {
|
||||||
|
syncChildren()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(items: List<ActionMenu>) {
|
fun update(items: List<ActionMenu>) {
|
||||||
@ -33,6 +41,6 @@ class SwingRootMenu(private var menuItems: List<JMenuItem>?, private val name: S
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun syncChildren() {
|
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