Changeset 11091 in josm
- Timestamp:
- 2016-10-07T21:13:12+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r10791 r11091 19 19 import java.util.HashSet; 20 20 import java.util.List; 21 import java.util.Objects; 21 22 import java.util.Set; 23 import java.util.stream.Collectors; 22 24 23 25 import javax.swing.AbstractAction; … … 47 49 import org.openstreetmap.josm.data.osm.Changeset; 48 50 import org.openstreetmap.josm.data.osm.ChangesetCache; 51 import org.openstreetmap.josm.data.osm.ChangesetDataSet; 52 import org.openstreetmap.josm.data.osm.PrimitiveId; 53 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 49 54 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 50 55 import org.openstreetmap.josm.gui.JosmUserIdentityManager; … … 53 58 import org.openstreetmap.josm.gui.help.HelpUtil; 54 59 import org.openstreetmap.josm.gui.io.CloseChangesetTask; 60 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; 55 61 import org.openstreetmap.josm.gui.util.GuiHelper; 56 62 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 59 65 import org.openstreetmap.josm.tools.ImageProvider; 60 66 import org.openstreetmap.josm.tools.InputMapUtils; 67 import org.openstreetmap.josm.tools.StreamUtils; 61 68 import org.openstreetmap.josm.tools.WindowGeometry; 62 69 … … 107 114 private DownloadSelectedChangesetsAction actDownloadSelectedChangesets; 108 115 private DownloadSelectedChangesetContentAction actDownloadSelectedContent; 116 private DownloadSelectedChangesetObjectsAction actDownloadSelectedChangesetObjects; 109 117 private JTable tblChangesets; 110 118 … … 240 248 model.getSelectionModel().addListSelectionListener(actDownloadSelectedContent); 241 249 tb.add(actDownloadSelectedContent); 250 251 // -- download the objects contained in the selected changesets from the OSM server 252 model.getSelectionModel().addListSelectionListener(actDownloadSelectedChangesetObjects); 253 tb.add(actDownloadSelectedChangesetObjects); 242 254 243 255 pnl.add(tb, BorderLayout.CENTER); … … 282 294 actDownloadSelectedChangesets = new DownloadSelectedChangesetsAction(model); 283 295 actDownloadSelectedContent = new DownloadSelectedChangesetContentAction(model); 296 actDownloadSelectedChangesetObjects = new DownloadSelectedChangesetObjectsAction(model); 284 297 285 298 cp.add(buildToolbarPanel(), BorderLayout.NORTH); … … 538 551 } 539 552 553 /** 554 * Downloads the objects contained in the selected changesets from the OSM server 555 */ 556 private class DownloadSelectedChangesetObjectsAction extends AbstractAction implements ListSelectionListener { 557 558 DownloadSelectedChangesetObjectsAction(ChangesetCacheManagerModel model) { 559 putValue(NAME, tr("Download changed objects")); 560 new ImageProvider("downloadprimitive").getResource().attachImageIcon(this); 561 putValue(SHORT_DESCRIPTION, tr("Download the current version of the changed objects in the selected changesets")); 562 updateEnabledState(); 563 } 564 565 @Override 566 public void actionPerformed(ActionEvent e) { 567 if (!GraphicsEnvironment.isHeadless()) { 568 actDownloadSelectedContent.actionPerformed(e); 569 Main.worker.submit(() -> { 570 final List<PrimitiveId> primitiveIds = model.getSelectedChangesets().stream() 571 .map(Changeset::getContent) 572 .filter(Objects::nonNull) 573 .flatMap(content -> StreamUtils.toStream(content::iterator)) 574 .map(ChangesetDataSet.ChangesetDataSetEntry::getPrimitive) 575 .map(HistoryOsmPrimitive::getPrimitiveId) 576 .distinct() 577 .collect(Collectors.toList()); 578 new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null).run(); 579 }); 580 } 581 } 582 583 protected void updateEnabledState() { 584 setEnabled(model.hasSelectedChangesets() && !Main.isOffline(OnlineResource.OSM_API)); 585 } 586 587 @Override 588 public void valueChanged(ListSelectionEvent e) { 589 updateEnabledState(); 590 } 591 } 592 540 593 static class ShowDetailAction extends AbstractAction { 541 594 private final ChangesetCacheManagerModel model; … … 619 672 add(actDownloadSelectedChangesets); 620 673 add(actDownloadSelectedContent); 674 add(actDownloadSelectedChangesetObjects); 621 675 } 622 676 }
Note:
See TracChangeset
for help on using the changeset viewer.