Changeset 16461 in josm for trunk/src/org
- Timestamp:
- 2020-05-19T06:32:38+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
r16436 r16461 42 42 import org.openstreetmap.josm.data.osm.OsmPrimitive; 43 43 import org.openstreetmap.josm.data.osm.PrimitiveId; 44 import org.openstreetmap.josm.data.osm.history.History;45 import org.openstreetmap.josm.data.osm.history.HistoryDataSet;46 44 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 47 45 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 49 47 import org.openstreetmap.josm.gui.help.HelpUtil; 50 48 import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager; 51 import org.openstreetmap.josm.gui.history.HistoryLoadTask;52 49 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; 53 50 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 54 51 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 55 import org.openstreetmap.josm.gui.util.GuiHelper;56 52 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 57 53 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 58 54 import org.openstreetmap.josm.tools.ImageProvider; 59 import org.openstreetmap.josm.tools.JosmRuntimeException;60 55 import org.openstreetmap.josm.tools.Utils; 61 import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;62 56 63 57 /** … … 231 225 class ShowHistoryAction extends AbstractAction implements ListSelectionListener { 232 226 233 private final class ShowHistoryTask implements Runnable {234 private final Collection<HistoryOsmPrimitive> primitives;235 236 private ShowHistoryTask(Collection<HistoryOsmPrimitive> primitives) {237 this.primitives = primitives;238 }239 240 @Override241 public void run() {242 try {243 for (HistoryOsmPrimitive p : primitives) {244 final History h = HistoryDataSet.getInstance().getHistory(p.getPrimitiveId());245 if (h == null) {246 continue;247 }248 GuiHelper.runInEDT(() -> HistoryBrowserDialogManager.getInstance().show(h));249 }250 } catch (final JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {251 GuiHelper.runInEDT(() -> BugReportExceptionHandler.handleException(e));252 }253 }254 }255 256 227 ShowHistoryAction() { 257 228 putValue(NAME, tr("Show history")); … … 261 232 } 262 233 263 protected List<HistoryOsmPrimitive> filterPrimitivesWithUnloadedHistory(Collection<HistoryOsmPrimitive> primitives) {264 return primitives.stream()265 .filter(p -> HistoryDataSet.getInstance().getHistory(p.getPrimitiveId()) == null)266 .collect(Collectors.toList());267 }268 269 public void showHistory(final Collection<HistoryOsmPrimitive> primitives) {270 271 List<HistoryOsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(primitives);272 if (!toLoad.isEmpty()) {273 HistoryLoadTask task = new HistoryLoadTask(ChangesetContentPanel.this);274 for (HistoryOsmPrimitive p: toLoad) {275 task.add(p);276 }277 MainApplication.worker.submit(task);278 }279 280 MainApplication.worker.submit(new ShowHistoryTask(primitives));281 }282 234 283 235 protected final void updateEnabledState() { … … 289 241 Set<HistoryOsmPrimitive> selected = getSelectedPrimitives(); 290 242 if (selected.isEmpty()) return; 291 showHistory(selected);243 HistoryBrowserDialogManager.getInstance().showHistory(selected); 292 244 } 293 245 -
trunk/src/org/openstreetmap/josm/gui/history/ShowHistoryAction.java
r16460 r16461 52 52 static class DoubleClickAdapter extends MouseAdapter { 53 53 private final Function<MouseEvent, PrimitiveId> primitiveIdFunction; 54 private final ShowHistoryAction showHistoryAction = new ShowHistoryAction();55 54 56 55 DoubleClickAdapter(Function<MouseEvent, PrimitiveId> primitiveIdFunction) { … … 65 64 if (pid == null || pid.isNew()) 66 65 return; 67 showHistoryAction.setPrimitiveId(pid); 68 showHistoryAction.run(); 66 HistoryBrowserDialogManager.getInstance().showHistory(Collections.singleton(pid)); 69 67 } 70 68 }
Note:
See TracChangeset
for help on using the changeset viewer.