Ticket #21497: 21497.patch

File 21497.patch, 1.9 KB (added by taylor.smock, 4 years ago)

Add check in OpenFileAction for FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG -- doCreateFileChooser only uses it if the native file chooser also supports the selection mode.

  • src/org/openstreetmap/josm/actions/OpenFileAction.java

    diff --git a/src/org/openstreetmap/josm/actions/OpenFileAction.java b/src/org/openstreetmap/josm/actions/OpenFileAction.java
    index 079cd8af3a..32127a54e6 100644
    a b import org.openstreetmap.josm.gui.io.importexport.FileImporter;  
    4444import org.openstreetmap.josm.gui.io.importexport.Options;
    4545import org.openstreetmap.josm.gui.util.GuiHelper;
    4646import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
     47import org.openstreetmap.josm.gui.widgets.FileChooserManager;
     48import org.openstreetmap.josm.gui.widgets.NativeFileChooser;
    4749import org.openstreetmap.josm.io.OsmTransferException;
    4850import org.openstreetmap.josm.spi.preferences.Config;
    4951import org.openstreetmap.josm.tools.Logging;
    public class OpenFileAction extends DiskAccessAction {  
    7880
    7981    @Override
    8082    public void actionPerformed(ActionEvent e) {
    81         AbstractFileChooser fc = createAndOpenFileChooser(true, true, null, null, JFileChooser.FILES_AND_DIRECTORIES,
    82                 true, null);
     83        final AbstractFileChooser fc;
     84        // If the user explicitly wants native file dialogs, let them use it.
     85        // Rather unfortunately, this means that they will not be able to select files and directories.
     86        if (Boolean.TRUE.equals(FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG.get())
     87                // This is almost redundant, as the JDK currently doesn't support this with (all?) native file choosers.
     88                && !NativeFileChooser.supportsSelectionMode(JFileChooser.FILES_AND_DIRECTORIES)) {
     89            fc = createAndOpenFileChooser(true, true, null);
     90        } else {
     91            fc = createAndOpenFileChooser(true, true, null, null,
     92                    JFileChooser.FILES_AND_DIRECTORIES, true, null);
     93        }
    8394        if (fc == null)
    8495            return;
    8596        File[] files = fc.getSelectedFiles();