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

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