Changeset 30532 in osm for applications/editors/josm/plugins/utilsplugin2/src/org
- Timestamp:
- 2014-07-14T04:18:06+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java
r29769 r30532 54 54 } 55 55 final JLabel label1=new JLabel(tr("Please select one of custom URLs (configured in Preferences)")); 56 final JList list1=new JList(names);56 final JList<String> list1=new JList<>(names); 57 57 final JTextField editField=new JTextField(); 58 58 final JCheckBox check1=new JCheckBox(tr("Ask every time")); -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java
r30177 r30532 8 8 import java.util.Arrays; 9 9 import java.util.Collection; 10 import java.util.Collections; 10 11 import java.util.HashMap; 11 12 import java.util.HashSet; … … 13 14 import java.util.List; 14 15 import java.util.Map; 15 import java.util.Set;16 16 17 17 import javax.swing.JOptionPane; … … 24 24 import org.openstreetmap.josm.command.DeleteCommand; 25 25 import org.openstreetmap.josm.command.MoveCommand; 26 import org.openstreetmap.josm.corrector.UserCancelException; 26 27 import org.openstreetmap.josm.data.coor.LatLon; 27 28 import org.openstreetmap.josm.data.osm.Node; … … 29 30 import org.openstreetmap.josm.data.osm.Relation; 30 31 import org.openstreetmap.josm.data.osm.RelationMember; 31 import org.openstreetmap.josm.data.osm.RelationToChildReference;32 32 import org.openstreetmap.josm.data.osm.TagCollection; 33 33 import org.openstreetmap.josm.data.osm.Way; 34 34 import org.openstreetmap.josm.gui.DefaultNameFormatter; 35 import org.openstreetmap.josm.gui.Notification; 35 36 import org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog; 36 import org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil;37 37 38 38 import edu.princeton.cs.algs4.AssignmentProblem; 39 import org.openstreetmap.josm.gui.Notification;40 import static org.openstreetmap.josm.tools.I18n.tr;41 39 42 40 /** … … 45 43 */ 46 44 public final class ReplaceGeometryUtils { 47 private static final String TITLE = tr("Replace Geometry");48 45 /** 49 46 * Replace new or uploaded object with new object … … 168 165 169 166 // merge tags 170 Collection<Command> tagResolutionCommands = getTagConflictResolutionCommands(subjectNode, referenceObject); 171 if (tagResolutionCommands == null) { 167 try { 168 commands.addAll(getTagConflictResolutionCommands(subjectNode, referenceObject)); 169 } catch (UserCancelException e) { 172 170 // user canceled tag merge dialog 173 171 return null; 174 172 } 175 commands.addAll(tagResolutionCommands);176 173 177 174 // replace sacrificial node in way with node that is being upgraded … … 254 251 255 252 // merge tags 256 Collection<Command> tagResolutionCommands = getTagConflictResolutionCommands(referenceWay, subjectWay); 257 if (tagResolutionCommands == null) { 253 try { 254 commands.addAll(getTagConflictResolutionCommands(referenceWay, subjectWay)); 255 } catch (UserCancelException e) { 258 256 // user canceled tag merge dialog 259 257 return null; 260 258 } 261 commands.addAll(tagResolutionCommands);262 259 263 260 // Prepare a list of nodes that are not used anywhere except in the way … … 452 449 * @param source object tags are merged from 453 450 * @param target object tags are merged to 454 * @return 455 */ 456 protected static List<Command> getTagConflictResolutionCommands(OsmPrimitive source, OsmPrimitive target) { 457 // determine if the same key in each object has different values 458 boolean keysWithMultipleValues; 459 Set<OsmPrimitive> set = new HashSet<OsmPrimitive>(); 460 set.add(source); 461 set.add(target); 462 TagCollection tagCol = TagCollection.unionOfAllPrimitives(set); 463 Set<String> keys = tagCol.getKeysWithMultipleValues(); 464 keysWithMultipleValues = !keys.isEmpty(); 465 451 * @return The list of {@link Command commands} needed to apply resolution actions. 452 * @throws UserCancelException If the user cancelled a dialog. 453 */ 454 protected static List<Command> getTagConflictResolutionCommands(OsmPrimitive source, OsmPrimitive target) throws UserCancelException { 466 455 Collection<OsmPrimitive> primitives = Arrays.asList(source, target); 467 468 Set<RelationToChildReference> relationToNodeReferences = RelationToChildReference.getRelationToChildReferences(primitives);469 470 // build the tag collection471 TagCollection tags = TagCollection.unionOfAllPrimitives(primitives);472 TagConflictResolutionUtil.combineTigerTags(tags);473 TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing(tags, primitives);474 TagCollection tagsToEdit = new TagCollection(tags);475 TagConflictResolutionUtil.completeTagCollectionForEditing(tagsToEdit);476 477 456 // launch a conflict resolution dialog, if necessary 478 CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance(); 479 dialog.getTagConflictResolverModel().populate(tagsToEdit, tags.getKeysWithMultipleValues()); 480 dialog.getRelationMemberConflictResolverModel().populate(relationToNodeReferences); 481 dialog.setTargetPrimitive(target); 482 dialog.prepareDefaultDecisions(); 483 484 // conflict resolution is necessary if there are conflicts in the merged tags 485 // or if both objects have relation memberships 486 if (keysWithMultipleValues || 487 (!RelationToChildReference.getRelationToChildReferences(source).isEmpty() && 488 !RelationToChildReference.getRelationToChildReferences(target).isEmpty())) { 489 dialog.setVisible(true); 490 if (dialog.isCanceled()) { 491 return null; 492 } 493 } 494 return dialog.buildResolutionCommands(); 495 } 496 457 return CombinePrimitiveResolverDialog.launchIfNecessary( 458 TagCollection.unionOfAllPrimitives(primitives), primitives, Collections.singleton(target)); 459 } 497 460 498 461 /**
Note:
See TracChangeset
for help on using the changeset viewer.