Commits

Anonymous committed ea25eb0

add file extension filter

Comments (0)

Files changed (1)

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]) {