Changeset 24905 in osm for applications/editors/josm/plugins/undelete/src/org
- Timestamp:
- 2010-12-29T22:03:57+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/undelete/src/org/openstreetmap/josm/plugins/undelete/Undelete.java
r23189 r24905 26 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 27 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 28 import org.openstreetmap.josm.data.osm.Relation; 29 import org.openstreetmap.josm.data.osm.RelationMember; 28 30 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 29 31 import org.openstreetmap.josm.data.osm.User; … … 33 35 import org.openstreetmap.josm.data.osm.history.HistoryNode; 34 36 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 37 import org.openstreetmap.josm.data.osm.history.HistoryRelation; 35 38 import org.openstreetmap.josm.data.osm.history.HistoryWay; 36 39 import org.openstreetmap.josm.gui.ExtendedDialog; … … 44 47 import org.openstreetmap.josm.tools.Shortcut; 45 48 46 49 /** 50 * // TODO: undelete relation members if necessary 51 */ 47 52 48 53 public class Undelete extends Plugin { … … 79 84 OsmPrimitiveTypesComboBox cbType = new OsmPrimitiveTypesComboBox(); 80 85 cbType.setToolTipText("Choose the OSM object type"); 86 cbType.setSelectedIndex(Main.pref.getInteger("undelete.lasttype", 0)); 81 87 gc.weightx = 1; 82 88 all.add(cbType, gc); … … 111 117 dialog.showDialog(); 112 118 if (dialog.getValue() != 1) return; 119 Main.pref.putInteger("undelete.lasttype", cbType.getSelectedIndex()); 113 120 Main.pref.put("undelete.newlayer", layer.isSelected()); 114 121 Main.pref.putInteger("undelete.osmid", tfId.getOsmId()); … … 210 217 else 211 218 { 212 primitive=new Node();219 primitive=new Relation(); 213 220 hPrimitive1=h.getLatest(); 214 hPrimitive2=h.getLatest(); 221 hPrimitive2=h.getByVersion(h.getNumVersions()-1); 222 223 Relation rel = new Relation(id, (int) hPrimitive1.getVersion()); 224 225 HistoryRelation hRel = (HistoryRelation) hPrimitive2; 226 227 List<RelationMember> members = new ArrayList<RelationMember>(hRel.getNumMembers()); 228 for (org.openstreetmap.josm.data.osm.history.RelationMember m : hRel.getMembers()) { 229 OsmPrimitive p = datas.getPrimitiveById(m.getPrimitiveId(), m.getPrimitiveType()); 230 if (p == null) { 231 switch (m.getPrimitiveType()) { 232 case NODE: p = new Node(m.getPrimitiveId()); break; 233 case WAY: p = new Way(m.getPrimitiveId()); break; 234 case RELATION: p = new Relation(m.getPrimitiveId()); break; 235 } 236 datas.addPrimitive(p); 237 } 238 members.add(new RelationMember(m.getRole(), p)); 239 } 240 241 rel.setMembers(members); 242 243 primitive=rel; 215 244 } 216 245
Note:
See TracChangeset
for help on using the changeset viewer.