src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java

Print this page




 174         public boolean isDirectorySelected() {
 175             return WindowsFileChooserUI.this.isDirectorySelected();
 176         }
 177 
 178         public File getDirectory() {
 179             return WindowsFileChooserUI.this.getDirectory();
 180         }
 181 
 182         public Action getChangeToParentDirectoryAction() {
 183             return WindowsFileChooserUI.this.getChangeToParentDirectoryAction();
 184         }
 185 
 186         public Action getApproveSelectionAction() {
 187             return WindowsFileChooserUI.this.getApproveSelectionAction();
 188         }
 189 
 190         public Action getNewFolderAction() {
 191             return WindowsFileChooserUI.this.getNewFolderAction();
 192         }
 193 
 194         public MouseListener createDoubleClickListener(JList list) {
 195             return WindowsFileChooserUI.this.createDoubleClickListener(getFileChooser(),
 196                                                                        list);
 197         }
 198 
 199         public ListSelectionListener createListSelectionListener() {
 200             return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
 201         }
 202     }
 203 
 204     public void installComponents(JFileChooser fc) {
 205         filePane = new FilePane(new WindowsFileChooserUIAccessor());
 206         fc.addPropertyChangeListener(filePane);
 207 
 208         FileSystemView fsv = fc.getFileSystemView();
 209 
 210         fc.setBorder(new EmptyBorder(4, 10, 10, 10));
 211         fc.setLayout(new BorderLayout(8, 8));
 212 
 213         updateUseShellFolder();
 214 


 977 
 978         result.addFocusListener(new FocusAdapter() {
 979             public void focusGained(FocusEvent e) {
 980                 result.getModel().setRollover(true);
 981             }
 982 
 983             public void focusLost(FocusEvent e) {
 984                 result.getModel().setRollover(false);
 985             }
 986         });
 987 
 988         return result;
 989     }
 990 
 991     //
 992     // Renderer for DirectoryComboBox
 993     //
 994     @SuppressWarnings("serial") // Superclass is not serializable across versions
 995     class DirectoryComboBoxRenderer extends DefaultListCellRenderer  {
 996         IndentIcon ii = new IndentIcon();
 997         public Component getListCellRendererComponent(JList list, Object value,
 998                                                       int index, boolean isSelected,
 999                                                       boolean cellHasFocus) {
1000 
1001             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
1002 
1003             if (value == null) {
1004                 setText("");
1005                 return this;
1006             }
1007             File directory = (File)value;
1008             setText(getFileChooser().getName(directory));
1009             Icon icon = getFileChooser().getIcon(directory);
1010             ii.icon = icon;
1011             ii.depth = directoryComboBoxModel.getDepth(index);
1012             setIcon(ii);
1013 
1014             return this;
1015         }
1016     }
1017 


