Ignore:
Timestamp:
2014-09-22T22:00:21+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10024 - Add an option in Preferences/Look-and-Feel to use native file-choosing dialogs.
They look nicer but they do not support file filters, so we cannot use them (yet) as default.
Based on patch by Lesath and code review by simon04.
The native dialogs are not used if selection mode is not supported ("files and directories" on all platforms, "directories" on systems other than OS X)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r7434 r7578  
    8989import org.openstreetmap.josm.gui.util.GuiHelper;
    9090import org.openstreetmap.josm.gui.util.TableHelper;
    91 import org.openstreetmap.josm.gui.widgets.JFileChooserManager;
     91import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
     92import org.openstreetmap.josm.gui.widgets.FileChooserManager;
    9293import org.openstreetmap.josm.gui.widgets.JosmTextField;
    9394import org.openstreetmap.josm.io.CachedFile;
     
    701702    }
    702703
    703     private static void prepareFileChooser(String url, JFileChooser fc) {
     704    private static void prepareFileChooser(String url, AbstractFileChooser fc) {
    704705        if (url == null || url.trim().length() == 0) return;
    705706        URL sourceUrl = null;
     
    813814                    return;
    814815                }
    815                 JFileChooserManager fcm = new JFileChooserManager(true)
     816                FileChooserManager fcm = new FileChooserManager(true)
    816817                        .createFileChooser(true, null, Arrays.asList(ff, FileFilterAllFiles.getInstance()), ff, JFileChooser.FILES_ONLY);
    817818                prepareFileChooser(tfURL.getText(), fcm.getFileChooser());
    818                 JFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this));
     819                AbstractFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this));
    819820                if (fc != null) {
    820821                    tfURL.setText(fc.getSelectedFile().toString());
     
    15121513            @Override
    15131514            public void actionPerformed(ActionEvent e) {
    1514                 JFileChooserManager fcm = new JFileChooserManager(true).createFileChooser();
     1515                FileChooserManager fcm = new FileChooserManager(true).createFileChooser();
    15151516                if (!isFile) {
    15161517                    fcm.getFileChooser().setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    15171518                }
    15181519                prepareFileChooser(tfFileName.getText(), fcm.getFileChooser());
    1519                 JFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this));
     1520                AbstractFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this));
    15201521                if (fc != null) {
    15211522                    tfFileName.setText(fc.getSelectedFile().toString());
Note: See TracChangeset for help on using the changeset viewer.