1 22 23 package apollo.dev; 24 25 import java.io.*; 26 import javax.swing.JFileChooser ; 27 import apollo.*; 28 29 public class DevFileOpenService implements FileOpenService 30 { 31 JFileChooser _chooser; 32 33 public DevFileOpenService() 34 { 35 _chooser = new JFileChooser (); 36 } 37 38 public FileContents openFileDialog( String pathHint, String exts[] ) 39 throws IOException 40 { 41 if( pathHint != null ) 42 _chooser.setCurrentDirectory( new File( pathHint ) ); 43 44 46 _chooser.setMultiSelectionEnabled( false ); 47 if( _chooser.showOpenDialog( null ) == JFileChooser.CANCEL_OPTION ) 48 return null; 49 50 File file = _chooser.getSelectedFile(); 51 if( file == null ) 52 return null; 53 else 54 return new DevFileContents( file ); 55 } 56 57 public FileContents[] openMultiFileDialog( String pathHint, String exts[] ) 58 throws IOException 59 { 60 if( pathHint != null ) 61 _chooser.setCurrentDirectory( new File( pathHint ) ); 62 63 _chooser.setMultiSelectionEnabled( true ); 64 if( _chooser.showOpenDialog( null ) == JFileChooser.CANCEL_OPTION ) 65 return null; 66 67 File file[] = _chooser.getSelectedFiles(); 68 DevFileContents contents[] = new DevFileContents[file.length]; 69 for( int i = 0; i < file.length; i++ ) 70 contents[i] = new DevFileContents( file[i] ); 71 72 return contents; 73 } 74 } 75 | Popular Tags |