Skip to content

Commit

Permalink
Add Context Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sotasan committed May 28, 2022
1 parent 4b6fb73 commit 8bbbd92
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "net.pryoscode"
version = "0.3.6"
version = "0.3.7"

kotlin {
jvmToolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Code(val entry: Entry, private val code: String) : Tab() {
}
}

val menu = ContextMenu()
contextMenu = ContextMenu()
val close = MenuItem("Close")
val closeOthers = MenuItem("Close Others")
val closeAll = MenuItem("Close All")
Expand All @@ -88,8 +88,7 @@ class Code(val entry: Entry, private val code: String) : Tab() {
}
}
closeAll.setOnAction { Container.tabs.clear() }
menu.items.addAll(close, closeOthers, closeAll)
contextMenu = menu
contextMenu.items.addAll(close, closeOthers, closeAll)

Container.tabs.add(this)
Container.selectionModel.select(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import net.pryoscode.decompiler.window.menu.file.items.NewWindow
import net.pryoscode.decompiler.window.menu.file.items.OpenFile
import java.awt.event.KeyEvent
import javax.swing.JMenu
import javax.swing.JSeparator

class File : JMenu("File") {

init {
mnemonic = KeyEvent.VK_F
add(OpenFile())
add(CloseFile())
add(JSeparator())
add(NewWindow())
add(Exit())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.pryoscode.decompiler.window.sidebar

import javafx.scene.control.ContextMenu
import javafx.scene.control.MenuItem
import javafx.scene.control.TreeCell
import javafx.scene.image.ImageView
import javafx.scene.input.MouseButton
Expand All @@ -18,9 +20,16 @@ class Cell : TreeCell<Entry>() {
if (empty || item == null) {
text = ""
graphic = null
contextMenu = null
} else {
text = item.name
graphic = ImageView(item.type.icon)
if (item.type != Type.ARCHIVE && item.type != Type.PACKAGE && item.type != Type.FILE) {
contextMenu = ContextMenu()
val open = MenuItem("Open")
open.setOnAction { Container.open(item) }
contextMenu.items.add(open)
}
}
}

Expand Down

0 comments on commit 8bbbd92

Please sign in to comment.