Changeset 2881 in josm for trunk/src/org
- Timestamp:
- 2010-01-23T14:24:03+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java
r2512 r2881 18 18 */ 19 19 public class Conflict<T extends OsmPrimitive> { 20 private T my;21 private T their;20 private final T my; 21 private final T their; 22 22 23 23 public Conflict(T my, T their) { -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r2846 r2881 12 12 import java.beans.PropertyChangeEvent; 13 13 import java.beans.PropertyChangeListener; 14 import java.text.MessageFormat;15 14 import java.util.ArrayList; 16 15 import java.util.HashMap; 16 import java.util.List; 17 17 import java.util.Observable; 18 18 … … 229 229 230 230 protected void copyToTop(ListRole role, int []rows) { 231 if (rows == null || rows.length == 0) 232 return; 233 for (int i = rows.length - 1; i >= 0; i--) { 234 int row = rows[i]; 235 T n = entries.get(role).get(row); 236 entries.get(MERGED_ENTRIES).add(0, cloneEntryForMergedList(n)); 237 } 231 copy(role, rows, 0); 238 232 fireModelDataChanged(); 239 233 mergedEntriesSelectionModel.setSelectionInterval(0, rows.length -1); … … 272 266 273 267 public void copyToEnd(ListRole source, int [] rows) { 274 if (rows == null || rows.length == 0) 275 return; 276 ArrayList<T> mergedEntries = getMergedEntries(); 277 for (int row : rows) { 278 T n = entries.get(source).get(row); 279 mergedEntries.add(cloneEntryForMergedList(n)); 280 } 268 copy(source, rows, getMergedEntriesSize()); 281 269 fireModelDataChanged(); 282 mergedEntriesSelectionModel.setSelectionInterval( mergedEntries.size()-rows.length, mergedEntries.size() -1);270 mergedEntriesSelectionModel.setSelectionInterval(getMergedEntriesSize()-rows.length, getMergedEntriesSize() -1); 283 271 284 272 } … … 306 294 } 307 295 296 private void copy(ListRole sourceRole, int[] rows, int position) { 297 List<T> newItems = new ArrayList<T>(rows.length); 298 List<T> source = entries.get(sourceRole); 299 for (int row: rows) { 300 T clone = cloneEntryForMergedList(source.get(row)); 301 if (clone != null) { 302 newItems.add(clone); 303 } 304 } 305 getMergedEntries().addAll(position, newItems); 306 } 307 308 308 /** 309 309 * Copies the nodes given by indices in rows from the list of nodes <code>source</code> to the … … 317 317 */ 318 318 protected void copyBeforeCurrent(ListRole source, int [] rows, int current) { 319 if (rows == null || rows.length == 0) 320 return; 321 ArrayList<T> mergedEntries = getMergedEntries(); 322 if (current < 0 || current >= mergedEntries.size()) 323 throw new IllegalArgumentException(MessageFormat.format("Parameter current out of range. Got {0}.", current)); 324 for (int i=rows.length -1; i>=0; i--) { 325 int row = rows[i]; 326 T n = entries.get(source).get(row); 327 mergedEntries.add(current, cloneEntryForMergedList(n)); 328 } 319 copy(source, rows, current); 329 320 fireModelDataChanged(); 330 321 mergedEntriesSelectionModel.setSelectionInterval(current, current + rows.length-1); … … 368 359 */ 369 360 protected void copyAfterCurrent(ListRole source, int [] rows, int current) { 370 if (rows == null || rows.length == 0) 371 return; 372 ArrayList<T> mergedEntries = getMergedEntries(); 373 374 if (current < 0 || current >= mergedEntries.size()) 375 throw new IllegalArgumentException(MessageFormat.format("Parameter current out of range. Got {0}.", current)); 376 if (current == mergedEntries.size() -1) { 377 copyToEnd(source, rows); 378 } else { 379 for (int i=rows.length -1; i>=0; i--) { 380 int row = rows[i]; 381 T n = entries.get(source).get(row); 382 mergedEntries.add(current+1, cloneEntryForMergedList(n)); 383 } 384 } 361 copy(source, rows, current + 1); 385 362 fireModelDataChanged(); 386 363 mergedEntriesSelectionModel.setSelectionInterval(current+1, current + rows.length-1); … … 551 528 } 552 529 553 public ListMergeModel getListMergeModel() {530 public ListMergeModel<T> getListMergeModel() { 554 531 return ListMergeModel.this; 555 532 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
r2846 r2881 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.ArrayList; 7 import java.util.logging.Logger; 6 import java.util.List; 8 7 8 import javax.swing.JOptionPane; 9 9 import javax.swing.table.DefaultTableModel; 10 10 11 11 import org.openstreetmap.josm.command.RelationMemberConflictResolverCommand; 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 14 import org.openstreetmap.josm.data.osm.Relation; 13 15 import org.openstreetmap.josm.data.osm.RelationMember; 16 import org.openstreetmap.josm.gui.DefaultNameFormatter; 14 17 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 15 18 import org.openstreetmap.josm.gui.conflict.pair.ListRole; … … 20 23 */ 21 24 public class RelationMemberListMergeModel extends ListMergeModel<RelationMember>{ 25 //private static final Logger logger = Logger.getLogger(RelationMemberListMergeModel.class.getName()); 22 26 23 private static final Logger logger = Logger.getLogger(RelationMemberListMergeModel.class.getName());27 private DataSet myDataset; 24 28 25 29 @Override … … 65 69 */ 66 70 public void populate(Relation my, Relation their) { 71 this.myDataset = my.getDataSet(); 72 67 73 CheckParameterUtil.ensureParameterNotNull(my, "my"); 68 74 CheckParameterUtil.ensureParameterNotNull(their, "their"); … … 92 98 @Override 93 99 protected RelationMember cloneEntryForMergedList(RelationMember entry) { 94 return new RelationMember(entry); 100 OsmPrimitive primitive = myDataset.getPrimitiveById(entry.getMember()); 101 if (primitive.isDeleted()) { 102 JOptionPane.showMessageDialog(null, 103 tr("Primitive {0} cannot be added to the relation because it was removed.", 104 primitive.getDisplayName(DefaultNameFormatter.getInstance()))); 105 return null; 106 } else 107 return new RelationMember(entry.getRole(), primitive); 95 108 } 96 109 … … 110 123 if (! isFrozen()) 111 124 throw new IllegalArgumentException(tr("Merged nodes not frozen yet. Cannot build resolution command")); 112 ArrayList<RelationMember> entries = getMergedEntries();125 List<RelationMember> entries = getMergedEntries(); 113 126 return new RelationMemberConflictResolverCommand(my, their, entries); 114 127 }
Note:
See TracChangeset
for help on using the changeset viewer.