Changeset 17251 in josm


Ignore:
Timestamp:
2020-10-22T11:30:37+02:00 (5 weeks ago)
Author:
GerdP
Message:

fix #19375 Avoid to download changesets contents twice

  • check if changeset is closed and content is already known
  • simplify code
File:
1 edited

Legend:

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

    r17250 r17251  
    5050import org.openstreetmap.josm.data.osm.Changeset;
    5151import org.openstreetmap.josm.data.osm.ChangesetCache;
    52 import org.openstreetmap.josm.data.osm.ChangesetDataSet;
    5352import org.openstreetmap.josm.data.osm.PrimitiveId;
    54 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    5553import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    5654import org.openstreetmap.josm.gui.MainApplication;
     
    7169import org.openstreetmap.josm.tools.InputMapUtils;
    7270import org.openstreetmap.josm.tools.Logging;
    73 import org.openstreetmap.josm.tools.StreamUtils;
    7471
    7572/**
     
    584581        public void actionPerformed(ActionEvent e) {
    585582            if (!GraphicsEnvironment.isHeadless()) {
    586                 actDownloadSelectedContent.actionPerformed(e);
     583                if (model.getSelectedChangesets().stream().anyMatch(cs -> !cs.hasContent() || cs.isOpen()))
     584                    actDownloadSelectedContent.actionPerformed(e);
    587585                MainApplication.worker.submit(() -> {
    588586                    final List<PrimitiveId> primitiveIds = model.getSelectedChangesets().stream()
    589587                            .map(Changeset::getContent)
    590588                            .filter(Objects::nonNull)
    591                             .flatMap(content -> StreamUtils.toStream(content::iterator))
    592                             .map(ChangesetDataSet.ChangesetDataSetEntry::getPrimitive)
    593                             .map(HistoryOsmPrimitive::getPrimitiveId)
     589                            .flatMap(content -> content.getIds().stream())
    594590                            .distinct()
    595591                            .collect(Collectors.toList());
Note: See TracChangeset for help on using the changeset viewer.