Commits

Matthias Mann  committed ea25eb0

add file extension filter

  • Participants
  • Parent commits cb44cb8

Comments (0)

Files changed (1)

File src/de/matthiasmann/twlscala/FileSelector.scala

     def FileNameFilter(name:String, f:(String)=>Boolean) = new FileFilter(name, new FileSystemModel.FileFilter {
             def accept(fsm:FileSystemModel, obj:AnyRef) = f(fsm.getName(obj))
         })
+    def FileExtensionFilter(name:String, f:(String)=>Boolean) = new FileFilter(name, new FileSystemModel.FileFilter {
+            def accept(fsm:FileSystemModel, obj:AnyRef) = {
+                val name = fsm.getName(obj)
+                f(name.substring(name.lastIndexOf('.')+1))
+            }
+        })
     
     addCallback(new TWLFileSelector.Callback {
         def filesSelected(objs:Array[AnyRef]) {