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

Last change on this file since 3266 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.2 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 to set the modified flag {@see OsmPrimitive}
18 *
19 *
20 */
21public class ModifiedConflictResolveCommand 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 ModifiedConflictResolveCommand(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("Set the ''modified'' flag for node {0}"); break;
39 case WAY: msg = marktr("Set the ''modified'' flag for way {0}"); break;
40 case RELATION: msg = marktr("Set the ''modified'' flag 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() && conflict.getMy().hasEqualSemanticAttributes(conflict.getTheir())) {
53 conflict.getMy().setModified(conflict.getTheir().isModified());
54 }
55 getLayer().getConflicts().remove(conflict);
56 rememberConflict(conflict);
57 return true;
58 }
59
60 @Override
61 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
62 Collection<OsmPrimitive> added) {
63 modified.add(conflict.getMy());
64 }
65}
Note: See TracBrowser for help on using the repository browser.