001package jmri.util.swing;
002
003import java.io.File;
004
005import javax.swing.JFileChooser;
006import javax.swing.filechooser.FileSystemView;
007
008import jmri.InstanceManager;
009
010public class JmriJFileChooser extends JFileChooser {
011
012
013    public JmriJFileChooser() {
014        super();
015        setJFileChooserFormat();
016    }
017
018    public JmriJFileChooser(String path) {
019        super(path);
020        setJFileChooserFormat();
021    }
022
023    public JmriJFileChooser(FileSystemView fsv) {
024        super(fsv);
025        setJFileChooserFormat();
026    }
027
028
029    public JmriJFileChooser(File f) {
030        super(f);
031        setJFileChooserFormat();
032    }
033
034    private void setJFileChooserFormat() {
035        javax.swing.Action details;
036        switch (InstanceManager.getDefault(jmri.util.gui.GuiLafPreferencesManager.class).getJFileChooserFormat()) {
037            case 1:
038                details = this.getActionMap().get("viewTypeList");
039                break;
040            case 2:
041                details = this.getActionMap().get("viewTypeDetails");
042                break;
043            default:
044                return;
045        }
046        if (details!=null) {
047            details.actionPerformed(null);
048        }
049    }
050}