Changeset 11318 in josm
- Timestamp:
- 2016-11-26T21:28:20+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java
r10413 r11318 11 11 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.conflict.Conflict; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 15 import org.openstreetmap.josm.data.osm.Relation; … … 19 20 /** 20 21 * Represents the resolution of conflicts in the member list of two {@link Relation}s. 21 * 22 * @since 1631 22 23 */ 23 24 public class RelationMemberConflictResolverCommand extends ConflictResolveCommand { 24 /** my relation */ 25 private final Relation my; 26 /** their relation */ 27 private final Relation their; 28 /** the list of merged nodes. This becomes the list of news of my way after the 29 * command is executed 30 */ 25 /** the conflict to resolve */ 26 private final Conflict<Relation> conflict; 27 /** the list of merged nodes. This becomes the list of news of my way after the command is executed */ 31 28 private final List<RelationMember> mergedMembers; 32 29 33 30 /** 34 * 35 * @param my my relation 36 * @param their their relation 31 * Constructs a new {@code RelationMemberConflictResolverCommand}. 32 * @param conflict the conflict to resolve 37 33 * @param mergedMembers the list of merged relation members 38 34 */ 39 public RelationMemberConflictResolverCommand(Relation my, Relation their, List<RelationMember> mergedMembers) {40 this.my = my;41 this. their = their;35 @SuppressWarnings("unchecked") 36 public RelationMemberConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<RelationMember> mergedMembers) { 37 this.conflict = (Conflict<Relation>) conflict; 42 38 this.mergedMembers = mergedMembers; 43 39 } … … 45 41 @Override 46 42 public String getDescriptionText() { 47 return tr("Resolve conflicts in member list of relation {0}", my.getId());43 return tr("Resolve conflicts in member list of relation {0}", conflict.getMy().getId()); 48 44 } 49 45 … … 61 57 // replace the list of members of 'my' relation by the list of merged members 62 58 // 63 my.setMembers(mergedMembers);59 conflict.getMy().setMembers(mergedMembers); 64 60 65 61 return true; … … 69 65 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, 70 66 Collection<OsmPrimitive> added) { 71 modified.add( my);67 modified.add(conflict.getMy()); 72 68 } 73 69 … … 92 88 // restore a conflict if necessary 93 89 // 94 if (!editLayer.getConflicts().hasConflictForMy( my)) {95 editLayer.getConflicts().add( my, their);90 if (!editLayer.getConflicts().hasConflictForMy(conflict.getMy())) { 91 editLayer.getConflicts().add(conflict); 96 92 } 97 93 } … … 99 95 @Override 100 96 public int hashCode() { 101 return Objects.hash(super.hashCode(), my, their, mergedMembers);97 return Objects.hash(super.hashCode(), conflict, mergedMembers); 102 98 } 103 99 … … 108 104 if (!super.equals(obj)) return false; 109 105 RelationMemberConflictResolverCommand that = (RelationMemberConflictResolverCommand) obj; 110 return Objects.equals(my, that.my) && 111 Objects.equals(their, that.their) && 112 Objects.equals(mergedMembers, that.mergedMembers); 106 return Objects.equals(conflict, that.conflict) && 107 Objects.equals(mergedMembers, that.mergedMembers); 113 108 } 114 109 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java
r10454 r11318 24 24 import org.openstreetmap.josm.data.osm.Relation; 25 25 import org.openstreetmap.josm.data.osm.Way; 26 import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListMergeModel;27 26 import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListMerger; 28 27 import org.openstreetmap.josm.gui.conflict.pair.properties.PropertiesMergeModel; 29 28 import org.openstreetmap.josm.gui.conflict.pair.properties.PropertiesMerger; 30 import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberListMergeModel;31 29 import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberMerger; 32 30 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeModel; … … 46 44 * their primitive</li> 47 45 * </ul> 48 * 46 * @since 1622 49 47 */ 50 48 public class ConflictResolver extends JPanel implements PropertyChangeListener { … … 274 272 275 273 /** 276 * Builds the resolution command(s) for the resolved conflicts in this 277 * ConflictResolver 274 * Builds the resolution command(s) for the resolved conflicts in this ConflictResolver 278 275 * 279 276 * @return the resolution command … … 287 284 commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict)); 288 285 if (my instanceof Way && nodeListMerger.getModel().isFrozen()) { 289 NodeListMergeModel model = (NodeListMergeModel) nodeListMerger.getModel(); 290 commands.add(model.buildResolveCommand(conflict)); 286 commands.add(nodeListMerger.getModel().buildResolveCommand(conflict)); 291 287 } else if (my instanceof Relation && relationMemberMerger.getModel().isFrozen()) { 292 RelationMemberListMergeModel model = (RelationMemberListMergeModel) relationMemberMerger.getModel(); 293 commands.add(model.buildResolveCommand((Relation) my, (Relation) their)); 288 commands.add(relationMemberMerger.getModel().buildResolveCommand(conflict)); 294 289 } 295 290 if (isResolvedCompletely()) { -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r11121 r11318 29 29 30 30 import org.openstreetmap.josm.Main; 31 import org.openstreetmap.josm.command.conflict.ConflictResolveCommand; 32 import org.openstreetmap.josm.data.conflict.Conflict; 31 33 import org.openstreetmap.josm.data.osm.DataSet; 32 34 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 69 71 * A ListMergeModel is used in combination with a {@link ListMerger}. 70 72 * 71 * @param <T> the type of the list entries 73 * @param <T> the type of the list entries 74 * @param <C> the type of conflict resolution command 72 75 * @see ListMerger 73 76 */ 74 public abstract class ListMergeModel<T extends PrimitiveId > extends ChangeNotifier {77 public abstract class ListMergeModel<T extends PrimitiveId, C extends ConflictResolveCommand> extends ChangeNotifier { 75 78 public static final String FROZEN_PROP = ListMergeModel.class.getName() + ".frozen"; 76 79 … … 614 617 } 615 618 616 public ListMergeModel<T> getListMergeModel() { 619 /** 620 * Returns the list merge model. 621 * @return the list merge model 622 */ 623 public ListMergeModel<T, C> getListMergeModel() { 617 624 return ListMergeModel.this; 618 625 } … … 861 868 } 862 869 } 870 871 /** 872 * Builds the command to resolve conflicts in the list. 873 * 874 * @param conflict the conflict data set 875 * @return the command 876 * @throws IllegalStateException if the merge is not yet frozen 877 */ 878 public abstract C buildResolveCommand(Conflict<? extends OsmPrimitive> conflict); 863 879 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r10667 r11318 32 32 33 33 import org.openstreetmap.josm.Main; 34 import org.openstreetmap.josm.command.conflict.ConflictResolveCommand; 34 35 import org.openstreetmap.josm.data.osm.OsmPrimitive; 35 36 import org.openstreetmap.josm.data.osm.PrimitiveId; … … 46 47 * 47 48 * @param <T> the type of the entries 49 * @param <C> the type of conflict resolution command 48 50 * @see ListMergeModel 49 51 * @since 1631 50 52 */ 51 public abstract class ListMerger<T extends PrimitiveId> extends JPanel implements PropertyChangeListener, ChangeListener, IConflictResolver { 53 public abstract class ListMerger<T extends PrimitiveId, C extends ConflictResolveCommand> extends JPanel 54 implements PropertyChangeListener, ChangeListener, IConflictResolver { 52 55 protected OsmPrimitivesTable myEntriesTable; 53 56 protected OsmPrimitivesTable mergedEntriesTable; 54 57 protected OsmPrimitivesTable theirEntriesTable; 55 58 56 protected transient ListMergeModel<T > model;59 protected transient ListMergeModel<T, C> model; 57 60 58 61 private CopyStartLeftAction copyStartLeftAction; … … 406 409 * @param model list merger model 407 410 */ 408 public ListMerger(ListMergeModel<T > model) {411 public ListMerger(ListMergeModel<T, C> model) { 409 412 this.model = model; 410 413 model.addChangeListener(this); … … 861 864 } 862 865 863 public ListMergeModel<T> getModel() { 866 /** 867 * Returns the model. 868 * @return the model 869 */ 870 public ListMergeModel<T, C> getModel() { 864 871 return model; 865 872 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/PairTable.java
r10308 r11318 6 6 import javax.swing.table.TableColumnModel; 7 7 8 import org.openstreetmap.josm.command.conflict.ConflictResolveCommand; 8 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 10 import org.openstreetmap.josm.data.osm.PrimitiveId; … … 14 15 public abstract class PairTable extends OsmPrimitivesTable { 15 16 16 private final transient ListMergeModel<? extends PrimitiveId > model;17 private final transient ListMergeModel<? extends PrimitiveId, ? extends ConflictResolveCommand> model; 17 18 18 19 /** … … 24 25 * @param sm selection model 25 26 */ 26 public PairTable(String name, ListMergeModel<? extends PrimitiveId > model,27 public PairTable(String name, ListMergeModel<? extends PrimitiveId, ? extends ConflictResolveCommand> model, 27 28 OsmPrimitivesTableModel dm, TableColumnModel cm, ListSelectionModel sm) { 28 29 super(dm, cm, sm); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java
r8465 r11318 18 18 import org.openstreetmap.josm.gui.conflict.pair.ListRole; 19 19 20 public class NodeListMergeModel extends ListMergeModel<Node> { 20 /** 21 * The model for merging two lists of way nodess 22 * @since 1622 23 */ 24 public class NodeListMergeModel extends ListMergeModel<Node, WayNodesConflictResolverCommand> { 21 25 22 26 /** … … 49 53 } 50 54 51 /** 52 * Builds the command to resolve conflicts in the node list of a way 53 * 54 * @param conflict the conflict data set 55 * @return the command 56 * @throws IllegalStateException if the merge is not yet frozen 57 */ 55 @Override 58 56 public WayNodesConflictResolverCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 59 57 if (!isFrozen()) -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
r10378 r11318 4 4 import javax.swing.JScrollPane; 5 5 6 import org.openstreetmap.josm.command.conflict.WayNodesConflictResolverCommand; 6 7 import org.openstreetmap.josm.data.conflict.Conflict; 7 8 import org.openstreetmap.josm.data.osm.Node; … … 14 15 * @since 1622 15 16 */ 16 public class NodeListMerger extends ListMerger<Node > {17 public class NodeListMerger extends ListMerger<Node, WayNodesConflictResolverCommand> { 17 18 18 19 /** -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTable.java
r10308 r11318 5 5 6 6 import org.openstreetmap.josm.actions.ZoomToAction; 7 import org.openstreetmap.josm.command.conflict.WayNodesConflictResolverCommand; 7 8 import org.openstreetmap.josm.data.osm.Node; 8 9 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; … … 10 11 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 11 12 13 /** 14 * Node list table. 15 * @since 5297 16 */ 12 17 public class NodeListTable extends PairTable { 13 18 … … 19 24 * @param sm selection model 20 25 */ 21 public NodeListTable(String name, ListMergeModel<Node> model, OsmPrimitivesTableModel dm, ListSelectionModel sm) { 26 public NodeListTable(String name, ListMergeModel<Node, WayNodesConflictResolverCommand> model, 27 OsmPrimitivesTableModel dm, ListSelectionModel sm) { 22 28 super(name, model, dm, new NodeListColumnModel(new NodeListTableCellRenderer()), sm); 23 29 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r10308 r11318 12 12 import javax.swing.table.TableCellRenderer; 13 13 14 import org.openstreetmap.josm.command.conflict.WayNodesConflictResolverCommand; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 16 import org.openstreetmap.josm.gui.DefaultNameFormatter; … … 54 55 * @param isSelected true, if the current row is selected 55 56 */ 56 protected void renderNode(ListMergeModel<Node>.EntriesTableModel model, Node node, int row, boolean isSelected) { 57 protected void renderNode(ListMergeModel<Node, WayNodesConflictResolverCommand>.EntriesTableModel model, Node node, 58 int row, boolean isSelected) { 57 59 setIcon(icon); 58 60 setBorder(null); … … 88 90 * @param row the row index 89 91 */ 90 protected void renderRowId(ListMergeModel<Node >.EntriesTableModel model, int row) {92 protected void renderRowId(ListMergeModel<Node, WayNodesConflictResolverCommand>.EntriesTableModel model, int row) { 91 93 setIcon(null); 92 94 setBorder(rowNumberBorder); … … 130 132 */ 131 133 @SuppressWarnings("unchecked") 132 protected ListMergeModel<Node >.EntriesTableModel getModel(JTable table) {133 return (ListMergeModel<Node >.EntriesTableModel) table.getModel();134 protected ListMergeModel<Node, WayNodesConflictResolverCommand>.EntriesTableModel getModel(JTable table) { 135 return (ListMergeModel<Node, WayNodesConflictResolverCommand>.EntriesTableModel) table.getModel(); 134 136 } 135 137 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
r8510 r11318 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.List;7 6 import java.util.Map; 8 7 … … 10 9 11 10 import org.openstreetmap.josm.command.conflict.RelationMemberConflictResolverCommand; 11 import org.openstreetmap.josm.data.conflict.Conflict; 12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 13 import org.openstreetmap.josm.data.osm.PrimitiveId; … … 17 17 import org.openstreetmap.josm.gui.conflict.pair.ListRole; 18 18 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 19 20 /** 20 21 * The model for merging two lists of relation members 21 * 22 * @since 1631 22 23 */ 23 public class RelationMemberListMergeModel extends ListMergeModel<RelationMember > {24 public class RelationMemberListMergeModel extends ListMergeModel<RelationMember, RelationMemberConflictResolverCommand> { 24 25 25 26 @Override … … 96 97 } 97 98 98 /** 99 * Builds the command to resolve conflicts in the node list of a way 100 * 101 * @param my my relation. Must not be null. 102 * @param their their relation. Must not be null 103 * @return the command 104 * @throws IllegalArgumentException if my is null 105 * @throws IllegalArgumentException if their is null 106 * @throws IllegalStateException if the merge is not yet frozen 107 */ 108 public RelationMemberConflictResolverCommand buildResolveCommand(Relation my, Relation their) { 109 CheckParameterUtil.ensureParameterNotNull(my, "my"); 110 CheckParameterUtil.ensureParameterNotNull(their, "their"); 99 @Override 100 public RelationMemberConflictResolverCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 101 CheckParameterUtil.ensureParameterNotNull(conflict, "conflict"); 111 102 if (!isFrozen()) 112 throw new IllegalArgumentException(tr("Merged nodes not frozen yet. Cannot build resolution command")); 113 List<RelationMember> entries = getMergedEntries(); 114 return new RelationMemberConflictResolverCommand(my, their, entries); 103 throw new IllegalArgumentException(tr("Merged members not frozen yet. Cannot build resolution command")); 104 return new RelationMemberConflictResolverCommand(conflict, getMergedEntries()); 115 105 } 116 106 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
r10378 r11318 4 4 import javax.swing.JScrollPane; 5 5 6 import org.openstreetmap.josm.command.conflict.RelationMemberConflictResolverCommand; 6 7 import org.openstreetmap.josm.data.conflict.Conflict; 7 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 14 15 * @since 1631 15 16 */ 16 public class RelationMemberMerger extends ListMerger<RelationMember > {17 public class RelationMemberMerger extends ListMerger<RelationMember, RelationMemberConflictResolverCommand> { 17 18 18 19 /** -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTable.java
r10308 r11318 5 5 6 6 import org.openstreetmap.josm.actions.ZoomToAction; 7 import org.openstreetmap.josm.command.conflict.RelationMemberConflictResolverCommand; 7 8 import org.openstreetmap.josm.data.osm.RelationMember; 8 9 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; … … 10 11 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 11 12 13 /** 14 * Relation member table. 15 * @since 5297 16 */ 12 17 public class RelationMemberTable extends PairTable { 13 18 … … 19 24 * @param sm selection model 20 25 */ 21 public RelationMemberTable(String name, ListMergeModel<RelationMember> model, OsmPrimitivesTableModel dm, ListSelectionModel sm) { 26 public RelationMemberTable(String name, ListMergeModel<RelationMember, RelationMemberConflictResolverCommand> model, 27 OsmPrimitivesTableModel dm, ListSelectionModel sm) { 22 28 super(name, model, dm, new RelationMemberListColumnModel(), sm); 23 29 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java
r10378 r11318 11 11 import javax.swing.table.TableCellRenderer; 12 12 13 import org.openstreetmap.josm. data.osm.Node;13 import org.openstreetmap.josm.command.conflict.RelationMemberConflictResolverCommand; 14 14 import org.openstreetmap.josm.data.osm.RelationMember; 15 15 import org.openstreetmap.josm.gui.DefaultNameFormatter; … … 20 20 /** 21 21 * This is the {@link TableCellRenderer} used in the tables of {@link RelationMemberMerger}. 22 * 22 * @since 1631 23 23 */ 24 24 public class RelationMemberTableCellRenderer extends JLabel implements TableCellRenderer { … … 45 45 } 46 46 47 protected void renderBackground(ListMergeModel<Node>.EntriesTableModel model, RelationMember member, int row, int col, boolean isSelected) { 47 protected void renderBackground(ListMergeModel<RelationMember, RelationMemberConflictResolverCommand>.EntriesTableModel model, 48 RelationMember member, int row, int col, boolean isSelected) { 48 49 Color bgc = ConflictColors.BGCOLOR.get(); 49 50 if (col == 0) { … … 77 78 } 78 79 79 protected void renderForeground(ListMergeModel<Node>.EntriesTableModel model, RelationMember member, int row, int col, boolean isSelected) { 80 protected void renderForeground(ListMergeModel<RelationMember, RelationMemberConflictResolverCommand>.EntriesTableModel model, 81 RelationMember member, int row, int col, boolean isSelected) { 80 82 Color fgc = ConflictColors.FGCOLOR.get(); 81 83 if (col == 0 && model.isParticipatingInCurrentComparePair() && !model.getListMergeModel().isFrozen()) { … … 146 148 */ 147 149 @SuppressWarnings("unchecked") 148 protected ListMergeModel< Node>.EntriesTableModel getModel(JTable table) {149 return (ListMergeModel< Node>.EntriesTableModel) table.getModel();150 protected ListMergeModel<RelationMember, RelationMemberConflictResolverCommand>.EntriesTableModel getModel(JTable table) { 151 return (ListMergeModel<RelationMember, RelationMemberConflictResolverCommand>.EntriesTableModel) table.getModel(); 150 152 } 151 153 }
Note:
See TracChangeset
for help on using the changeset viewer.