001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.actions.relation; 003 004import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 005import static org.openstreetmap.josm.tools.I18n.tr; 006 007import java.awt.event.ActionEvent; 008import java.util.ArrayList; 009 010import org.openstreetmap.josm.gui.MainApplication; 011import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask; 012import org.openstreetmap.josm.tools.ImageProvider; 013 014/** 015 * The action for downloading relations with members 016 * @since 17485 017 */ 018public class DownloadRelationAction extends AbstractRelationAction { 019 020 /** 021 * Constructs a new <code>DownloadMembersAction</code>. 022 */ 023 public DownloadRelationAction() { 024 putValue(SHORT_DESCRIPTION, tr("Download relation with members")); 025 putValue(NAME, tr("Download with members")); 026 new ImageProvider("dialogs", "downloadincomplete").getResource().attachImageIcon(this, true); 027 setHelpId(ht("/Dialog/RelationList#DownloadRelation")); 028 } 029 030 @Override 031 public void actionPerformed(ActionEvent e) { 032 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) 033 return; 034 MainApplication.worker.submit(new DownloadPrimitivesTask(MainApplication.getLayerManager().getEditLayer(), 035 new ArrayList<>(relations), true)); 036 } 037 038 @Override 039 protected void updateEnabledState() { 040 setEnabled(canDownload()); 041 } 042}