source: josm/trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java@ 4806

Last change on this file since 4806 was 4191, checked in by stoecker, 13 years ago

remove old debug stuff

  • 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 java.util.List;
8
9import javax.swing.JLabel;
10
11import org.openstreetmap.josm.data.conflict.Conflict;
12import org.openstreetmap.josm.data.osm.Node;
13import org.openstreetmap.josm.data.osm.OsmPrimitive;
14import org.openstreetmap.josm.data.osm.Way;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17/**
18 * Represent a command for resolving conflicts in the node list of two
19 * {@see Way}s.
20 *
21 */
22public class WayNodesConflictResolverCommand extends ConflictResolveCommand {
23 /** the conflict to resolve */
24 private Conflict<Way> conflict;
25
26 /** the list of merged nodes. This becomes the list of news of my way after the
27 * command is executed
28 */
29 private final List<Node> mergedNodeList;
30
31 /**
32 *
33 * @param my my may
34 * @param their their way
35 * @param mergedNodeList the list of merged nodes
36 */
37 @SuppressWarnings("unchecked")
38 public WayNodesConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<Node> mergedNodeList) {
39 this.conflict = (Conflict<Way>) conflict;
40 this.mergedNodeList = mergedNodeList;
41 }
42
43 @Override public JLabel getDescription() {
44 return new JLabel(
45 tr("Resolve conflicts in node list of way {0}", conflict.getMy().getId()),
46 ImageProvider.get("data", "object"),
47 JLabel.HORIZONTAL
48 );
49 }
50
51 @Override
52 public boolean executeCommand() {
53 // remember the current state of 'my' way
54 //
55 super.executeCommand();
56
57 // replace the list of nodes of 'my' way by the list of merged
58 // nodes
59 //
60 for (Node n:mergedNodeList) {
61 if (! getLayer().data.getNodes().contains(n)) {
62 System.out.println(tr("Main dataset does not include node {0}", n.toString()));
63 }
64 }
65 conflict.getMy().setNodes(mergedNodeList);
66 rememberConflict(conflict);
67 return true;
68 }
69
70 @Override
71 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
72 Collection<OsmPrimitive> added) {
73 modified.add(conflict.getMy());
74 }
75}
Note: See TracBrowser for help on using the repository browser.