source: josm/trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java@ 3055

Last change on this file since 3055 was 3034, checked in by jttt, 14 years ago

Fix #4467 Don't silently drop locally deleted member primitives from downloaded ways and relation (fix the issue when deleted primitive is referenced)

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;
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 to set the modified flag {@see OsmPrimitive}
20 *
21 *
22 */
23public class ModifiedConflictResolveCommand extends ConflictResolveCommand {
24
25 /** the conflict to resolve */
26 private Conflict<? extends 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 ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
34 this.conflict = conflict;
35 }
36
37 @Override
38 public MutableTreeNode description() {
39 String msg = "";
40 switch(OsmPrimitiveType.from(conflict.getMy())) {
41 case NODE: msg = marktr("Set the ''modified'' flag for node {0}"); break;
42 case WAY: msg = marktr("Set the ''modified'' flag for way {0}"); break;
43 case RELATION: msg = marktr("Set the ''modified'' flag 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 if (!conflict.getMy().isNew() && conflict.getMy().hasEqualSemanticAttributes(conflict.getTheir())) {
58 conflict.getMy().setModified(conflict.getTheir().isModified());
59 }
60 getLayer().getConflicts().remove(conflict);
61 rememberConflict(conflict);
62 return true;
63 }
64
65 @Override
66 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
67 Collection<OsmPrimitive> added) {
68 modified.add(conflict.getMy());
69 }
70}
Note: See TracBrowser for help on using the repository browser.