jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
changeset 1853 63c1129add13
parent 1639 a97859015238
parent 1842 824c7f885a64
child 2491 123954ad0034
equal deleted inserted replaced
1810:54dffad0bf06 1853:63c1129add13
    69 
    69 
    70     private FilePane filePane;
    70     private FilePane filePane;
    71     private JToggleButton listViewButton;
    71     private JToggleButton listViewButton;
    72     private JToggleButton detailsViewButton;
    72     private JToggleButton detailsViewButton;
    73 
    73 
    74     private boolean useShellFolder;
       
    75 
       
    76     private boolean readOnly;
    74     private boolean readOnly;
    77 
    75 
    78     private JPanel buttonPanel;
    76     private JPanel buttonPanel;
    79     private JPanel bottomPanel;
    77     private JPanel bottomPanel;
    80 
    78 
   183         }
   181         }
   184 
   182 
   185         public ListSelectionListener createListSelectionListener() {
   183         public ListSelectionListener createListSelectionListener() {
   186             return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
   184             return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
   187         }
   185         }
   188 
       
   189         public boolean usesShellFolder() {
       
   190             return useShellFolder;
       
   191         }
       
   192     }
   186     }
   193 
   187 
   194     protected void installDefaults(JFileChooser fc) {
   188     protected void installDefaults(JFileChooser fc) {
   195         super.installDefaults(fc);
   189         super.installDefaults(fc);
   196         readOnly = UIManager.getBoolean("FileChooser.readOnly");
   190         readOnly = UIManager.getBoolean("FileChooser.readOnly");
   198 
   192 
   199     public void installComponents(JFileChooser fc) {
   193     public void installComponents(JFileChooser fc) {
   200         super.installComponents(fc);
   194         super.installComponents(fc);
   201 
   195 
   202         SynthContext context = getContext(fc, ENABLED);
   196         SynthContext context = getContext(fc, ENABLED);
   203 
       
   204         updateUseShellFolder();
       
   205 
   197 
   206         fc.setLayout(new BorderLayout(0, 11));
   198         fc.setLayout(new BorderLayout(0, 11));
   207 
   199 
   208         // ********************************* //
   200         // ********************************* //
   209         // **** Construct the top panel **** //
   201         // **** Construct the top panel **** //
   430     protected void uninstallListeners(JFileChooser fc) {
   422     protected void uninstallListeners(JFileChooser fc) {
   431         fc.removePropertyChangeListener(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY, modeListener);
   423         fc.removePropertyChangeListener(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY, modeListener);
   432         super.uninstallListeners(fc);
   424         super.uninstallListeners(fc);
   433     }
   425     }
   434 
   426 
   435     private void updateUseShellFolder() {
       
   436         // Decide whether to use the ShellFolder class to populate shortcut
       
   437         // panel and combobox.
       
   438         JFileChooser fc = getFileChooser();
       
   439         Boolean prop =
       
   440             (Boolean)fc.getClientProperty("FileChooser.useShellFolder");
       
   441         if (prop != null) {
       
   442             useShellFolder = prop.booleanValue();
       
   443         } else {
       
   444             useShellFolder = fc.getFileSystemView().equals(FileSystemView.getFileSystemView());
       
   445         }
       
   446     }
       
   447 
       
   448 
       
   449     private String fileNameString(File file) {
   427     private String fileNameString(File file) {
   450         if (file == null) {
   428         if (file == null) {
   451             return null;
   429             return null;
   452         } else {
   430         } else {
   453             JFileChooser fc = getFileChooser();
   431             JFileChooser fc = getFileChooser();
   758         public void addItem(File directory) {
   736         public void addItem(File directory) {
   759 
   737 
   760             if (directory == null) {
   738             if (directory == null) {
   761                 return;
   739                 return;
   762             }
   740             }
       
   741 
       
   742             boolean useShellFolder = FilePane.usesShellFolder(chooser);
   763 
   743 
   764             int oldSize = directories.size();
   744             int oldSize = directories.size();
   765             directories.clear();
   745             directories.clear();
   766             if (oldSize > 0) {
   746             if (oldSize > 0) {
   767                 fireIntervalRemoved(this, 0, oldSize);
   747                 fireIntervalRemoved(this, 0, oldSize);