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

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