Changeset 23189 in osm for applications/editors/josm/plugins/undelete/src
- Timestamp:
- 2010-09-15T18:53:09+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/undelete/src/org/openstreetmap/josm/plugins/undelete/Undelete.java
r22291 r23189 50 50 51 51 public Undelete(PluginInformation info) { 52 52 super(info); 53 53 Undelete = MainMenu.add(Main.main.menu.fileMenu, new UndeleteAction()); 54 54 55 55 } 56 57 56 57 58 58 private class UndeleteAction extends JosmAction { 59 59 /** 60 * 61 62 63 60 * 61 */ 62 private static final long serialVersionUID = 1L; 63 public UndeleteAction() { 64 64 super(tr("Undelete object..."), "undelete", tr("Undelete object by id"), Shortcut.registerShortcut("tools:undelete", tr("File: {0}", tr("Undelete object...")), 65 65 KeyEvent.VK_U, Shortcut.GROUP_EDIT, KeyEvent.SHIFT_DOWN_MASK|KeyEvent.ALT_DOWN_MASK), true); … … 117 117 undelete(layer.isSelected(), cbType.getType(), ids, 0); 118 118 } 119 } 120 119 } 120 121 121 /** 122 122 * Download the given primitive. … … 128 128 Main.main.addLayer(tmpLayer); 129 129 } 130 130 131 131 final DataSet datas = tmpLayer.data; 132 132 final OsmDataLayer layer=tmpLayer; 133 133 134 134 HistoryLoadTask task = new HistoryLoadTask(); 135 135 for (long id: ids) … … 138 138 } 139 139 140 141 140 141 142 142 Main.worker.execute(task); 143 143 144 144 Runnable r = new Runnable() { 145 145 public void run() { … … 149 149 150 150 History h = HistoryDataSet.getInstance().getHistory(id, type); 151 151 152 152 OsmPrimitive primitive; 153 153 HistoryOsmPrimitive hPrimitive1=h.getLatest(); 154 154 HistoryOsmPrimitive hPrimitive2; 155 155 156 156 boolean visible=hPrimitive1.isVisible(); 157 157 158 158 if (visible) 159 159 { 160 160 // If the object is not deleted we get the real object 161 161 DownloadPrimitiveTask download=new DownloadPrimitiveTask(new SimplePrimitiveId(id, type), layer); 162 System.out.println(tr("Will get {0}", id)); 162 System.out.println(tr("Will get {0}", id)); 163 163 download.run(); 164 165 166 System.out.println(tr("Looking for {0}", id)); 164 165 166 System.out.println(tr("Looking for {0}", id)); 167 167 primitive=datas.getPrimitiveById(id, type); 168 168 System.out.println(tr("Found {0}", primitive.getId())); … … 178 178 // We get all info from the latest version 179 179 hPrimitive2=hPrimitive1; 180 180 181 181 Node node = new Node(id, (int) hPrimitive1.getVersion()); 182 182 183 183 HistoryNode hNode = (HistoryNode) hPrimitive1; 184 184 node.setCoor(hNode.getCoords()); 185 185 186 186 primitive=node; 187 187 if (parent>0) … … 196 196 hPrimitive2 = h.getByVersion(h.getNumVersions()-1); 197 197 198 199 198 199 200 200 Way way = new Way(id, (int) hPrimitive1.getVersion()); 201 201 202 202 HistoryWay hWay = (HistoryWay) hPrimitive2; 203 203 //System.out.println(tr("Primitive {0} version {1}: {2} nodes", hPrimitive2.getId(), hPrimitive2.getVersion(), hWay.getNumNodes())); 204 204 List<Long> nodeIds = hWay.getNodes(); 205 205 undelete(false, OsmPrimitiveType.NODE, nodeIds, id); 206 206 207 207 primitive=way; 208 208 209 209 } 210 210 else 211 { 211 { 212 212 primitive=new Node(); 213 213 hPrimitive1=h.getLatest(); … … 216 216 217 217 User user = User.createOsmUser(hPrimitive1.getUid(), hPrimitive1.getUser()); 218 218 219 219 primitive.setUser(user); 220 220 221 221 primitive.setKeys(hPrimitive2.getTags()); 222 222 223 223 primitive.put("history", "retrieved using undelete JOSM plugin"); 224 224 225 225 primitive.setModified(true); 226 227 datas.addPrimitive(primitive); 226 227 datas.addPrimitive(primitive); 228 228 } 229 229 230 230 231 231 //HistoryBrowserDialogManager.getInstance().show(h); … … 234 234 { 235 235 Way parentWay=(Way)datas.getPrimitiveById(parent, OsmPrimitiveType.WAY); 236 236 237 237 parentWay.setNodes(nodes); 238 238 } … … 240 240 }; 241 241 Main.worker.submit(r); 242 242 243 243 //if (downloadReferrers) { 244 244 // Main.worker.submit(new DownloadReferrersTask(layer, id, type)); 245 245 //} 246 } 246 } 247 247 }
Note:
See TracChangeset
for help on using the changeset viewer.