Skip to content

Commit

Permalink
Update flatlaf to v3.4.1 (#153)
Browse files Browse the repository at this point in the history
* Fix some UI bugs, use new split pane expandable side feature
  • Loading branch information
renovate[bot] authored Apr 5, 2024
1 parent 87fefab commit 9e47663
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 189 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
java = "21"
kotlin = "1.9.22"
coroutines = "1.8.0"
flatlaf = "3.4"
flatlaf = "3.4.1"
kotest = "5.8.1"
ignition = "8.1.20"
jackson = "2.17.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class MainPanel : JPanel(MigLayout("ins 6, fill, hidemode 3")) {
private val landingPanel = JPanel(MigLayout("ins 0, fillx", "[center, grow]")).apply {
add(
JLabel("Open...").apply {
font = font.deriveFont(24F)
putClientProperty("FlatLaf.styleClass", "h1")
},
)
for (tools in Tool.sortedByTitle.chunked(3)) {
Expand All @@ -148,10 +148,8 @@ class MainPanel : JPanel(MigLayout("ins 6, fill, hidemode 3")) {
}

private fun toolTile(tool: Tool): JButton {
return JButton().apply {
text = tool.title
font = font.deriveFont(18F)
icon = tool.icon.derive(2F)
return JButton(tool.title, tool.icon.derive(2F)).apply {
putClientProperty("FlatLaf.styleClass", "h2.regular")
iconTextGap = 20
verticalTextPosition = BOTTOM
horizontalTextPosition = CENTER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ package io.github.inductiveautomation.kindling.idb.generic

import com.formdev.flatlaf.extras.FlatSVGIcon
import com.formdev.flatlaf.extras.components.FlatTree
import com.jidesoft.swing.StyledLabelBuilder
import com.jidesoft.swing.TreeSearchable
import com.jidesoft.tree.StyledTreeCellRenderer
import io.github.inductiveautomation.kindling.utils.asActionIcon
import io.github.inductiveautomation.kindling.utils.toFileSizeLabel
import java.awt.Font
import javax.swing.JTree
import javax.swing.UIManager
import io.github.inductiveautomation.kindling.utils.treeCellRenderer
import javax.swing.tree.TreeModel
import javax.swing.tree.TreePath
import javax.swing.tree.TreeSelectionModel
Expand All @@ -21,36 +17,27 @@ class DBMetaDataTree(treeModel: TreeModel) : FlatTree() {
setShowsRootHandles(true)
selectionModel.selectionMode = TreeSelectionModel.SINGLE_TREE_SELECTION
setCellRenderer(
object : StyledTreeCellRenderer() {
override fun customizeStyledLabel(tree: JTree, value: Any?, sel: Boolean, expanded: Boolean, leaf: Boolean, row: Int, focused: Boolean) {
super.customizeStyledLabel(tree, value, sel, expanded, leaf, row, focused)
clearStyleRanges()

foreground = when {
selected && focused -> UIManager.getColor("Tree.selectionForeground")
selected -> UIManager.getColor("Tree.selectionInactiveForeground")
else -> UIManager.getColor("Tree.textForeground")
treeCellRenderer { _, value, selected, _, _, _, hasFocus ->
when (value) {
is Table -> {
text = buildString {
append(value.name)
append(" ")
append("(${value.size.toFileSizeLabel()})")
}
icon = TABLE_ICON.asActionIcon(selected && hasFocus)
}

when (value) {
is Table -> {
StyledLabelBuilder().apply {
add(value.name)
add(" ")
add("(${value.size.toFileSizeLabel()})", Font.ITALIC)
}.configure(this)
icon = TABLE_ICON.asActionIcon(selected || focused)
}
is Column -> {
StyledLabelBuilder().apply {
add(value.name)
add(" ")
add(value.type.takeIf { it.isNotEmpty() } ?: "UNKNOWN", Font.ITALIC)
}.configure(this)
icon = COLUMN_ICON.asActionIcon(selected || focused)
is Column -> {
text = buildString {
append(value.name)
append(" ")
append(value.type.takeIf { it.isNotEmpty() } ?: "UNKNOWN")
}
icon = COLUMN_ICON.asActionIcon(selected && hasFocus)
}
}
this
},
)

Expand Down
Loading

0 comments on commit 9e47663

Please sign in to comment.