- Timestamp:
- 2024-03-28T09:29:34+01:00 (8 months ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/conflict/tags
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r18988 r19022 17 17 import java.beans.PropertyChangeListener; 18 18 import java.util.Collection; 19 import java.util.HashSet;20 19 import java.util.LinkedList; 21 20 import java.util.List; … … 47 46 import org.openstreetmap.josm.gui.util.WindowGeometry; 48 47 import org.openstreetmap.josm.gui.widgets.AutoAdjustingSplitPane; 49 import org.openstreetmap.josm.spi.preferences.Config;50 48 import org.openstreetmap.josm.tools.CheckParameterUtil; 51 49 import org.openstreetmap.josm.tools.ImageProvider; … … 519 517 tagModel.populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues(), false); 520 518 relModel.populate(parentRelations, primitives, false); 521 if (Config.getPref().getBoolean("combine-conflict-precise", true)) { 522 tagModel.prepareDefaultTagDecisions(getResolvableKeys(tagsOfPrimitives.getKeys(), primitives)); 523 } else { 524 tagModel.prepareDefaultTagDecisions(false); 525 } 519 tagModel.prepareDefaultTagDecisions(false); 526 520 relModel.prepareDefaultRelationDecisions(false); 527 521 … … 649 643 } 650 644 651 /**652 * See #23305: Find those tag keys for which no conflict exists.653 * @param keysToDecide the keys of tags which might be shown in the conflict dialog654 * @param primitives the collection of primitives655 * @return the keys which can be resolved using the only available value656 */657 private static Set<String> getResolvableKeys(Set<String> keysToDecide, Collection<? extends OsmPrimitive> primitives) {658 Set<String> easyKeys = new HashSet<>();659 // determine the number of objects which have any of the tags which require a decision660 int countTagged = 0;661 for (OsmPrimitive p : primitives) {662 for (String key : keysToDecide) {663 if (p.hasTag(key)) {664 ++countTagged;665 break;666 }667 }668 }669 for (String key : keysToDecide) {670 Set<String> values = new HashSet<>();671 int num = 0;672 for (OsmPrimitive p : primitives) {673 String val = p.get(key);674 if (val != null) {675 num++;676 values.add(val);677 }678 }679 if (values.size() == 1 && num == countTagged) {680 // there is only one value and all tagged objects have that value -> easy to solve681 easyKeys.add(key);682 }683 }684 return easyKeys;685 }686 687 645 @Override 688 646 public void dispose() { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java
r19002 r19022 293 293 294 294 /** 295 * Prepare the default decisions for the current model.296 * @param decidedKeys set of tag keys for which the first value should be used297 * @since 18988298 */299 public void prepareDefaultTagDecisions(Set<String> decidedKeys) {300 for (MultiValueResolutionDecision decision : decisions.values()) {301 if (!decidedKeys.contains(decision.getKey()))302 continue;303 List<String> values = decision.getValues();304 if (!values.isEmpty()) {305 decision.keepOne(values.iterator().next());306 }307 }308 rebuild(false);309 }310 311 /**312 295 * Returns the set of keys in conflict. 313 296 * @return the set of keys in conflict.
Note:
See TracChangeset
for help on using the changeset viewer.