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

Last change on this file since 8855 was 8510, checked in by Don-vip, 9 years ago

checkstyle: enable relevant whitespace checks and fix them

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command.conflict;
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 the resolution of a conflict between the modified flag of two {@link OsmPrimitive}s.
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
67 @Override
68 public int hashCode() {
69 final int prime = 31;
70 int result = super.hashCode();
71 result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
72 return result;
73 }
74
75 @Override
76 public boolean equals(Object obj) {
77 if (this == obj)
78 return true;
79 if (!super.equals(obj))
80 return false;
81 if (getClass() != obj.getClass())
82 return false;
83 ModifiedConflictResolveCommand other = (ModifiedConflictResolveCommand) obj;
84 if (conflict == null) {
85 if (other.conflict != null)
86 return false;
87 } else if (!conflict.equals(other.conflict))
88 return false;
89 return true;
90 }
91}
Note: See TracBrowser for help on using the repository browser.