Ticket #23305: 23305-alt.patch
File 23305-alt.patch, 5.1 KB (added by , 9 months ago) |
---|
-
src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
16 16 import java.beans.PropertyChangeEvent; 17 17 import java.beans.PropertyChangeListener; 18 18 import java.util.Collection; 19 import java.util.HashSet; 19 20 import java.util.LinkedList; 20 21 import java.util.List; 21 22 import java.util.Set; … … 45 46 import org.openstreetmap.josm.gui.util.GuiHelper; 46 47 import org.openstreetmap.josm.gui.util.WindowGeometry; 47 48 import org.openstreetmap.josm.gui.widgets.AutoAdjustingSplitPane; 49 import org.openstreetmap.josm.spi.preferences.Config; 48 50 import org.openstreetmap.josm.tools.CheckParameterUtil; 49 51 import org.openstreetmap.josm.tools.ImageProvider; 50 52 import org.openstreetmap.josm.tools.InputMapUtils; … … 516 518 517 519 tagModel.populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues(), false); 518 520 relModel.populate(parentRelations, primitives, false); 519 tagModel.prepareDefaultTagDecisions(false); 521 if (Config.getPref().getBoolean("combine-conflict-precise", true)) { 522 tagModel.prepareDefaultTagDecisions(getResolvableKeys(tagsOfPrimitives.getKeys(), primitives)); 523 } else { 524 tagModel.prepareDefaultTagDecisions(false); 525 } 520 526 relModel.prepareDefaultRelationDecisions(false); 521 527 522 528 if (tagModel.isResolvedCompletely() && relModel.isResolvedCompletely()) { … … 589 595 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(parentRelations, 20)); 590 596 591 597 if (!ConditionalOptionPaneUtil.showConfirmationDialog( 592 "combine_ tags",598 "combine_relation_member", 593 599 MainApplication.getMainFrame(), 594 600 "<html>" + msg + "</html>", 595 601 tr("Combine confirmation"), … … 642 648 return tr("{0} ({1})", key, values); 643 649 } 644 650 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 dialog 654 * @param primitives the collection of primitives 655 * @return the keys which can be resolved using the only available value 656 */ 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 decision 660 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 solve 681 easyKeys.add(key); 682 } 683 } 684 return easyKeys; 685 } 686 645 687 @Override 646 688 public void dispose() { 647 689 setTargetPrimitive(null, false); -
src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java
275 275 /** 276 276 * Prepare the default decisions for the current model 277 277 * @param fireEvent {@code true} to call {@code fireTableDataChanged} (can be a slow operation) 278 * @since 1162 6278 * @since 11627 279 279 */ 280 280 void prepareDefaultTagDecisions(boolean fireEvent) { 281 281 for (MultiValueResolutionDecision decision: decisions.values()) { … … 292 292 } 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 used 297 * @since xxx 298 */ 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 /** 295 312 * Returns the set of keys in conflict. 296 313 * @return the set of keys in conflict. 297 314 * @since 6616