Changeset 35398 in osm for applications
- Timestamp:
- 2020-03-27T15:42:18+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/undelete
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/undelete/build.xml
r34881 r35398 4 4 <property name="commit.message" value="adapt to core changes (backwards compatible)"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 4763"/>6 <property name="plugin.main.version" value="16205"/> 7 7 8 8 <property name="plugin.author" value="Nakor"/> -
applications/editors/josm/plugins/undelete/src/org/openstreetmap/josm/plugins/undelete/UndeleteAction.java
r35396 r35398 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.awt.event.ActionEvent; … … 35 36 import org.openstreetmap.josm.data.osm.history.HistoryWay; 36 37 import org.openstreetmap.josm.gui.MainApplication; 37 import org.openstreetmap.josm.gui.Notification;38 38 import org.openstreetmap.josm.gui.history.HistoryLoadTask; 39 39 import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask; 40 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; 40 41 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 41 42 import org.openstreetmap.josm.gui.util.GuiHelper; … … 58 59 private Set<OsmPrimitive> restored; 59 60 60 private Worker(OsmPrimitive parent, OsmDataLayer layer, List<PrimitiveId> ids, Set<OsmPrimitive> restored) { 61 this.parent = parent; 62 this.layer = layer; 63 this.ids = ids; 64 this.restored = restored != null ? restored : new LinkedHashSet<>(); 65 } 61 private Set<PrimitiveId> missingPrimitives; 62 63 private Worker(OsmPrimitive parent, OsmDataLayer layer, List<PrimitiveId> ids, Set<OsmPrimitive> restored, 64 HistoryLoadTask task) { 65 this.parent = parent; 66 this.layer = layer; 67 this.ids = ids; 68 this.restored = restored; 69 this.missingPrimitives = task.getMissingPrimitives(); 70 } 66 71 67 72 @Override … … 69 74 List<Node> nodes = new ArrayList<>(); 70 75 for (PrimitiveId pid : ids) { 76 if (missingPrimitives == null || missingPrimitives.contains(pid)) { 77 continue; 78 } 79 71 80 OsmPrimitive primitive = layer.data.getPrimitiveById(pid); 72 81 if (primitive == null) { … … 77 86 History h = HistoryDataSet.getInstance().getHistory(id, type); 78 87 79 80 81 82 88 if (h == null) { 89 Logging.warn("Cannot find history for " + type + " " + id); 90 return; 91 } 83 92 84 93 HistoryOsmPrimitive hPrimitive1 = h.getLatest(); … … 186 195 layer.data.addPrimitive(primitive); 187 196 restored.add(primitive); 188 } else {189 final String msg = OsmPrimitiveType.NODE == type190 ? tr("Unable to undelete node {0}. Object has likely been redacted", id)191 : OsmPrimitiveType.WAY == type192 ? tr("Unable to undelete way {0}. Object has likely been redacted", id)193 : OsmPrimitiveType.RELATION == type194 ? tr("Unable to undelete relation {0}. Object has likely been redacted", id)195 : null;196 GuiHelper.runInEDT(() -> new Notification(msg).setIcon(JOptionPane.WARNING_MESSAGE).show());197 Logging.warn(msg);198 197 } 199 198 } … … 215 214 }); 216 215 } 216 if (missingPrimitives != null && !missingPrimitives.isEmpty()) { 217 GuiHelper.runInEDTAndWait(() -> DownloadPrimitivesWithReferrersTask.reportProblemDialog(missingPrimitives, 218 trn("Object could not be undeleted", "Some objects could not be undeleted", missingPrimitives.size()), 219 trn("One object could not be undeleted.<br>", 220 "{0} objects could not be undeleted.<br>", 221 missingPrimitives.size(), 222 missingPrimitives.size()) 223 + tr("The server replied with response code 404.<br>" 224 + "This usually means, the server does not know an object with the requested id. Maybe it was redacted."), 225 tr("missing objects:"), 226 JOptionPane.ERROR_MESSAGE 227 ).showDialog()); 228 229 } 217 230 } 231 218 232 } 219 233 … … 255 269 HistoryLoadTask task = new HistoryLoadTask(); 256 270 task.setChangesetDataNeeded(false); 271 task.setCollectMissing(true); 257 272 for (PrimitiveId id : ids) { 258 273 task.add(id); … … 260 275 261 276 MainApplication.worker.execute(task); 262 MainApplication.worker.submit(new Worker(parent, layer, ids, restored ));277 MainApplication.worker.submit(new Worker(parent, layer, ids, restored, task)); 263 278 } 264 279 }
Note:
See TracChangeset
for help on using the changeset viewer.