Changeset 8215 in josm for trunk


Ignore:
Timestamp:
2015-04-18T11:08:07+02:00 (5 years ago)
Author:
simon04
Message:

fix #10866 - Adjust size check for "Download area too large" warning when only notes are downloaded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r8126 r8215  
    3131import javax.swing.JTabbedPane;
    3232import javax.swing.KeyStroke;
     33import javax.swing.event.ChangeEvent;
     34import javax.swing.event.ChangeListener;
    3335
    3436import org.openstreetmap.josm.Main;
     
    9294        pnl.setLayout(new GridBagLayout());
    9395
     96        final ChangeListener checkboxChangeListener = new ChangeListener() {
     97            @Override
     98            public void stateChanged(ChangeEvent e) {
     99                // size check depends on selected data source
     100                updateSizeCheck();
     101            }
     102        };
     103
    94104        // adding the download tasks
    95105        pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5,5,1,5));
    96106        cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), true);
    97107        cbDownloadOsmData.setToolTipText(tr("Select to download OSM data in the selected download area."));
    98         pnl.add(cbDownloadOsmData,  GBC.std().insets(1,5,1,5));
     108        cbDownloadOsmData.getModel().addChangeListener(checkboxChangeListener);
     109        pnl.add(cbDownloadOsmData, GBC.std().insets(1, 5, 1, 5));
    99110        cbDownloadGpxData = new JCheckBox(tr("Raw GPS data"));
    100111        cbDownloadGpxData.setToolTipText(tr("Select to download GPS traces in the selected download area."));
    101         pnl.add(cbDownloadGpxData,  GBC.std().insets(5,5,1,5));
     112        cbDownloadGpxData.getModel().addChangeListener(checkboxChangeListener);
     113        pnl.add(cbDownloadGpxData, GBC.std().insets(5, 5, 1, 5));
    102114        cbDownloadNotes = new JCheckBox(tr("Notes"));
    103115        cbDownloadNotes.setToolTipText(tr("Select to download notes in the selected download area."));
     116        cbDownloadNotes.getModel().addChangeListener(checkboxChangeListener);
    104117        pnl.add(cbDownloadNotes, GBC.eol().insets(50, 5, 1, 5));
    105118
     
    231244
    232245    private void updateSizeCheck() {
     246        boolean isAreaTooLarge = false;
    233247        if (currentBounds == null) {
    234248            sizeCheck.setText(tr("No area selected yet"));
    235249            sizeCheck.setForeground(Color.darkGray);
    236         } else if (currentBounds.getArea() > Main.pref.getDouble("osm-server.max-request-area", 0.25)) {
     250        } else if (isDownloadNotes() && !isDownloadOsmData() && !isDownloadGpxData()) {
     251            // see max_note_request_area in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     252            isAreaTooLarge = currentBounds.getArea() > Main.pref.getDouble("osm-server.max-request-area-notes", 25);
     253        } else {
     254            // see max_request_area in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     255            isAreaTooLarge = currentBounds.getArea() > Main.pref.getDouble("osm-server.max-request-area", 0.25);
     256        }
     257        if (isAreaTooLarge) {
    237258            sizeCheck.setText(tr("Download area too large; will probably be rejected by server"));
    238259            sizeCheck.setForeground(Color.red);
Note: See TracChangeset for help on using the changeset viewer.