source: josm/trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java@ 2171

Last change on this file since 2171 was 2070, checked in by Gubaer, 15 years ago

new: rewrite of CombineWay action
new: conflict resolution dialog for CombineWay, including conflicts for different relation memberships
cleanup: cleanup in OsmReader, reduces memory footprint and reduces parsing time
cleanup: made most of the public fields in OsmPrimitive @deprecated, added accessors and changed the code
cleanup: replaced usages of @deprecated constructors for ExtendedDialog
fixed #3208: Combine ways brokes relation order

WARNING: this changeset touches a lot of code all over the code base. "latest" might become slightly unstable in the next days. Also experience incompatibility issues with plugins in the next few days.

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.marktr;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.util.Collection;
8
9import javax.swing.JLabel;
10import javax.swing.tree.DefaultMutableTreeNode;
11import javax.swing.tree.MutableTreeNode;
12
13import org.openstreetmap.josm.data.conflict.Conflict;
14import org.openstreetmap.josm.data.osm.OsmPrimitive;
15import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
16import org.openstreetmap.josm.tools.ImageProvider;
17
18/**
19 * Represents a command for resolving a version conflict between two {@see OsmPrimitive}
20 *
21 *
22 */
23public class VersionConflictResolveCommand extends ConflictResolveCommand {
24
25 /** the conflict to resolve */
26 private Conflict<OsmPrimitive> conflict;
27
28 /**
29 * constructor
30 * @param my my primitive (i.e. the primitive from the local dataset)
31 * @param their their primitive (i.e. the primitive from the server)
32 */
33 public VersionConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
34 conflict = new Conflict<OsmPrimitive>(my, their);
35 }
36
37 @Override
38 public MutableTreeNode description() {
39 String msg = "";
40 switch(OsmPrimitiveType.from(conflict.getMy())) {
41 case NODE: msg = marktr("Resolve version conflicts for node {0}"); break;
42 case WAY: msg = marktr("Resolve version conflicts for way {0}"); break;
43 case RELATION: msg = marktr("Resolve version conflicts for relation {0}"); break;
44 }
45 return new DefaultMutableTreeNode(
46 new JLabel(
47 tr(msg,conflict.getMy().getId()),
48 ImageProvider.get("data", "object"),
49 JLabel.HORIZONTAL
50 )
51 );
52 }
53
54 @Override
55 public boolean executeCommand() {
56 super.executeCommand();
57 conflict.getMy().setOsmId(
58 conflict.getMy().getId(),
59 (int)Math.max(conflict.getMy().getVersion(), conflict.getTheir().getVersion())
60 );
61 getLayer().getConflicts().remove(conflict);
62 rememberConflict(conflict);
63 return true;
64 }
65
66 @Override
67 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
68 Collection<OsmPrimitive> added) {
69 modified.add(conflict.getMy());
70 }
71}
Note: See TracBrowser for help on using the repository browser.