source: josm/trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java@ 6113

Last change on this file since 6113 was 5816, checked in by stoecker, 11 years ago

javadoc fixes

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7import javax.swing.Icon;
8
9import org.openstreetmap.josm.data.conflict.Conflict;
10import org.openstreetmap.josm.data.osm.Node;
11import org.openstreetmap.josm.data.osm.OsmPrimitive;
12import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
13import org.openstreetmap.josm.tools.ImageProvider;
14
15/**
16 * Represents a the resolution of a conflict between the coordinates of two {@link Node}s
17 *
18 */
19public class CoordinateConflictResolveCommand extends ConflictResolveCommand {
20
21 /** the conflict to resolve */
22 private Conflict<? extends OsmPrimitive> conflict;
23
24 /** the merge decision */
25 private final MergeDecisionType decision;
26
27 /**
28 * constructor for coordinate conflict
29 *
30 * @param conflict the conflict data set
31 * @param decision the merge decision
32 */
33 public CoordinateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
34 this.conflict = conflict;
35 this.decision = decision;
36 }
37
38 @Override
39 public String getDescriptionText() {
40 return tr("Resolve conflicts in coordinates in {0}", conflict.getMy().getId());
41 }
42
43 @Override
44 public Icon getDescriptionIcon() {
45 return ImageProvider.get("data", "object");
46 }
47
48 @Override
49 public boolean executeCommand() {
50 // remember the current state of modified primitives, i.e. of
51 // OSM primitive 'my'
52 //
53 super.executeCommand();
54
55 if (decision.equals(MergeDecisionType.KEEP_MINE)) {
56 // do nothing
57 } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
58 Node my = (Node)conflict.getMy();
59 Node their = (Node)conflict.getTheir();
60 my.setCoor(their.getCoor());
61 } else
62 // should not happen
63 throw new IllegalStateException(tr("Cannot resolve undecided conflict."));
64
65 // remember the layer this command was applied to
66 //
67 rememberConflict(conflict);
68
69 return true;
70 }
71
72 @Override
73 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
74 Collection<OsmPrimitive> added) {
75 modified.add(conflict.getMy());
76 }
77}
Note: See TracBrowser for help on using the repository browser.