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

Last change on this file since 2612 was 2512, checked in by stoecker, 14 years ago

i18n updated, fixed files to reduce problems when applying patches, fix #4017

File size: 2.5 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 * @param my my may
40 * @param their their way
41 * @param mergedNodeList the list of merged nodes
42 */
43 public WayNodesConflictResolverCommand(Way my, Way their, List<Node> mergedNodeList) {
44 conflict = new Conflict<Way>(my,their);
45 this.mergedNodeList = mergedNodeList;
46 }
47
48 @Override
49 public MutableTreeNode description() {
50 return new DefaultMutableTreeNode(
51 new JLabel(
52 tr("Resolve conflicts in node list of way {0}", conflict.getMy().getId()),
53 ImageProvider.get("data", "object"),
54 JLabel.HORIZONTAL
55 )
56 );
57 }
58
59 @Override
60 public boolean executeCommand() {
61 // remember the current state of 'my' way
62 //
63 super.executeCommand();
64
65 // replace the list of nodes of 'my' way by the list of merged
66 // nodes
67 //
68 for (Node n:mergedNodeList) {
69 if (! getLayer().data.getNodes().contains(n)) {
70 logger.warning(tr("Main dataset does not include node {0}", n.toString()));
71 }
72 }
73 conflict.getMy().setNodes(mergedNodeList);
74 rememberConflict(conflict);
75 return true;
76 }
77
78 @Override
79 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
80 Collection<OsmPrimitive> added) {
81 modified.add(conflict.getMy());
82 }
83}
Note: See TracBrowser for help on using the repository browser.