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

Last change on this file since 1857 was 1766, checked in by stoecker, 15 years ago

fixed i18n issues

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