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

Last change on this file since 6215 was 5926, checked in by bastiK, 11 years ago

clean up imports

  • Property svn:eol-style set to native
File size: 2.1 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.Icon;
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 {@link 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 conflict the conflict data set
29 */
30 public ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
31 this.conflict = conflict;
32 }
33
34 @Override
35 public String getDescriptionText() {
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 tr(msg,conflict.getMy().getId());
43 }
44
45 @Override
46 public Icon getDescriptionIcon() {
47 return ImageProvider.get("data", "object");
48 }
49
50 @Override
51 public boolean executeCommand() {
52 super.executeCommand();
53 if (!conflict.getMy().isNew() && conflict.getMy().hasEqualSemanticAttributes(conflict.getTheir())) {
54 conflict.getMy().setModified(conflict.getTheir().isModified());
55 }
56 getLayer().getConflicts().remove(conflict);
57 rememberConflict(conflict);
58 return true;
59 }
60
61 @Override
62 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
63 Collection<OsmPrimitive> added) {
64 modified.add(conflict.getMy());
65 }
66}
Note: See TracBrowser for help on using the repository browser.