| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.actions.relation;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
|---|
| 5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 6 |
|
|---|
| 7 | import java.awt.event.ActionEvent;
|
|---|
| 8 | import java.util.ArrayList;
|
|---|
| 9 |
|
|---|
| 10 | import org.openstreetmap.josm.gui.MainApplication;
|
|---|
| 11 | import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask;
|
|---|
| 12 | import org.openstreetmap.josm.tools.ImageProvider;
|
|---|
| 13 |
|
|---|
| 14 | /**
|
|---|
| 15 | * The action for downloading relations with members
|
|---|
| 16 | * @since 17485
|
|---|
| 17 | */
|
|---|
| 18 | public 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 | }
|
|---|