- Timestamp:
- 2010-02-07T22:54:58+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r2915 r2949 34 34 */ 35 35 public class ConflictCollection implements Iterable<Conflict<?>>{ 36 private ArrayList<Conflict<?>> conflicts;36 private final List<Conflict<?>> conflicts; 37 37 private CopyOnWriteArrayList<IConflictListener> listeners; 38 38 … … 313 313 return size() == 0; 314 314 } 315 316 @Override 317 public String toString() { 318 return conflicts.toString(); 319 } 315 320 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r2945 r2949 20 20 import javax.swing.ComboBoxModel; 21 21 import javax.swing.DefaultListSelectionModel; 22 import javax.swing.JOptionPane; 22 23 import javax.swing.table.DefaultTableModel; 23 24 import javax.swing.table.TableModel; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.data.osm.PrimitiveId; 24 28 25 29 /** … … 60 64 public static final String FROZEN_PROP = ListMergeModel.class.getName() + ".frozen"; 61 65 66 private static final int MAX_DELETED_PRIMITIVE_IN_DIALOG = 5; 67 62 68 protected HashMap<ListRole, ArrayList<T>> entries; 63 69 … … 104 110 */ 105 111 protected abstract void setValueAt(DefaultTableModel model, Object value, int row, int col); 112 113 /** 114 * 115 * @param entry 116 * @return Primitive from my dataset referenced by entry 117 */ 118 protected abstract OsmPrimitive getMyPrimitive(T entry); 106 119 107 120 protected void buildMyEntriesTableModel() { … … 300 313 List<T> newItems = new ArrayList<T>(rows.length); 301 314 List<T> source = entries.get(sourceRole); 315 List<PrimitiveId> deletedIds = new ArrayList<PrimitiveId>(); 302 316 for (int row: rows) { 303 T clone = cloneEntryForMergedList(source.get(row)); 304 if (clone != null) { 317 T entry = source.get(row); 318 OsmPrimitive primitive = getMyPrimitive(entry); 319 if (!primitive.isDeleted()) { 320 T clone = cloneEntryForMergedList(entry); 305 321 newItems.add(clone); 322 } else { 323 deletedIds.add(primitive.getPrimitiveId()); 306 324 } 307 325 } 308 326 getMergedEntries().addAll(position, newItems); 309 327 fireModelDataChanged(); 328 if (!deletedIds.isEmpty()) { 329 List<String> items = new ArrayList<String>(); 330 for (int i=0; i<Math.min(MAX_DELETED_PRIMITIVE_IN_DIALOG, deletedIds.size()); i++) { 331 items.add(deletedIds.get(i).toString()); 332 } 333 if (deletedIds.size() > MAX_DELETED_PRIMITIVE_IN_DIALOG) { 334 items.add(tr("{0} more...", deletedIds.size() - MAX_DELETED_PRIMITIVE_IN_DIALOG)); 335 } 336 JOptionPane.showMessageDialog(null, tr("Following primitives could not be added because they are deleted: {0}", items)); 337 } 310 338 } 311 339 312 340 public void copyAll(ListRole source) { 313 341 getMergedEntries().clear(); 314 getMergedEntries().addAll(entries.get(source)); 315 fireModelDataChanged(); 342 343 int[] rows = new int[entries.get(source).size()]; 344 for (int i=0; i<rows.length; i++) { 345 rows[i] = i; 346 } 347 copy(source, rows, 0); 316 348 } 317 349 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java
r2882 r2949 6 6 import java.util.ArrayList; 7 7 8 import javax.swing.JOptionPane;9 8 import javax.swing.table.DefaultTableModel; 10 9 … … 12 11 import org.openstreetmap.josm.data.osm.DataSet; 13 12 import org.openstreetmap.josm.data.osm.Node; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 14 import org.openstreetmap.josm.data.osm.Way; 15 import org.openstreetmap.josm.gui.DefaultNameFormatter;16 15 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 17 16 import org.openstreetmap.josm.gui.conflict.pair.ListRole; … … 89 88 @Override 90 89 protected Node cloneEntryForMergedList(Node entry) { 91 Node node = (Node) myDataset.getPrimitiveById(entry); 92 if (node.isDeleted()) { 93 JOptionPane.showMessageDialog(null, tr("Node {0} cannot be added to the way because it was deleted", node.getDisplayName(DefaultNameFormatter.getInstance()))); 94 return null; 95 } else 96 return node; 90 return (Node) getMyPrimitive(entry); 97 91 } 92 93 @Override 94 protected OsmPrimitive getMyPrimitive(Node entry) { 95 return myDataset.getPrimitiveById(entry); 96 } 97 98 98 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
r2882 r2949 6 6 import java.util.List; 7 7 8 import javax.swing.JOptionPane;9 8 import javax.swing.table.DefaultTableModel; 10 9 … … 14 13 import org.openstreetmap.josm.data.osm.Relation; 15 14 import org.openstreetmap.josm.data.osm.RelationMember; 16 import org.openstreetmap.josm.gui.DefaultNameFormatter;17 15 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 18 16 import org.openstreetmap.josm.gui.conflict.pair.ListRole; … … 98 96 @Override 99 97 protected RelationMember cloneEntryForMergedList(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 deleted.", 104 primitive.getDisplayName(DefaultNameFormatter.getInstance()))); 105 return null; 106 } else 107 return new RelationMember(entry.getRole(), primitive); 98 OsmPrimitive primitive = getMyPrimitive(entry); 99 return new RelationMember(entry.getRole(), primitive); 100 } 101 102 @Override 103 protected OsmPrimitive getMyPrimitive(RelationMember entry) { 104 return myDataset.getPrimitiveById(entry.getMember()); 108 105 } 109 106
Note:
See TracChangeset
for help on using the changeset viewer.