Changeset 12527 in josm for trunk


Ignore:
Timestamp:
2017-07-27T23:24:45+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #10838 - add robustness if incomplete ways are selected

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java

    r12031 r12527  
    173173        List<Node> selectedNodes = new ArrayList<>(ds.getSelectedNodes());
    174174        List<Way> selectedWays = new ArrayList<>(ds.getSelectedWays());
     175        selectedWays.removeIf(OsmPrimitive::isIncomplete);
    175176
    176177        try {
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r12463 r12527  
    107107        // remove duplicates, preserving order
    108108        ways = new LinkedHashSet<>(ways);
     109        // remove incomplete ways
     110        ways.removeIf(OsmPrimitive::isIncomplete);
     111        // we need at least two ways
     112        if (ways.size() < 2)
     113            return null;
    109114
    110115        List<DataSet> dataSets = ways.stream().map(Way::getDataSet).distinct().collect(Collectors.toList());
     
    245250        int numWays = 0;
    246251        for (OsmPrimitive osm : selection) {
    247             if (osm instanceof Way) {
    248                 numWays++;
     252            if (osm instanceof Way && !osm.isIncomplete() && ++numWays >= 2) {
     253                break;
    249254            }
    250255        }
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r12131 r12527  
    194194                nodeList.add((Node) p);
    195195            } else if (p instanceof Way) {
    196                 wayDataList.add(new WayData(((Way) p).getNodes()));
     196                if (!p.isIncomplete()) {
     197                    wayDataList.add(new WayData(((Way) p).getNodes()));
     198                }
    197199            } else {
    198200                throw new InvalidUserInputException(tr("Selection must consist only of ways and nodes."));
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r12356 r12527  
    1010import java.util.Collection;
    1111import java.util.Collections;
     12import java.util.LinkedHashSet;
    1213import java.util.LinkedList;
    1314import java.util.List;
     
    113114            return;
    114115
    115         final Collection<Way> sel = ds.getSelectedWays();
     116        final Collection<Way> sel = new LinkedHashSet<>(ds.getSelectedWays());
     117        sel.removeIf(w -> w.isIncomplete());
    116118        if (sel.isEmpty()) {
    117119            new Notification(
     
    163165    @Override
    164166    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    165         setEnabled(selection.stream().anyMatch(Way.class::isInstance));
     167        setEnabled(selection.stream().anyMatch(o -> o instanceof Way && !o.isIncomplete()));
    166168    }
    167169}
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r12386 r12527  
    102102        try {
    103103            List<Way> ways = OsmPrimitive.getFilteredList(ds.getSelected(), Way.class);
     104            ways.removeIf(OsmPrimitive::isIncomplete);
    104105            if (ways.isEmpty()) {
    105106                alertSelectAtLeastOneWay();
Note: See TracChangeset for help on using the changeset viewer.