Ignore:
Timestamp:
2017-08-12T18:23:06+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] #josm15142

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SortPTStopsAction.java

    r33446 r33492  
    5555    public void actionPerformed(ActionEvent e) {
    5656
    57         Relation rel = (Relation) getLayerManager().getEditDataSet().getSelected().iterator().next();
    58 
    59         if (rel.hasIncompleteMembers()) {
    60             if (JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(Main.parent,
    61                 tr("The relation has incomplete members. Do you want to download them and continue with the sorting?"),
    62                 tr("Incomplete Members"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
    63                 null, null, null)) {
    64 
    65                 List<Relation> incomplete = Collections.singletonList(rel);
    66                 Future<?> future = Main.worker.submit(new DownloadRelationMemberTask(
    67                         incomplete,
    68                         DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(incomplete),
    69                         Main.getLayerManager().getEditLayer()));
    70 
    71                     Main.worker.submit(() -> {
    72                         try {
    73                             future.get();
    74                             continueAfterDownload(rel);
    75                         } catch (InterruptedException | ExecutionException e1) {
    76                              Main.error(e1);
    77                             return;
    78                         }
    79                     });
     57        for (Relation rel : getLayerManager().getEditDataSet().getSelectedRelations()) {
     58            if (rel.hasIncompleteMembers()) {
     59                if (JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(Main.parent,
     60                    tr("The relation has incomplete members. Do you want to download them and continue with the sorting?"),
     61                    tr("Incomplete Members"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
     62                    null, null, null)) {
     63
     64                    List<Relation> incomplete = Collections.singletonList(rel);
     65                    Future<?> future = Main.worker.submit(new DownloadRelationMemberTask(
     66                            incomplete,
     67                            DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(incomplete),
     68                            Main.getLayerManager().getEditLayer()));
     69
     70                        Main.worker.submit(() -> {
     71                            try {
     72                                future.get();
     73                                continueAfterDownload(rel);
     74                            } catch (InterruptedException | ExecutionException e1) {
     75                                 Main.error(e1);
     76                                return;
     77                            }
     78                        });
     79                } else
     80                    return;
    8081            } else
    81                 return;
    82         } else
    83             continueAfterDownload(rel);
     82                continueAfterDownload(rel);
     83        }
    8484    }
    8585
     
    259259    protected void updateEnabledState(
    260260            Collection<? extends OsmPrimitive> selection) {
    261         setEnabled(false);
    262         if (selection == null || selection.size() != 1)
     261        if (selection.isEmpty()) {
     262            setEnabled(false);
    263263            return;
    264         OsmPrimitive selected = selection.iterator().next();
    265         if (selected.getType() == OsmPrimitiveType.RELATION &&
    266                 RouteUtils.isPTRoute((Relation) selected)) {
    267             setEnabled(true);
    268         }
     264        }
     265
     266        for (OsmPrimitive sel : selection) {
     267            if (sel.getType() != OsmPrimitiveType.RELATION || !RouteUtils.isPTRoute((Relation) sel)) {
     268                setEnabled(false);
     269                return;
     270            }
     271        }
     272
     273        setEnabled(true);
    269274    }
    270275}
Note: See TracChangeset for help on using the changeset viewer.