Skip to content

Commit 735f06d

Browse files
committed
(Temporary) fix for tool loading order in archives
1 parent ebee051 commit 735f06d

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/main/kotlin/io/github/inductiveautomation/kindling/MainPanel.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ class MainPanel : JPanel(MigLayout("ins 6, fill, hidemode 3")) {
102102
)
103103
}
104104

105-
Tool.byFilter.keys.forEach(this::addChoosableFileFilter)
105+
Tool.sortedByTitle.forEach { tool ->
106+
addChoosableFileFilter(tool.filter)
107+
}
106108
fileFilter = DefaultTool.currentValue.filter
107109
addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY) { e ->
108110
val relevantTool = Tool.byFilter[e.newValue as FileFilter]
@@ -137,7 +139,7 @@ class MainPanel : JPanel(MigLayout("ins 6, fill, hidemode 3")) {
137139
font = font.deriveFont(24F)
138140
},
139141
)
140-
for (tools in Tool.tools.sortedBy { it.title }.chunked(3)) {
142+
for (tools in Tool.sortedByTitle.chunked(3)) {
141143
add(toolTile(tools[0]), "sg tile, h 200!, newline, split, gaptop 20")
142144
for (tool in tools.drop(1)) {
143145
add(toolTile(tool), "sg tile, gap 20 0 20 0")
@@ -222,7 +224,7 @@ class MainPanel : JPanel(MigLayout("ins 6, fill, hidemode 3")) {
222224

223225
private val fileMenu = JMenu("File").apply {
224226
add(openAction)
225-
for (tool in Tool.tools) {
227+
for (tool in Tool.sortedByTitle) {
226228
add(
227229
Action(
228230
name = "Open ${tool.title}",

src/main/kotlin/io/github/inductiveautomation/kindling/core/Kindling.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ data object Kindling {
7878
default = Tool.tools.first(),
7979
serializer = ToolSerializer,
8080
editor = {
81-
JComboBox(Vector(Tool.tools)).apply {
81+
JComboBox(Vector(Tool.sortedByTitle)).apply {
8282
selectedItem = currentValue
8383

8484
configureCellRenderer { _, value, _, selected, focused ->

src/main/kotlin/io/github/inductiveautomation/kindling/core/Tool.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ interface Tool : KindlingSerializable {
5555
add(AlarmViewer)
5656
add(XmlTool)
5757
addAll(loadService<Tool>())
58-
}.sortedBy { it.title }
58+
}
59+
}
60+
61+
val sortedByTitle: List<Tool> by lazy {
62+
tools.sortedBy { it.title }
5963
}
6064

6165
val byFilter: Map<FileFilter, Tool> by lazy {

0 commit comments

Comments
 (0)