private void createFileFilter ( ) { HashMap < String , String [ ] > extensionMap = MultimediaContainerManager . getSupportedFileExtensionsPerContainer ( ) ; ArrayList < FileFilter > chooserFilterArray = new ArrayList < FileFilter > ( extensionMap . size ( ) + 1 ) ; // add all single file extensions grouped by container Set < String > containerNameSet = extensionMap . keySet ( ) ; Iterator < String > containerNameIterator = containerNameSet . iterator ( ) ; while ( containerNameIterator . hasNext ( ) ) { String containerName = containerNameIterator . next ( ) ; String [ ] extensions = extensionMap . get ( containerName ) ; StringBuilder fileText = new StringBuilder ( containerName ) ; fileText . append ( " (" ) ; int ende = extensions . length - 1 ; for ( int i = 0 ; i <= ende ; i ++ ) { fileText . append ( "*." ) . append ( extensions [ i ] ) ; if ( i < ende ) fileText . append ( ", " ) ; } fileText . append ( ' ' ) ; chooserFilterArray . add ( new FileChooserFilter ( extensions , fileText . toString ( ) ) ) ; } // now add playlist as group of files chooserFilterArray . add ( PlayList . PLAYLIST_FILE_FILTER ) ; // now add all playable files at the last step (container extensions and playlist files) String [ ] containerExtensions = MultimediaContainerManager . getSupportedFileExtensions ( ) ; String [ ] fullSupportedExtensions = new String [ containerExtensions . length + PlayList . SUPPORTEDPLAYLISTS . length ] ; System . arraycopy ( PlayList . SUPPORTEDPLAYLISTS , 0 , fullSupportedExtensions , 0 , PlayList . SUPPORTEDPLAYLISTS . length ) ; System . arraycopy ( containerExtensions , 0 , fullSupportedExtensions , PlayList . SUPPORTEDPLAYLISTS . length , containerExtensions . length ) ; chooserFilterArray . add ( new FileChooserFilter ( fullSupportedExtensions , "All playable files" ) ) ; // add default "all files" - WE DO NOT DO THAT ANYMORE ;) // chooserFilterArray.add(new FileChooserFilter("*", "All files")); fileFilterLoad = new FileFilter [ chooserFilterArray . size ( ) ] ; chooserFilterArray . toArray ( fileFilterLoad ) ; fileFilterExport = new FileFilter [ 1 ] ; fileFilterExport [ 0 ] = new FileChooserFilter ( javax . sound . sampled . AudioFileFormat . Type . WAVE . getExtension ( ) , javax . sound . sampled . AudioFileFormat . Type . WAVE . toString ( ) ) ; }
Create the file filters so that we do have them for the dialogs