Ignore:
Timestamp:
2012-08-13T00:12:48+02:00 (14 years ago)
Author:
Don-vip
Message:

fix #6733 - File Open dialog incorrectly accepts folder selection

Major rework of how the JFileChooser are created in JOSM

  • Simple need: use DiskAccessAction.createAndOpenFileChooser methods
  • Complex need: use directly the new class JFileChooserManager

Concerning the directory selection for geottaged images, this is still possible via:

  • right-click on GPX layer -> Import Photos
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r5219 r5438  
    7171import org.openstreetmap.josm.gui.preferences.SourceEntry;
    7272import org.openstreetmap.josm.gui.widgets.HtmlPanel;
     73import org.openstreetmap.josm.gui.widgets.JFileChooserManager;
    7374import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    7475import org.openstreetmap.josm.tools.GBC;
     
    522523            final StyleSource s = model.getRow(sel);
    523524
    524             String curDir = Main.pref.get("mappaint.clone-style.lastDirectory", System.getProperty("user.home"));
    525 
    526             String suggestion = curDir + File.separator + s.getFileNamePart();
    527             JFileChooser fc = new JFileChooser();
    528             fc.setSelectedFile(new File(suggestion));
    529 
    530             int answer = fc.showSaveDialog(Main.parent);
    531             if (answer != JFileChooser.APPROVE_OPTION)
     525            JFileChooserManager fcm = new JFileChooserManager(false, "mappaint.clone-style.lastDirectory", System.getProperty("user.home"));
     526            String suggestion = fcm.getInitialDirectory() + File.separator + s.getFileNamePart();
     527            fcm.createFileChooser().getFileChooser().setSelectedFile(new File(suggestion));
     528            JFileChooser fc = fcm.openFileChooser();
     529            if (fc == null)
    532530                return;
    533531
    534             if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir)) {
    535                 Main.pref.put("mappaint.clone-style.lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
    536             }
    537532            File file = fc.getSelectedFile();
    538533
Note: See TracChangeset for help on using the changeset viewer.