1 28 29 package org.objectweb.util.browser.plugins.fractal.lib; 30 31 import java.io.File ; 32 33 import javax.swing.JFileChooser ; 34 import javax.swing.filechooser.FileFilter ; 35 36 import org.objectweb.util.browser.plugins.fractal.api.FractalBrowserConstants; 37 38 43 public class JFileChooserSingleton 44 { 45 51 52 protected static JFileChooser instance_ = null; 53 54 55 protected static FileFilter fractalFileFilter_ = new FractalFileFilter(); 56 57 63 69 72 protected static void init() { 73 instance_ = new JFileChooser (); 74 } 75 76 85 public static JFileChooser getInstance(int fileFilterType) { 86 File f = null; 87 if (instance_ != null) 88 f = instance_.getCurrentDirectory(); 89 else 90 f = new File (System.getProperty("user.dir")); 91 init(); 92 instance_.setCurrentDirectory(f); 93 if (fileFilterType == FractalBrowserConstants.FRACTAL_FILE_FILTER) 94 instance_.setFileFilter(fractalFileFilter_); 95 else if (fileFilterType == FractalBrowserConstants.DIRECTORY_FILE_FILTER) 96 instance_.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 97 return instance_; 98 } 99 } 100 | Popular Tags |