Ignore:
Timestamp:
2016-01-17T23:57:57+01:00 (8 years ago)
Author:
simon04
Message:

fix #4996 - Changeset manager: allow to download objects from a changeset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r9520 r9521  
    3636import org.openstreetmap.josm.data.osm.Changeset;
    3737import org.openstreetmap.josm.data.osm.OsmPrimitive;
     38import org.openstreetmap.josm.data.osm.PrimitiveId;
    3839import org.openstreetmap.josm.data.osm.history.History;
    3940import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
     
    4546import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager;
    4647import org.openstreetmap.josm.gui.history.HistoryLoadTask;
     48import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask;
    4749import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4850import org.openstreetmap.josm.gui.util.GuiHelper;
     
    5153import org.openstreetmap.josm.tools.BugReportExceptionHandler;
    5254import org.openstreetmap.josm.tools.ImageProvider;
     55import org.openstreetmap.josm.tools.Utils;
    5356
    5457/**
     
    7073
    7174    private final HeaderPanel pnlHeader = new HeaderPanel();
     75    public DownloadObjectAction actDownloadObjectAction;
    7276
    7377    protected void buildModels() {
     
    7680        actDownloadContentAction = new DownloadChangesetContentAction(this);
    7781        actDownloadContentAction.initProperties();
     82
     83        actDownloadObjectAction = new DownloadObjectAction();
     84        model.getSelectionModel().addListSelectionListener(actDownloadObjectAction);
     85
    7886        actShowHistory = new ShowHistoryAction();
    7987        model.getSelectionModel().addListSelectionListener(actShowHistory);
     
    118126
    119127        tb.add(actDownloadContentAction);
     128        tb.addSeparator();
     129        tb.add(actDownloadObjectAction);
    120130        tb.add(actShowHistory);
     131        tb.addSeparator();
    121132        tb.add(actSelectInCurrentLayerAction);
    122133        tb.add(actZoomInCurrentLayerAction);
     
    190201        ChangesetContentTablePopupMenu() {
    191202            add(actDownloadContentAction);
     203            add(new JSeparator());
     204            add(actDownloadObjectAction);
    192205            add(actShowHistory);
    193206            add(new JSeparator());
     
    280293    }
    281294
     295    class DownloadObjectAction extends AbstractAction implements ListSelectionListener {
     296
     297        DownloadObjectAction() {
     298            putValue(NAME, tr("Download objects"));
     299            putValue(SMALL_ICON, ImageProvider.get("downloadprimitive"));
     300            putValue(SHORT_DESCRIPTION, tr("Download the current version of the selected objects"));
     301            updateEnabledState();
     302        }
     303
     304        @Override
     305        public void actionPerformed(ActionEvent arg0) {
     306            final List<PrimitiveId> primitiveIds = new ArrayList<>(Utils.transform(
     307                    model.getSelectedPrimitives(), new Utils.Function<HistoryOsmPrimitive, PrimitiveId>() {
     308                        @Override
     309                        public PrimitiveId apply(HistoryOsmPrimitive x) {
     310                            return x.getPrimitiveId();
     311                        }
     312                    }));
     313            Main.worker.submit(new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null));
     314        }
     315
     316        protected final void updateEnabledState() {
     317            setEnabled(model.hasSelectedPrimitives());
     318        }
     319
     320        @Override
     321        public void valueChanged(ListSelectionEvent e) {
     322            updateEnabledState();
     323        }
     324    }
     325
    282326    abstract class SelectionBasedAction extends AbstractAction implements ListSelectionListener, EditLayerChangeListener {
    283327
Note: See TracChangeset for help on using the changeset viewer.