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

Last change on this file since 3262 was 3262, checked in by bastiK, 14 years ago

extended command list dialog; added inspection panel

  • Property svn:eol-style set to native
File size: 2.4 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;
7
8import javax.swing.JLabel;
9
10import org.openstreetmap.josm.data.conflict.Conflict;
11import org.openstreetmap.josm.data.osm.Node;
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
14import org.openstreetmap.josm.tools.ImageProvider;
15
16/**
17 * Represents a the resolution of a conflict between the coordinates of two {@see Node}s
18 *
19 */
20public class CoordinateConflictResolveCommand extends ConflictResolveCommand {
21
22 /** the conflict to resolve */
23 private Conflict<? extends OsmPrimitive> conflict;
24
25 /** the merge decision */
26 private final MergeDecisionType decision;
27
28 /**
29 * constructor
30 *
31 * @param my my node
32 * @param their their node
33 * @param decision the merge decision
34 */
35 public CoordinateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
36 this.conflict = conflict;
37 this.decision = decision;
38 }
39
40 @Override public JLabel getDescription() {
41 return new JLabel(
42 tr("Resolve conflicts in coordinates in {0}",conflict.getMy().getId()),
43 ImageProvider.get("data", "object"),
44 JLabel.HORIZONTAL
45 );
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.