src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java

Print this page




 158         public boolean isDirectorySelected() {
 159             return SynthFileChooserUIImpl.this.isDirectorySelected();
 160         }
 161 
 162         public File getDirectory() {
 163             return SynthFileChooserUIImpl.this.getDirectory();
 164         }
 165 
 166         public Action getChangeToParentDirectoryAction() {
 167             return SynthFileChooserUIImpl.this.getChangeToParentDirectoryAction();
 168         }
 169 
 170         public Action getApproveSelectionAction() {
 171             return SynthFileChooserUIImpl.this.getApproveSelectionAction();
 172         }
 173 
 174         public Action getNewFolderAction() {
 175             return SynthFileChooserUIImpl.this.getNewFolderAction();
 176         }
 177 
 178         public MouseListener createDoubleClickListener(JList list) {
 179             return SynthFileChooserUIImpl.this.createDoubleClickListener(getFileChooser(),
 180                                                                      list);
 181         }
 182 
 183         public ListSelectionListener createListSelectionListener() {
 184             return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
 185         }
 186     }
 187 
 188     protected void installDefaults(JFileChooser fc) {
 189         super.installDefaults(fc);
 190         readOnly = UIManager.getBoolean("FileChooser.readOnly");
 191     }
 192 
 193     @SuppressWarnings("serial") // anonymous classes inside
 194     public void installComponents(JFileChooser fc) {
 195         super.installComponents(fc);
 196 
 197         SynthContext context = getContext(fc, ENABLED);
 198 


 546             && files.length > 0
 547             && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
 548             setFileName(fileNameString(files));
 549         }
 550     }
 551 
 552     protected void doDirectoryChanged(PropertyChangeEvent e) {
 553         super.doDirectoryChanged(e);
 554 
 555         JFileChooser fc = getFileChooser();
 556         FileSystemView fsv = fc.getFileSystemView();
 557         File currentDirectory = fc.getCurrentDirectory();
 558 
 559         if (!readOnly && currentDirectory != null) {
 560             getNewFolderAction().setEnabled(filePane.canWrite(currentDirectory));
 561         }
 562 
 563         if (currentDirectory != null) {
 564             JComponent cb = getDirectoryComboBox();
 565             if (cb instanceof JComboBox) {
 566                 ComboBoxModel model = ((JComboBox)cb).getModel();
 567                 if (model instanceof DirectoryComboBoxModel) {
 568                     ((DirectoryComboBoxModel)model).addItem(currentDirectory);
 569                 }
 570             }
 571 
 572             if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
 573                 if (fsv.isFileSystem(currentDirectory)) {
 574                     setFileName(currentDirectory.getPath());
 575                 } else {
 576                     setFileName(null);
 577                 }
 578             }
 579         }
 580     }
 581 
 582 
 583     protected void doFileSelectionModeChanged(PropertyChangeEvent e) {
 584         super.doFileSelectionModeChanged(e);
 585 
 586         JFileChooser fc = getFileChooser();




 158         public boolean isDirectorySelected() {
 159             return SynthFileChooserUIImpl.this.isDirectorySelected();
 160         }
 161 
 162         public File getDirectory() {
 163             return SynthFileChooserUIImpl.this.getDirectory();
 164         }
 165 
 166         public Action getChangeToParentDirectoryAction() {
 167             return SynthFileChooserUIImpl.this.getChangeToParentDirectoryAction();
 168         }
 169 
 170         public Action getApproveSelectionAction() {
 171             return SynthFileChooserUIImpl.this.getApproveSelectionAction();
 172         }
 173 
 174         public Action getNewFolderAction() {
 175             return SynthFileChooserUIImpl.this.getNewFolderAction();
 176         }
 177 
 178         public MouseListener createDoubleClickListener(JList<?> list) {
 179             return SynthFileChooserUIImpl.this.createDoubleClickListener(getFileChooser(),
 180                                                                      list);
 181         }
 182 
 183         public ListSelectionListener createListSelectionListener() {
 184             return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
 185         }
 186     }
 187 
 188     protected void installDefaults(JFileChooser fc) {
 189         super.installDefaults(fc);
 190         readOnly = UIManager.getBoolean("FileChooser.readOnly");
 191     }
 192 
 193     @SuppressWarnings("serial") // anonymous classes inside
 194     public void installComponents(JFileChooser fc) {
 195         super.installComponents(fc);
 196 
 197         SynthContext context = getContext(fc, ENABLED);
 198 


 546             && files.length > 0
 547             && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
 548             setFileName(fileNameString(files));
 549         }
 550     }
 551 
 552     protected void doDirectoryChanged(PropertyChangeEvent e) {
 553         super.doDirectoryChanged(e);
 554 
 555         JFileChooser fc = getFileChooser();
 556         FileSystemView fsv = fc.getFileSystemView();
 557         File currentDirectory = fc.getCurrentDirectory();
 558 
 559         if (!readOnly && currentDirectory != null) {
 560             getNewFolderAction().setEnabled(filePane.canWrite(currentDirectory));
 561         }
 562 
 563         if (currentDirectory != null) {
 564             JComponent cb = getDirectoryComboBox();
 565             if (cb instanceof JComboBox) {
 566                 ComboBoxModel<?> model = ((JComboBox)cb).getModel();
 567                 if (model instanceof DirectoryComboBoxModel) {
 568                     ((DirectoryComboBoxModel)model).addItem(currentDirectory);
 569                 }
 570             }
 571 
 572             if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
 573                 if (fsv.isFileSystem(currentDirectory)) {
 574                     setFileName(currentDirectory.getPath());
 575                 } else {
 576                     setFileName(null);
 577                 }
 578             }
 579         }
 580     }
 581 
 582 
 583     protected void doFileSelectionModeChanged(PropertyChangeEvent e) {
 584         super.doFileSelectionModeChanged(e);
 585 
 586         JFileChooser fc = getFileChooser();