Ticket #20432: 20432-alpha.patch

File 20432-alpha.patch, 2.9 KB (added by GerdP, 2 months ago)

work in progress

  • src/org/openstreetmap/josm/actions/relation/DownloadRelationAction.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.actions.relation;
     3
     4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
     5import static org.openstreetmap.josm.tools.I18n.tr;
     6
     7import java.awt.event.ActionEvent;
     8import java.util.ArrayList;
     9
     10import org.openstreetmap.josm.gui.MainApplication;
     11import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask;
     12import org.openstreetmap.josm.tools.ImageProvider;
     13
     14/**
     15 * The action for downloading relations with members
     16 * @since xxx
     17 */
     18public class DownloadRelationAction extends AbstractRelationAction {
     19
     20    /**
     21     * Constructs a new <code>DownloadMembersAction</code>.
     22     */
     23    public DownloadRelationAction() {
     24        putValue(SHORT_DESCRIPTION, tr("Download relation with members"));
     25        putValue(NAME, tr("Download with members"));
     26        new ImageProvider("dialogs", "downloadincomplete").getResource().attachImageIcon(this, true);
     27        setHelpId(ht("/Dialog/RelationList#DownloadRelation"));
     28    }
     29
     30    @Override
     31    public void actionPerformed(ActionEvent e) {
     32        if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView())
     33            return;
     34        MainApplication.worker.submit(new DownloadPrimitivesTask(MainApplication.getLayerManager().getEditLayer(),
     35                new ArrayList<>(relations), true));
     36    }
     37
     38    @Override
     39    protected void updateEnabledState() {
     40        setEnabled(canDownload());
     41    }
     42}
  • src/org/openstreetmap/josm/gui/dialogs/relation/RelationPopupMenus.java

     
    88
    99import org.openstreetmap.josm.actions.relation.DeleteRelationsAction;
    1010import org.openstreetmap.josm.actions.relation.DownloadMembersAction;
     11import org.openstreetmap.josm.actions.relation.DownloadRelationAction;
    1112import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
    1213import org.openstreetmap.josm.actions.relation.DuplicateRelationAction;
    1314import org.openstreetmap.josm.actions.relation.EditRelationAction;
     
    5758        menu.addAction(new SelectMembersAction(true));
    5859        menu.addSeparator();
    5960
     61        menu.addAction(new DownloadRelationAction());
    6062        menu.addAction(new DownloadMembersAction());
    6163        menu.addAction(new DownloadSelectedIncompleteMembersAction());
    6264