Skip to content

Commit

Permalink
Fix Windows file compatibility issue with JFileChooser
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshlha committed Sep 21, 2023
1 parent 58da3da commit 4b25fa9
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -326,15 +324,17 @@ class ReifiedJXTable<T : TableModel>(

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<String>) : this(description, { path -> path.extension in extensions })
constructor(description: String, extensions: List<String>) : 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
}
Expand Down

0 comments on commit 4b25fa9

Please sign in to comment.