1167             return directories.size();
1168         }
1169 
1170         public File getElementAt(int index) {
1171             return directories.elementAt(index);
1172         }
1173     }
1174 
1175     //
1176     // Renderer for Types ComboBox
1177     //
1178     protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
1179         return new FilterComboBoxRenderer();
1180     }
1181 
1182     /**
1183      * Render different type sizes and styles.
1184      */
1185     @SuppressWarnings("serial") // Superclass is not serializable across versions
1186     public class FilterComboBoxRenderer extends DefaultListCellRenderer {
1187         public Component getListCellRendererComponent(JList list,
1188             Object value, int index, boolean isSelected,
1189             boolean cellHasFocus) {
1190 
1191             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
1192 
1193             if (value != null && value instanceof FileFilter) {
1194                 setText(((FileFilter)value).getDescription());
1195             }
1196 
1197             return this;
1198         }
1199     }
1200 
1201     //
1202     // DataModel for Types Comboxbox
1203     //
1204     protected FilterComboBoxModel createFilterComboBoxModel() {
1205         return new FilterComboBoxModel();
1206     }
1207 




 174         public boolean isDirectorySelected() {
 175             return WindowsFileChooserUI.this.isDirectorySelected();
 176         }
 177 
 178         public File getDirectory() {
 179             return WindowsFileChooserUI.this.getDirectory();
 180         }
 181 
 182         public Action getChangeToParentDirectoryAction() {
 183             return WindowsFileChooserUI.this.getChangeToParentDirectoryAction();
 184         }
 185 
 186         public Action getApproveSelectionAction() {
 187             return WindowsFileChooserUI.this.getApproveSelectionAction();
 188         }
 189 
 190         public Action getNewFolderAction() {
 191             return WindowsFileChooserUI.this.getNewFolderAction();
 192         }
 193 
 194         public MouseListener createDoubleClickListener(JList<?> list) {
 195             return WindowsFileChooserUI.this.createDoubleClickListener(getFileChooser(),
 196                                                                        list);
 197         }
 198 
 199         public ListSelectionListener createListSelectionListener() {
 200             return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
 201         }
 202     }
 203 
 204     public void installComponents(JFileChooser fc) {
 205         filePane = new FilePane(new WindowsFileChooserUIAccessor());
 206         fc.addPropertyChangeListener(filePane);
 207 
 208         FileSystemView fsv = fc.getFileSystemView();
 209 
 210         fc.setBorder(new EmptyBorder(4, 10, 10, 10));
 211         fc.setLayout(new BorderLayout(8, 8));
 212 
 213         updateUseShellFolder();
 214 


 977 
 978         result.addFocusListener(new FocusAdapter() {
 979             public void focusGained(FocusEvent e) {
 980                 result.getModel().setRollover(true);
 981             }
 982 
 983             public void focusLost(FocusEvent e) {
 984                 result.getModel().setRollover(false);
 985             }
 986         });
 987 
 988         return result;
 989     }
 990 
 991     //
 992     // Renderer for DirectoryComboBox
 993     //
 994     @SuppressWarnings("serial") // Superclass is not serializable across versions
 995     class DirectoryComboBoxRenderer extends DefaultListCellRenderer  {
 996         IndentIcon ii = new IndentIcon();
 997         public Component getListCellRendererComponent(JList<?> list, Object value,
 998                                                       int index, boolean isSelected,
 999                                                       boolean cellHasFocus) {
1000 
1001             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
1002 
1003             if (value == null) {
1004                 setText("");
1005                 return this;
1006             }
1007             File directory = (File)value;
1008             setText(getFileChooser().getName(directory));
1009             Icon icon = getFileChooser().getIcon(directory);
1010             ii.icon = icon;
1011             ii.depth = directoryComboBoxModel.getDepth(index);
1012             setIcon(ii);
1013 
1014             return this;
1015         }
1016     }
1017 


1167             return directories.size();
1168         }
1169 
1170         public File getElementAt(int index) {
1171             return directories.elementAt(index);
1172         }
1173     }
1174 
1175     //
1176     // Renderer for Types ComboBox
1177     //
1178     protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
1179         return new FilterComboBoxRenderer();
1180     }
1181 
1182     /**
1183      * Render different type sizes and styles.
1184      */
1185     @SuppressWarnings("serial") // Superclass is not serializable across versions
1186     public class FilterComboBoxRenderer extends DefaultListCellRenderer {
1187         public Component getListCellRendererComponent(JList<?> list,
1188             Object value, int index, boolean isSelected,
1189             boolean cellHasFocus) {
1190 
1191             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
1192 
1193             if (value != null && value instanceof FileFilter) {
1194                 setText(((FileFilter)value).getDescription());
1195             }
1196 
1197             return this;
1198         }
1199     }
1200 
1201     //
1202     // DataModel for Types Comboxbox
1203     //
1204     protected FilterComboBoxModel createFilterComboBoxModel() {
1205         return new FilterComboBoxModel();
1206     }
1207