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

Last change on this file since 1728 was 1690, checked in by Gubaer, 15 years ago

new: MultiFetchServerObjectReader using APIs Multi Fetch method
update: now uses Multi Fetch to check for deleted primitives on the server
update: now uses Multi Fetch to update the selected primitives with the state from the server
fixed: cleaned up merging in MergeVisitor
new: conflict resolution dialog; now resolves conflicts due to different visibilities
new: replacement for realEqual() on OsmPrimitive and derived classes; realEqual now @deprecated
fixed: cleaning up OsmReader
fixed: progress indication in OsmApi

File size: 2.2 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;
7
8import javax.swing.JLabel;
9import javax.swing.tree.DefaultMutableTreeNode;
10import javax.swing.tree.MutableTreeNode;
11
12import org.openstreetmap.josm.Main;
13import org.openstreetmap.josm.data.osm.OsmPrimitive;
14import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17/**
18 * Represents a command for resolving a version conflict between two {@see OsmPrimitive}
19 *
20 *
21 */
22public class VersionConflictResolveCommand extends Command {
23
24 private final OsmPrimitive my;
25 private final OsmPrimitive their;
26
27 /**
28 * constructor
29 * @param my my primitive (i.e. the primitive from the local dataset)
30 * @param their their primitive (i.e. the primitive from the server)
31 */
32 public VersionConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
33 this.my = my;
34 this.their = their;
35 }
36
37 @Override
38 public MutableTreeNode description() {
39 return new DefaultMutableTreeNode(
40 new JLabel(
41 tr("Resolve version conflicts for {0} {1}",OsmPrimitiveType.from(my).getLocalizedDisplayNameSingular(), my.id),
42 ImageProvider.get("data", "object"),
43 JLabel.HORIZONTAL
44 )
45 );
46 }
47
48 @Override
49 public boolean executeCommand() {
50 super.executeCommand();
51 my.version = Math.max(my.version, their.version);
52 Main.map.conflictDialog.removeConflictForPrimitive(my);
53 return true;
54 }
55
56 @Override
57 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
58 Collection<OsmPrimitive> added) {
59 modified.add(my);
60 }
61
62 @Override
63 public void undoCommand() {
64 super.undoCommand();
65
66 // restore a conflict if necessary
67 //
68 if (!Main.map.conflictDialog.conflicts.containsKey(my)) {
69 Main.map.conflictDialog.addConflict(my, their);
70 }
71 }
72}
Note: See TracBrowser for help on using the repository browser.