Hi all,
In recent weeks I have done some work on a MetalFileChooserUI
implementation, but don't have enough time lately to fix the last few
problems. Lillian mentioned that she has just started looking at this
also, so I thought I would send in my current patch (which is
unfortunately somewhat large) for others to look at and/or work on.
Some notes:
- the patch destroys the current file chooser UI in the
BasicLookAndFeel (the one in the reference implementation doesn't
function on its own either);
- I already committed a FileChooserDemo to the GNU Classpath Swing
demo, and this is useful for testing ('open' and 'save' work for me,
selecting a directory doesn't, multiple selection doesn't);
- a recent regression in the JComboBox implementation makes the
directory selection somewhat flakey;
- there is a bug in the JList implementation that prevents the correct
layout of the files and directories from being used, it was working
previously (for now, I've used the standard list layout);
- this patch fixes most (but not all) of the Mauve tests that I've
written for JFileChooser/BasicFileChooserUI/MetalFileChooserUI.
If there any questions, please ask. Perhaps if the patch works well
enough for others, I can just commit it to CVS and then anyone else
can jump in to help with fixes.
Here is a ChangeLog entry (with some TODOs marked):
2005-11-25 David Gilbert <address@hidden>
* javax/swing/JFileChooser.java
(selectedFiles): Initialise,
(JFileChooser(String)): Delegate to another constructor,
(JFileChooser(String, FileSystemView)): Convert directory to file,
(setSelectedFile): Check for current selection == null,
(getSelectedFiles): Updated API docs,
(setSelectedFiles): Changed order of event generation,
(changeToParentDirectory): Don't check for null parent (reference
implementation doesn't),
(addChoosableFileFilter): Change handling of null filter,
(removeChoosableFileFilter): Handle case where removed filter is also
the current selection,
(setAcceptAllFileFilterUsed): Add or remove accept all filter as
appropriate,
(setFileFilter): Add new filter to choosable filters if necessary,
(accept): Reimplemented,
* javax/swing/plaf/basic/BasicFileChooserUI.java
(ApproveSelectionAction.ApproveSelectionAction): Set action name,
(ApproveSelectionAction.actionPerformed): Call getFileName() rather
than accessing JTextField directly,
(CancelSelectionAction.CancelSelectionAction): Set action name,
(ChangeToParentDirectoryAction.ChangeToParentDirectoryAction): Set
action name,
(DoubleClickListener.mouseClicked): Call setFileName rather than
accessing JTextField directly,
(GoHomeAction.GoHomeAction): Set action name,
(NewFolderAction.NewFolderAction): Set action name,
(SelectionListener.valueChanged): Get list from event,
(UpdateAction.UpdateAction): Set action name to null,
(computerIcon): Removed initialization,
(detailsViewIcon): Likewise,
(directoryIcon): Likewise,
(fileIcon): Likewise,
(floppyDriveIcon): Likewise,
(hardDriveIcon): Likewise,
(homeFolderIcon): Likewise,
(listViewIcon): Likewise,
(upFolderIcon): Likewise,
(fileList): Removed,
(filters): Removed,
(ICON_SIZE): Removed,
(parents): Removed,
(filename): Removed,
(cancel): Removed,
(upFolderButton): Removed,
(newFolderButton): Removed,
(homeFolderButton): Removed,
(approveSelectionAction): New field,
(cancelSelectionAction): New field,
(goHomeAction): New field,
(changeToParentDirectoryAction): New field,
(newFolderAction): New field,
(updateAction): New field,
(BasicFileChooserUI): Do nothing here,
(installUI): Initialise filechooser field,
(createBoxListener): Removed,
(createFilterListener): Removed,
(filterEntries): Removed,
(installComponents): Do nothing here,
(uninstallComponents): Do nothing here,
(installListeners): Removed component specific listeners,
(installIcons): Use Metal icons,
(unintallIcons): Clear icons,
(installStrings): Use fixed strings for text items that aren't
defined
in the UI defaults - should implement localised strings later,
(uninstallStrings): Clear text items,
(createPropertyChangeListener): Return blank listener,
(getFileName): TODO,
(setFileName): TODO,
(rescanCurrentDirectory): Remove call on deleted filelist,
(getApproveButton): Just return field,
(getFileView): Updated API docs,
(getDialogTitle): Reimplemented,
(getApproveButtonText): Reimplemented,
(getNewFolderAction): Create new instance if required,
(getGoHomeAction): Likewise,
(getChangeToParentDirectoryAction): Likewise,
(getApproveSelectionAction): Likewise,
(getCancelSelectionAction): Likewise,
(getUpdateAction): Likewise,
* javax/swing/plaf/metal/MetalFileChooserUI.java
(MetalFileChooserPropertyChangeListener): New class,
(DirectoryComboBoxRenderer): New class,
(FilterComboBoxModel.selectedIndex): Removed field,
(FilterComboBoxModel.selected): New field,
(FilterComboBoxModel.FilterComboBoxModel): Initialise selected field,
(FilterComboBoxModel.propertyChange): Update filter list,
(FilterComboBoxModel.setSelectedItem): Reimplemented,
(FilterComboBoxModel.getSelectedItem): Return selected field,
(FilterComboBoxRenderer.getListCellRendererComponent): Call super,
(MetalFileChooserSelectionListener): New class,
(SingleClickListener): New class TODO,
(directoryLabel): New field,
(directoryComboBox): New field,
(fileLabel): New field,
(fileTextField): New field,
(filterLabel): New field,
(topPanel): New field,
(controls): New field,
(bottomPanel): New field,
(buttonPanel): New field,
(approveButton): New field,
(fileList): New field,
(fileListPanel): New field,
(filterModel): New field,
(MetalFileChooserUI): Initialise panels,
(installUI): TODO,
(uninstallUI): TODO,
(installComponents): Implemented,
(uninstallComponents): Implemented,
(getButtonPanel): Implemented,
(getBottomPanel): Implemented,
(installStrings): Implemented,
(installListeners): Implemented,
(uninstallListeners): Implemented,
(getActionMap): TODO,
(createActionMap): Implemented,
(createList): Implemented,
(createDetailsView): Implemented,
(createListSelectionListener): Implemented,
(getPreferredSize): Implemented badly,
(getMinimumSize): Likewise,
(getMaximumSize): Implemented,
(createPropertyChangeListener): Implemented,
(createDirectoryComboBoxRenderer): Implemented,
(addControlButtons): Implemented,
(removeControlButtons): TODO,
(ensureFileIsVisible): TODO,
(rescanCurrentDirectory): Implemented,
(getFileName): Implemented,
(setFileName): Implemented,
(setDirectorySelected): TODO,
(getDirectoryName): TODO,
(setDirectoryName): TODO,
(valueChanged): TODO,
(getApproveButton): Implemented,
(VerticalMidLayout): New support class,
(ButtonLayout): New support class,
* javax/swing/plaf/metal/MetalLookAndFeel.java
(initClassDefaults): Add 'FileChooserUI' default,
(initComponentDefaults): Added FileChooser icons.
Regards,
Dave