Changeset 17206 in josm


Ignore:
Timestamp:
2020-10-15T16:30:03+02:00 (6 days ago)
Author:
GerdP
Message:

fix #19939 Replace ParentRelationLoadingTask by DownloadReferrersTask

  • remove class ParentRelationLoadingTask
  • adapt code to use DownloadReferrersTask instead
Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
1 deleted
2 edited

Legend:

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

    r17174 r17206  
    134134        // just trigger a repaint - the display name of the relation members may have changed
    135135        Collection<RelationMember> sel = getSelectedMembers();
    136         GuiHelper.runInEDT(this::fireTableDataChanged);
     136        GuiHelper.runInEDTAndWait(this::fireTableDataChanged);
    137137        setSelectedMembers(sel);
    138138    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java

    r15678 r17206  
    1010import java.awt.event.MouseAdapter;
    1111import java.awt.event.MouseEvent;
     12import java.util.Collections;
     13import java.util.List;
     14import java.util.stream.Collectors;
    1215
    1316import javax.swing.AbstractAction;
     
    2326import javax.swing.event.ListSelectionListener;
    2427
     28import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask;
     29import org.openstreetmap.josm.data.osm.OsmPrimitive;
     30import org.openstreetmap.josm.data.osm.PrimitiveId;
    2531import org.openstreetmap.josm.data.osm.Relation;
    2632import org.openstreetmap.josm.gui.MainApplication;
    2733import org.openstreetmap.josm.gui.PrimitiveRenderer;
     34import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask;
    2835import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    29 import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
     36import org.openstreetmap.josm.gui.util.GuiHelper;
    3037import org.openstreetmap.josm.tools.ImageProvider;
    3138
     
    118125        @Override
    119126        public void actionPerformed(ActionEvent e) {
    120             boolean full = cbReadFull.isSelected();
    121             final ParentRelationLoadingTask task = new ParentRelationLoadingTask(
    122                     model.getRelation(),
    123                     getLayer(),
    124                     full,
    125                     new PleaseWaitProgressMonitor(tr("Loading parent relations"))
    126             );
    127             task.setContinuation(() -> {
    128                     if (task.isCanceled() || task.hasError())
    129                         return;
    130                     model.populate(task.getParents());
    131                 });
     127            DownloadReferrersTask task = new DownloadReferrersTask(getLayer(), Collections.singleton(model.getRelation()));
    132128            MainApplication.worker.submit(task);
     129            MainApplication.worker.submit(() -> {
     130                if (cbReadFull.isSelected() && !task.getProgressMonitor().isCanceled()) {
     131                    // download all members of parents
     132                    List<PrimitiveId> parentsChildren = model.getRelation().referrers(Relation.class)
     133                            .collect(Collectors.toSet()).stream().flatMap(r -> r.getMemberPrimitives().stream())
     134                            .distinct().map(OsmPrimitive::getPrimitiveId).distinct().collect(Collectors.toList());
     135                    new DownloadPrimitivesTask(getLayer(), parentsChildren, false).run();
     136                }
     137            });
     138            GuiHelper.executeByMainWorkerInEDT(() ->
     139                model.populate(model.getRelation().getReferrers().stream()
     140                        .filter(Relation.class::isInstance)
     141                        .map(Relation.class::cast)
     142                        .collect(Collectors.toList()))
     143                );
    133144        }
    134145
Note: See TracChangeset for help on using the changeset viewer.