Changeset 18728 in josm for trunk/src


Ignore:
Timestamp:
2023-05-12T14:55:43+02:00 (12 months ago)
Author:
taylor.smock
Message:

Fix #21886: Download Dialog incorrectly reports note area rejection (patch by gaben, modified)

The modifications are as follows:

  • SonarLint fixes
  • Removal of unused code (see r16503)
File:
1 edited

Legend:

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

    r18014 r18728  
    8888                MainApplication.worker.submit(new PostDownloadHandler(task, future));
    8989                if (zoom) {
    90                     tasks.add(new Pair<AbstractDownloadTask<?>, Future<?>>(task, future));
     90                    tasks.add(new Pair<>(task, future));
    9191                }
    9292            } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
     
    212212
    213213            // size check depends on selected data source
    214             checkboxChangeListener = e ->
    215                     dialog.getSelectedDownloadArea().ifPresent(this::updateSizeCheck);
     214            checkboxChangeListener = e -> {
     215                rememberSettings();
     216                dialog.getSelectedDownloadArea().ifPresent(OSMDownloadSourcePanel.this::boundingBoxChanged);
     217            };
    216218
    217219            downloadSourcesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
     
    281283            }
    282284
    283             final Boolean slippyMapShowsDownloadBounds = settings.getSlippyMapBounds()
     285            final boolean slippyMapShowsDownloadBounds = settings.getSlippyMapBounds()
    284286                    .map(b -> b.intersects(settings.getDownloadBounds().get()))
    285287                    .orElse(true);
     
    325327        @Override
    326328        public void boundingBoxChanged(Bounds bbox) {
    327             updateSizeCheck(bbox);
    328         }
    329 
    330         @Override
    331         public String getSimpleName() {
    332             return SIMPLE_NAME;
    333         }
    334 
    335         private void updateSizeCheck(Bounds bbox) {
    336329            if (bbox == null) {
    337330                sizeCheck.setText(tr("No area selected yet"));
     
    341334
    342335            displaySizeCheckResult(DOWNLOAD_SOURCES.stream()
     336                    .filter(IDownloadSourceType::isEnabled)
    343337                    .anyMatch(type -> type.isDownloadAreaTooLarge(bbox)));
     338        }
     339
     340        @Override
     341        public String getSimpleName() {
     342            return SIMPLE_NAME;
    344343        }
    345344
     
    355354    }
    356355
    357     /**
    358      * Encapsulates data that is required to download from the OSM server.
    359      */
    360     static class OSMDownloadData {
    361 
    362         private final List<IDownloadSourceType> downloadPossibilities;
    363 
    364         /**
    365          * Constructs a new {@code OSMDownloadData}.
    366          * @param downloadPossibilities A list of DataDownloadTypes (instantiated, with
    367          *                              options set)
    368          */
    369         OSMDownloadData(List<IDownloadSourceType> downloadPossibilities) {
    370             this.downloadPossibilities = downloadPossibilities;
    371         }
    372 
    373         /**
    374          * Returns the download possibilities.
    375          * @return A list of DataDownloadTypes (instantiated, with options set)
    376          */
    377         public List<IDownloadSourceType> getDownloadPossibilities() {
    378             return downloadPossibilities;
    379         }
    380     }
    381 
    382356    private static class OsmDataDownloadType implements IDownloadSourceType {
    383357        static final BooleanProperty IS_ENABLED = new BooleanProperty("download.osm.data", true);
     
    415389        public boolean isDownloadAreaTooLarge(Bounds bound) {
    416390            // see max_request_area in
    417             // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     391            // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/settings.yml
    418392            return bound.getArea() > Config.getPref().getDouble("osm-server.max-request-area", 0.25);
    419393        }
     
    493467        public boolean isDownloadAreaTooLarge(Bounds bound) {
    494468            // see max_note_request_area in
    495             // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     469            // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/settings.yml
    496470            return bound.getArea() > Config.getPref().getDouble("osm-server.max-request-area-notes", 25);
    497471        }
Note: See TracChangeset for help on using the changeset viewer.