Changeset 18314 in josm for trunk/src


Ignore:
Timestamp:
2021-11-07T14:24:15+01:00 (3 years ago)
Author:
Don-vip
Message:

fix #21497 - see #21344 - don't use FILES_AND_DIRECTORIES selection mode if user chose native file dialogs (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java

    r18238 r18314  
    22package org.openstreetmap.josm.actions;
    33
     4import static javax.swing.JFileChooser.FILES_AND_DIRECTORIES;
    45import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    56import static org.openstreetmap.josm.tools.I18n.tr;
     
    2930import java.util.stream.Stream;
    3031
    31 import javax.swing.JFileChooser;
    3232import javax.swing.JOptionPane;
    3333import javax.swing.SwingUtilities;
     
    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;
     
    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 (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(FILES_AND_DIRECTORIES)) {
     89            fc = createAndOpenFileChooser(true, true, null);
     90        } else {
     91            fc = createAndOpenFileChooser(true, true, null, null, FILES_AND_DIRECTORIES, true, null);
     92        }
    8393        if (fc == null)
    8494            return;
Note: See TracChangeset for help on using the changeset viewer.