home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / plaf / basic / BasicFileChooserUI.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  9.8 KB  |  357 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.event.MouseListener;
  5. import java.beans.PropertyChangeListener;
  6. import java.io.File;
  7. import javax.swing.Action;
  8. import javax.swing.ActionMap;
  9. import javax.swing.Icon;
  10. import javax.swing.InputMap;
  11. import javax.swing.JButton;
  12. import javax.swing.JComponent;
  13. import javax.swing.JFileChooser;
  14. import javax.swing.JList;
  15. import javax.swing.JPanel;
  16. import javax.swing.SwingUtilities;
  17. import javax.swing.UIManager;
  18. import javax.swing.event.AncestorListener;
  19. import javax.swing.event.ListSelectionListener;
  20. import javax.swing.filechooser.FileFilter;
  21. import javax.swing.filechooser.FileView;
  22. import javax.swing.plaf.ActionMapUIResource;
  23. import javax.swing.plaf.FileChooserUI;
  24.  
  25. public class BasicFileChooserUI extends FileChooserUI {
  26.    protected Icon directoryIcon = null;
  27.    protected Icon fileIcon = null;
  28.    protected Icon computerIcon = null;
  29.    protected Icon hardDriveIcon = null;
  30.    protected Icon floppyDriveIcon = null;
  31.    protected Icon newFolderIcon = null;
  32.    protected Icon upFolderIcon = null;
  33.    protected Icon homeFolderIcon = null;
  34.    protected Icon listViewIcon = null;
  35.    protected Icon detailsViewIcon = null;
  36.    protected int saveButtonMnemonic = 0;
  37.    protected int openButtonMnemonic = 0;
  38.    protected int cancelButtonMnemonic = 0;
  39.    protected int updateButtonMnemonic = 0;
  40.    protected int helpButtonMnemonic = 0;
  41.    protected String saveButtonText = null;
  42.    protected String openButtonText = null;
  43.    protected String cancelButtonText = null;
  44.    protected String updateButtonText = null;
  45.    protected String helpButtonText = null;
  46.    protected String saveButtonToolTipText = null;
  47.    protected String openButtonToolTipText = null;
  48.    protected String cancelButtonToolTipText = null;
  49.    protected String updateButtonToolTipText = null;
  50.    protected String helpButtonToolTipText = null;
  51.    private Action approveSelectionAction = new ApproveSelectionAction(this);
  52.    private Action cancelSelectionAction = new CancelSelectionAction(this);
  53.    private Action updateAction = new UpdateAction(this);
  54.    private Action newFolderAction = new NewFolderAction(this);
  55.    private Action goHomeAction = new GoHomeAction(this);
  56.    private Action changeToParentDirectoryAction = new ChangeToParentDirectoryAction(this);
  57.    private String newFolderErrorSeparator = null;
  58.    private String newFolderErrorText = null;
  59.    private String fileDescriptionText = null;
  60.    private String directoryDescriptionText = null;
  61.    private JFileChooser filechooser = null;
  62.    private PropertyChangeListener propertyChangeListener = null;
  63.    private AncestorListener ancestorListener = null;
  64.    private AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter(this);
  65.    private BasicDirectoryModel model = null;
  66.    private BasicFileView fileView = new BasicFileView(this);
  67.    private JPanel accessoryPanel = null;
  68.  
  69.    public BasicFileChooserUI(JFileChooser var1) {
  70.    }
  71.  
  72.    public void installUI(JComponent var1) {
  73.       this.accessoryPanel = new JPanel(new BorderLayout());
  74.       this.filechooser = (JFileChooser)var1;
  75.       this.createModel();
  76.       this.installDefaults(this.filechooser);
  77.       this.installComponents(this.filechooser);
  78.       this.installListeners(this.filechooser);
  79.    }
  80.  
  81.    public void uninstallUI(JComponent var1) {
  82.       this.uninstallListeners(this.filechooser);
  83.       this.uninstallComponents(this.filechooser);
  84.       this.uninstallDefaults(this.filechooser);
  85.       if (this.accessoryPanel != null) {
  86.          this.accessoryPanel.removeAll();
  87.       }
  88.  
  89.       this.accessoryPanel = null;
  90.       this.getFileChooser().removeAll();
  91.    }
  92.  
  93.    public void installComponents(JFileChooser var1) {
  94.    }
  95.  
  96.    public void uninstallComponents(JFileChooser var1) {
  97.    }
  98.  
  99.    protected void installListeners(JFileChooser var1) {
  100.       this.propertyChangeListener = this.createPropertyChangeListener(var1);
  101.       if (this.propertyChangeListener != null) {
  102.          ((JComponent)var1).addPropertyChangeListener(this.propertyChangeListener);
  103.       }
  104.  
  105.       ((JComponent)var1).addPropertyChangeListener(this.model);
  106.       this.ancestorListener = new 1(this);
  107.       ((JComponent)var1).addAncestorListener(this.ancestorListener);
  108.       InputMap var2 = this.getInputMap(1);
  109.       SwingUtilities.replaceUIInputMap(var1, 1, var2);
  110.       ActionMap var3 = this.getActionMap();
  111.       SwingUtilities.replaceUIActionMap(var1, var3);
  112.    }
  113.  
  114.    InputMap getInputMap(int var1) {
  115.       return var1 == 1 ? (InputMap)UIManager.get("FileChooser.ancestorInputMap") : null;
  116.    }
  117.  
  118.    ActionMap getActionMap() {
  119.       return this.createActionMap();
  120.    }
  121.  
  122.    ActionMap createActionMap() {
  123.       2 var1 = new 2(this);
  124.       ActionMapUIResource var2 = new ActionMapUIResource();
  125.       ((ActionMap)var2).put("cancelSelection", var1);
  126.       return var2;
  127.    }
  128.  
  129.    protected void uninstallListeners(JFileChooser var1) {
  130.       if (this.propertyChangeListener != null) {
  131.          ((JComponent)var1).removePropertyChangeListener(this.propertyChangeListener);
  132.       }
  133.  
  134.       ((JComponent)var1).removePropertyChangeListener(this.model);
  135.       SwingUtilities.replaceUIInputMap(var1, 1, (InputMap)null);
  136.       SwingUtilities.replaceUIActionMap(var1, (ActionMap)null);
  137.       ((JComponent)var1).removeAncestorListener(this.ancestorListener);
  138.       this.ancestorListener = null;
  139.    }
  140.  
  141.    protected void installDefaults(JFileChooser var1) {
  142.       this.installIcons(var1);
  143.       this.installStrings(var1);
  144.    }
  145.  
  146.    protected void installIcons(JFileChooser var1) {
  147.       this.directoryIcon = UIManager.getIcon("FileView.directoryIcon");
  148.       this.fileIcon = UIManager.getIcon("FileView.fileIcon");
  149.       this.computerIcon = UIManager.getIcon("FileView.computerIcon");
  150.       this.hardDriveIcon = UIManager.getIcon("FileView.hardDriveIcon");
  151.       this.floppyDriveIcon = UIManager.getIcon("FileView.floppyDriveIcon");
  152.       this.newFolderIcon = UIManager.getIcon("FileChooser.newFolderIcon");
  153.       this.upFolderIcon = UIManager.getIcon("FileChooser.upFolderIcon");
  154.       this.homeFolderIcon = UIManager.getIcon("FileChooser.homeFolderIcon");
  155.       this.detailsViewIcon = UIManager.getIcon("FileChooser.detailsViewIcon");
  156.       this.listViewIcon = UIManager.getIcon("FileChooser.listViewIcon");
  157.    }
  158.  
  159.    protected void installStrings(JFileChooser var1) {
  160.       this.newFolderErrorText = UIManager.getString("FileChooser.newFolderErrorText");
  161.       this.newFolderErrorSeparator = UIManager.getString("FileChooser.newFolderErrorSeparator");
  162.       this.fileDescriptionText = UIManager.getString("FileChooser.fileDescriptionText");
  163.       this.directoryDescriptionText = UIManager.getString("FileChooser.directoryDescriptionText");
  164.       this.saveButtonText = UIManager.getString("FileChooser.saveButtonText");
  165.       this.openButtonText = UIManager.getString("FileChooser.openButtonText");
  166.       this.cancelButtonText = UIManager.getString("FileChooser.cancelButtonText");
  167.       this.updateButtonText = UIManager.getString("FileChooser.updateButtonText");
  168.       this.helpButtonText = UIManager.getString("FileChooser.helpButtonText");
  169.       this.saveButtonMnemonic = UIManager.getInt("FileChooser.saveButtonMnemonic");
  170.       this.openButtonMnemonic = UIManager.getInt("FileChooser.openButtonMnemonic");
  171.       this.cancelButtonMnemonic = UIManager.getInt("FileChooser.cancelButtonMnemonic");
  172.       this.updateButtonMnemonic = UIManager.getInt("FileChooser.updateButtonMnemonic");
  173.       this.helpButtonMnemonic = UIManager.getInt("FileChooser.helpButtonMnemonic");
  174.       this.saveButtonToolTipText = UIManager.getString("FileChooser.saveButtonToolTipText");
  175.       this.openButtonToolTipText = UIManager.getString("FileChooser.openButtonToolTipText");
  176.       this.cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText");
  177.       this.updateButtonToolTipText = UIManager.getString("FileChooser.updateButtonToolTipText");
  178.       this.helpButtonToolTipText = UIManager.getString("FileChooser.helpButtonToolTipText");
  179.    }
  180.  
  181.    protected void uninstallDefaults(JFileChooser var1) {
  182.       this.uninstallIcons(var1);
  183.       this.uninstallStrings(var1);
  184.    }
  185.  
  186.    protected void uninstallIcons(JFileChooser var1) {
  187.       this.directoryIcon = null;
  188.       this.fileIcon = null;
  189.       this.computerIcon = null;
  190.       this.hardDriveIcon = null;
  191.       this.floppyDriveIcon = null;
  192.       this.newFolderIcon = null;
  193.       this.upFolderIcon = null;
  194.       this.homeFolderIcon = null;
  195.       this.detailsViewIcon = null;
  196.       this.listViewIcon = null;
  197.    }
  198.  
  199.    protected void uninstallStrings(JFileChooser var1) {
  200.       this.saveButtonText = null;
  201.       this.openButtonText = null;
  202.       this.cancelButtonText = null;
  203.       this.updateButtonText = null;
  204.       this.helpButtonText = null;
  205.       this.saveButtonToolTipText = null;
  206.       this.openButtonToolTipText = null;
  207.       this.cancelButtonToolTipText = null;
  208.       this.updateButtonToolTipText = null;
  209.       this.helpButtonToolTipText = null;
  210.    }
  211.  
  212.    protected void createModel() {
  213.       this.model = new BasicDirectoryModel(this.getFileChooser());
  214.    }
  215.  
  216.    public BasicDirectoryModel getModel() {
  217.       return this.model;
  218.    }
  219.  
  220.    public PropertyChangeListener createPropertyChangeListener(JFileChooser var1) {
  221.       return null;
  222.    }
  223.  
  224.    public String getFileName() {
  225.       return null;
  226.    }
  227.  
  228.    public String getDirectoryName() {
  229.       return null;
  230.    }
  231.  
  232.    public void setFileName(String var1) {
  233.    }
  234.  
  235.    public void setDirectoryName(String var1) {
  236.    }
  237.  
  238.    public void rescanCurrentDirectory(JFileChooser var1) {
  239.    }
  240.  
  241.    public void ensureFileIsVisible(JFileChooser var1, File var2) {
  242.    }
  243.  
  244.    public JFileChooser getFileChooser() {
  245.       return this.filechooser;
  246.    }
  247.  
  248.    public JPanel getAccessoryPanel() {
  249.       return this.accessoryPanel;
  250.    }
  251.  
  252.    protected JButton getApproveButton(JFileChooser var1) {
  253.       return null;
  254.    }
  255.  
  256.    public String getApproveButtonToolTipText(JFileChooser var1) {
  257.       String var2 = var1.getApproveButtonToolTipText();
  258.       if (var2 != null) {
  259.          return var2;
  260.       } else if (var1.getDialogType() == 0) {
  261.          return this.openButtonToolTipText;
  262.       } else {
  263.          return var1.getDialogType() == 1 ? this.saveButtonToolTipText : null;
  264.       }
  265.    }
  266.  
  267.    public void clearIconCache() {
  268.       this.fileView.clearIconCache();
  269.    }
  270.  
  271.    public ListSelectionListener createListSelectionListener(JFileChooser var1) {
  272.       return new SelectionListener(this);
  273.    }
  274.  
  275.    protected MouseListener createDoubleClickListener(JFileChooser var1, JList var2) {
  276.       return new DoubleClickListener(this, var2);
  277.    }
  278.  
  279.    public FileFilter getAcceptAllFileFilter(JFileChooser var1) {
  280.       return this.acceptAllFileFilter;
  281.    }
  282.  
  283.    public FileView getFileView(JFileChooser var1) {
  284.       return this.fileView;
  285.    }
  286.  
  287.    public String getDialogTitle(JFileChooser var1) {
  288.       return this.getApproveButtonText(var1);
  289.    }
  290.  
  291.    public int getApproveButtonMnemonic(JFileChooser var1) {
  292.       if (this.getFileChooser().getDialogType() == 0) {
  293.          return this.openButtonMnemonic;
  294.       } else if (this.getFileChooser().getDialogType() == 1) {
  295.          return this.saveButtonMnemonic;
  296.       } else {
  297.          int var2 = this.getFileChooser().getApproveButtonMnemonic();
  298.          return var2;
  299.       }
  300.    }
  301.  
  302.    public String getApproveButtonText(JFileChooser var1) {
  303.       String var2 = this.getFileChooser().getApproveButtonText();
  304.       if (var2 != null) {
  305.          return var2;
  306.       } else if (this.getFileChooser().getDialogType() == 0) {
  307.          return this.openButtonText;
  308.       } else {
  309.          return this.getFileChooser().getDialogType() == 1 ? this.saveButtonText : null;
  310.       }
  311.    }
  312.  
  313.    public Action getNewFolderAction() {
  314.       return this.newFolderAction;
  315.    }
  316.  
  317.    public Action getGoHomeAction() {
  318.       return this.goHomeAction;
  319.    }
  320.  
  321.    public Action getChangeToParentDirectoryAction() {
  322.       return this.changeToParentDirectoryAction;
  323.    }
  324.  
  325.    public Action getApproveSelectionAction() {
  326.       return this.approveSelectionAction;
  327.    }
  328.  
  329.    public Action getCancelSelectionAction() {
  330.       return this.cancelSelectionAction;
  331.    }
  332.  
  333.    public Action getUpdateAction() {
  334.       return this.updateAction;
  335.    }
  336.  
  337.    // $FF: synthetic method
  338.    static String access$000(BasicFileChooserUI var0) {
  339.       return var0.newFolderErrorText;
  340.    }
  341.  
  342.    // $FF: synthetic method
  343.    static String access$100(BasicFileChooserUI var0) {
  344.       return var0.newFolderErrorSeparator;
  345.    }
  346.  
  347.    // $FF: synthetic method
  348.    static String access$200(BasicFileChooserUI var0) {
  349.       return var0.directoryDescriptionText;
  350.    }
  351.  
  352.    // $FF: synthetic method
  353.    static String access$300(BasicFileChooserUI var0) {
  354.       return var0.fileDescriptionText;
  355.    }
  356. }
  357.