From bf6e943195a3f4ed60e4228389eae7eb33b9a529 Mon Sep 17 00:00:00 2001 From: Joshlha Date: Thu, 21 Sep 2023 12:57:24 -0700 Subject: [PATCH] Fix Windows file compatibility issue with JFileChooser --- .../inductiveautomation/kindling/utils/Swing.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/io/github/inductiveautomation/kindling/utils/Swing.kt b/src/main/kotlin/io/github/inductiveautomation/kindling/utils/Swing.kt index db0ac52b..e4cd6ea7 100644 --- a/src/main/kotlin/io/github/inductiveautomation/kindling/utils/Swing.kt +++ b/src/main/kotlin/io/github/inductiveautomation/kindling/utils/Swing.kt @@ -61,8 +61,6 @@ import javax.swing.text.Document import javax.swing.tree.DefaultTreeCellRenderer import javax.swing.tree.TreeCellRenderer import javax.swing.tree.TreeNode -import kotlin.io.path.extension -import kotlin.io.path.isDirectory import kotlin.reflect.KClass import kotlin.reflect.safeCast import kotlin.time.Duration.Companion.milliseconds @@ -326,15 +324,17 @@ class ReifiedJXTable( class FileFilter( private val description: String, - private val predicate: (path: Path) -> Boolean, + private val predicate: (file: File) -> Boolean, ) : SwingFileFilter(), FileFilter { - constructor(description: String, extensions: List) : this(description, { path -> path.extension in extensions }) + constructor(description: String, extensions: List) : this(description, { file -> file.extension in extensions }) fun accept(path: Path): Boolean { - return path.isDirectory() || predicate(path) + return accept(path.toFile()) } - override fun accept(file: File): Boolean = accept(file.toPath()) + override fun accept(file: File): Boolean { + return file.isDirectory || predicate(file) + } override fun getDescription(): String = description }