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

Last change on this file since 5907 was 5816, checked in by stoecker, 11 years ago

javadoc fixes

  • 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;
8import javax.swing.Icon;
9
10import javax.swing.JLabel;
11
12import org.openstreetmap.josm.data.conflict.Conflict;
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 to set the modified flag {@link OsmPrimitive}
19 *
20 *
21 */
22public class ModifiedConflictResolveCommand extends ConflictResolveCommand {
23
24 /** the conflict to resolve */
25 private Conflict<? extends OsmPrimitive> conflict;
26
27 /**
28 * constructor
29 * @param conflict the conflict data set
30 */
31 public ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
32 this.conflict = conflict;
33 }
34
35 @Override
36 public String getDescriptionText() {
37 String msg = "";
38 switch(OsmPrimitiveType.from(conflict.getMy())) {
39 case NODE: msg = marktr("Set the ''modified'' flag for node {0}"); break;
40 case WAY: msg = marktr("Set the ''modified'' flag for way {0}"); break;
41 case RELATION: msg = marktr("Set the ''modified'' flag for relation {0}"); break;
42 }
43 return tr(msg,conflict.getMy().getId());
44 }
45
46 @Override
47 public Icon getDescriptionIcon() {
48 return ImageProvider.get("data", "object");
49 }
50
51 @Override
52 public boolean executeCommand() {
53 super.executeCommand();
54 if (!conflict.getMy().isNew() && conflict.getMy().hasEqualSemanticAttributes(conflict.getTheir())) {
55 conflict.getMy().setModified(conflict.getTheir().isModified());
56 }
57 getLayer().getConflicts().remove(conflict);
58 rememberConflict(conflict);
59 return true;
60 }
61
62 @Override
63 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
64 Collection<OsmPrimitive> added) {
65 modified.add(conflict.getMy());
66 }
67}
Note: See TracBrowser for help on using the repository browser.