- Timestamp:
- 2007-10-26T09:56:48+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r425 r426 76 76 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 77 77 LinkedList<Way> selectedWays = new LinkedList<Way>(); 78 78 79 79 for (OsmPrimitive osm : selection) 80 80 if (osm instanceof Way) … … 85 85 return; 86 86 } 87 88 // Check whether all ways have identical relationship membership. More 87 88 // Check whether all ways have identical relationship membership. More 89 89 // specifically: If one of the selected ways is a member of relation X 90 90 // in role Y, then all selected ways must be members of X in role Y. 91 92 // FIXME: In a later revision, we should display some sort of conflict 91 92 // FIXME: In a later revision, we should display some sort of conflict 93 93 // dialog like we do for tags, to let the user choose which relations 94 94 // should be kept. 95 95 96 96 // Step 1, iterate over all relations and figure out which of our 97 97 // selected ways are members of a relation. … … 122 122 } 123 123 } 124 125 // Step 2, all values of the backlinks HashMap must now equal the size 126 // of the selection. 124 125 // Complain to the user if the ways don't have equal memberships. 127 126 for (HashSet<Way> waylinks : backlinks.values()) { 128 if (!selectedWays.equals(waylinks)) { 129 JOptionPane.showMessageDialog(Main.parent, tr("The selected ways cannot be combined as they have differing relation memberships.")); 130 return; 127 if (!waylinks.containsAll(selectedWays)) { 128 int option = JOptionPane.showConfirmDialog(Main.parent, 129 tr("The selected ways have differing relation memberships. " 130 + "Do you still want to combine them?"), 131 tr("Combine ways with different memberships?"), 132 JOptionPane.YES_NO_OPTION); 133 if (option == JOptionPane.YES_OPTION) { 134 break; 135 } else { 136 return; 137 } 131 138 } 132 139 } … … 166 173 newWay.nodes.clear(); 167 174 newWay.nodes.addAll(nodeList); 168 175 169 176 // display conflict dialog 170 177 Map<String, JComboBox> components = new HashMap<String, JComboBox>(); … … 181 188 newWay.put(e.getKey(), e.getValue().iterator().next()); 182 189 } 183 190 184 191 if (!components.isEmpty()) { 185 192 int answer = JOptionPane.showConfirmDialog(Main.parent, p, tr("Enter values for all conflicts."), JOptionPane.OK_CANCEL_OPTION); … … 193 200 cmds.add(new DeleteCommand(selectedWays.subList(1, selectedWays.size()))); 194 201 cmds.add(new ChangeCommand(selectedWays.peek(), newWay)); 195 202 196 203 // modify all relations containing the now-deleted ways 197 204 for (Relation r : relationsUsingWays) { 198 205 Relation newRel = new Relation(r); 199 206 newRel.members.clear(); 207 HashSet<String> rolesToReAdd = new HashSet<String>(); 200 208 for (RelationMember rm : r.members) { 201 // only copy member if it is either the first of all the selected 202 // ways (indexOf==0) or not one if the selected ways (indexOf==-1) 203 if (selectedWays.indexOf(rm.member) < 1) { 204 newRel.members.add(new RelationMember(rm)); 205 } 209 // Don't copy the member if it to one of our ways, just keep a 210 // note to re-add it later on. 211 if (selectedWays.contains(rm.member)) { 212 rolesToReAdd.add(rm.role); 213 } else { 214 newRel.members.add(rm); 215 } 216 } 217 for (String role : rolesToReAdd) { 218 newRel.members.add(new RelationMember(role, selectedWays.peek())); 206 219 } 207 220 cmds.add(new ChangeCommand(r, newRel)); … … 224 237 // complain to the user. 225 238 // 4. Profit! 226 239 227 240 HashSet<NodePair> chunkSet = new HashSet<NodePair>(); 228 241 for (Way w : ways) { … … 278 291 return tr("Could not combine ways " 279 292 + "(They could not be merged into a single string of nodes)"); 280 } 281 293 } 294 282 295 return nodeList; 283 296 } -
trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
r369 r426 17 17 */ 18 18 public RelationMember() { }; 19 20 public RelationMember(String role, OsmPrimitive member) { 21 this.role = role; 22 this.member = member; 23 } 19 24 20 25 /**
Note:
See TracChangeset
for help on using the changeset viewer.