Changeset 21124 in osm
- Timestamp:
- 2010-05-05T01:40:27+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/undelete/src/org/openstreetmap/josm/plugins/undelete/Undelete.java
r21114 r21124 13 13 import java.util.LinkedList; 14 14 import java.util.ArrayList; 15 import java.util.List; 15 16 16 17 import javax.swing.JCheckBox; … … 42 43 import org.openstreetmap.josm.data.osm.history.HistoryNode; 43 44 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 45 import org.openstreetmap.josm.data.osm.history.HistoryWay; 44 46 import org.openstreetmap.josm.gui.ExtendedDialog; 45 47 import org.openstreetmap.josm.gui.MainMenu; … … 119 121 Main.pref.put("undelete.newlayer", layer.isSelected()); 120 122 Main.pref.putInteger("undelete.osmid", tfId.getOsmId()); 121 undelete(layer.isSelected(), cbType.getType(), tfId.getOsmId()); 123 List<Long> ids=new ArrayList<Long>(); 124 ids.add((long)tfId.getOsmId()); 125 undelete(layer.isSelected(), cbType.getType(), ids, 0); 122 126 } 123 127 } … … 126 130 * Download the given primitive. 127 131 */ 128 public void undelete(boolean newLayer, final OsmPrimitiveType type, final long id) {132 public void undelete(boolean newLayer, final OsmPrimitiveType type, final List<Long> ids, final long parent) { 129 133 OsmDataLayer layer = Main.main.getEditLayer(); 130 134 if ((layer == null) || newLayer) { … … 136 140 137 141 HistoryLoadTask task = new HistoryLoadTask(); 138 task.add (id, type); 142 for (long id: ids) 143 { 144 task.add (id, type); 145 } 146 139 147 140 148 … … 143 151 Runnable r = new Runnable() { 144 152 public void run() { 153 List<Node> nodes=new ArrayList<Node>(); 154 for (long id: ids) 155 { 156 145 157 History h = HistoryDataSet.getInstance().getHistory(id, type); 146 158 147 159 OsmPrimitive primitive; 148 HistoryOsmPrimitive hPrimitive=h.getLatest(); 160 HistoryOsmPrimitive hPrimitive1; 161 HistoryOsmPrimitive hPrimitive2; 149 162 150 163 if (type.equals(OsmPrimitiveType.NODE)) 151 164 { 152 HistoryNode hNode = (HistoryNode) hPrimitive; 153 154 Node node = new Node(id, (int) hNode.getVersion()); 165 // We get all info from the latest version 166 hPrimitive1=h.getLatest(); 167 hPrimitive2=hPrimitive1; 168 169 Node node = new Node(id, (int) hPrimitive1.getVersion()); 170 171 HistoryNode hNode = (HistoryNode) hPrimitive1; 155 172 node.setCoor(hNode.getCoords()); 156 173 157 174 primitive=node; 175 if (parent>0) 176 { 177 nodes.add(node); 178 } 179 } 180 else if (type.equals(OsmPrimitiveType.WAY)) 181 { 182 // We get version and user from the latest version, nodes and tags from n-1 version 183 hPrimitive1 = h.getLatest(); 184 hPrimitive2 = h.getByVersion(h.getNumVersions()-1); 185 186 187 188 Way way = new Way(id, (int) hPrimitive1.getVersion()); 189 190 HistoryWay hWay = (HistoryWay) hPrimitive2; 191 //System.out.println(tr("Primitive {0} version {1}: {2} nodes", hPrimitive2.getId(), hPrimitive2.getVersion(), hWay.getNumNodes())); 192 List<Long> nodeIds = hWay.getNodes(); 193 undelete(false, OsmPrimitiveType.NODE, nodeIds, id); 194 195 primitive=way; 196 158 197 } 159 198 else 160 { primitive=new Node();} 161 162 primitive.setKeys(hPrimitive.getTags()); 163 164 User user = User.createOsmUser(hPrimitive.getUid(), hPrimitive.getUser()); 199 { 200 primitive=new Node(); 201 hPrimitive1=h.getLatest(); 202 hPrimitive2=h.getLatest(); 203 } 204 205 User user = User.createOsmUser(hPrimitive1.getUid(), hPrimitive1.getUser()); 165 206 166 207 primitive.setUser(user); 208 209 primitive.setKeys(hPrimitive2.getTags()); 167 210 168 211 primitive.setModified(true); … … 170 213 datas.addPrimitive(primitive); 171 214 //HistoryBrowserDialogManager.getInstance().show(h); 215 } 216 if ((parent>0) && (type.equals(OsmPrimitiveType.NODE))) 217 { 218 Way parentWay=(Way)datas.getPrimitiveById(parent, OsmPrimitiveType.WAY); 219 220 parentWay.setNodes(nodes); 221 } 172 222 } 173 223 };
Note:
See TracChangeset
for help on using the changeset viewer.