source: josm/trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java@ 3486

Last change on this file since 3486 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.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7
8import javax.swing.JLabel;
9
10import org.openstreetmap.josm.data.conflict.Conflict;
11import org.openstreetmap.josm.data.osm.OsmPrimitive;
12import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
13import org.openstreetmap.josm.gui.layer.OsmDataLayer;
14import org.openstreetmap.josm.tools.ImageProvider;
15
16/**
17 * Represents a the resolution of a conflict between the coordinates of two {@see Node}s
18 *
19 */
20public class DeletedStateConflictResolveCommand extends ConflictResolveCommand {
21
22 /** the conflict to resolve */
23 private Conflict<? extends OsmPrimitive> conflict;
24
25 /** the merge decision */
26 private final MergeDecisionType decision;
27
28 /**
29 * constructor
30 *
31 * @param my my node
32 * @param their their node
33 * @param decision the merge decision
34 */
35 public DeletedStateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
36 this.conflict = conflict;
37 this.decision = decision;
38 }
39
40 @Override public JLabel getDescription() {
41 return new JLabel(
42 tr("Resolve conflicts in deleted state in {0}",conflict.getMy().getId()),
43 ImageProvider.get("data", "object"),
44 JLabel.HORIZONTAL
45 );
46 }
47
48 @Override
49 public boolean executeCommand() {
50 // remember the current state of modified primitives, i.e. of
51 // OSM primitive 'my'
52 //
53 super.executeCommand();
54
55 OsmDataLayer layer = getLayer();
56
57 if (decision.equals(MergeDecisionType.KEEP_MINE)) {
58 if (conflict.getMy().isDeleted() || conflict.isMyDeleted()) {
59 // because my was involved in a conflict it my still be referred
60 // to from a way or a relation. Fix this now.
61 //
62 layer.data.unlinkReferencesToPrimitive(conflict.getMy());
63 conflict.getMy().setDeleted(true);
64 }
65 } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
66 if (conflict.getTheir().isDeleted()) {
67 layer.data.unlinkReferencesToPrimitive(conflict.getMy());
68 conflict.getMy().setDeleted(true);
69 } else {
70 conflict.getMy().setDeleted(false);
71 }
72 } else
73 // should not happen
74 throw new IllegalStateException(tr("Cannot resolve undecided conflict."));
75
76 rememberConflict(conflict);
77 return true;
78 }
79
80 @Override
81 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
82 Collection<OsmPrimitive> added) {
83 modified.add(conflict.getMy());
84 modified.addAll(conflict.getMy().getReferrers());
85 }
86}
Note: See TracBrowser for help on using the repository browser.