Ignore:
Timestamp:
2012-03-29T23:22:07+02:00 (12 years ago)
Author:
simon04
Message:

fix #7513 - Warn non-experts when combining ways with conflicting tags or ways being part of relations

File:
1 edited

Legend:

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

    r4982 r5132  
    4343import org.openstreetmap.josm.data.osm.Way;
    4444import org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog;
    45 import org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil;
    4645import org.openstreetmap.josm.tools.Geometry;
    4746import org.openstreetmap.josm.tools.Pair;
     
    538537        }
    539538
    540         if (ways.size() < 2)
     539        if (ways.size() < 2) {
    541540            return true;
    542 
    543         //mostly copied from CombineWayAction.java.
     541        }
     542
    544543        TagCollection wayTags = TagCollection.unionOfAllPrimitives(ways);
    545         TagCollection completeWayTags = new TagCollection(wayTags);
    546         TagConflictResolutionUtil.combineTigerTags(completeWayTags);
    547         TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing(completeWayTags, ways);
    548         TagCollection tagsToEdit = new TagCollection(completeWayTags);
    549         TagConflictResolutionUtil.completeTagCollectionForEditing(tagsToEdit);
    550 
    551         CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance();
    552         dialog.getTagConflictResolverModel().populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues());
    553         dialog.setTargetPrimitive(ways.get(0));
    554         Collection<Relation> parentRelations = CombineWayAction.getParentRelations(ways);
    555         parentRelations = filterOwnMultipolygonRelations(parentRelations, polygons);
    556         dialog.getRelationMemberConflictResolverModel().populate(
    557                 parentRelations,
    558                 ways
    559         );
    560         dialog.prepareDefaultDecisions();
    561 
    562         // resolve tag conflicts if necessary
    563         //
    564         if (!completeWayTags.isApplicableToPrimitive() || !parentRelations.isEmpty()) {
    565             dialog.setVisible(true);
    566             if (dialog.isCanceled())
    567                 return false;
    568         }
    569 
    570         for (Way way : ways) {
    571             dialog.setTargetPrimitive(way);
    572             cmds.addAll(dialog.buildResolutionCommands());
    573         }
    574 
    575         commitCommands(marktr("Fix tag conflicts"));
    576         return true;
     544        try {
     545            cmds.addAll(CombinePrimitiveResolverDialog.launchIfNecessary(wayTags, ways, ways));
     546            commitCommands(marktr("Fix tag conflicts"));
     547            return true;
     548        } catch (UserCancelException ex) {
     549            return false;
     550        }
    577551    }
    578552
     
    12091183        Set<Way> processedInnerWays = new LinkedHashSet<Way>();
    12101184
    1211         for (Relation r : CombineWayAction.getParentRelations(selectedWays)) {
     1185        for (Relation r : OsmPrimitive.getParentRelations(selectedWays)) {
    12121186            if (r.isDeleted() || !r.isMultipolygon()) {
    12131187                continue;
Note: See TracChangeset for help on using the changeset viewer.