source: josm/trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java@ 13664

Last change on this file since 13664 was 13486, checked in by Don-vip, 6 years ago

fix #8039, see #10456 - fix bugs with non-downloadable layers

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
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.Collection;
9
10import org.openstreetmap.josm.data.osm.OsmPrimitive;
11import org.openstreetmap.josm.gui.MainApplication;
12import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask;
13import org.openstreetmap.josm.tools.ImageProvider;
14import org.openstreetmap.josm.tools.SubclassFilteredCollection;
15
16/**
17 * The action for downloading members of relations
18 * @since 5793
19 */
20public class DownloadMembersAction extends AbstractRelationAction {
21
22 /**
23 * Constructs a new <code>DownloadMembersAction</code>.
24 */
25 public DownloadMembersAction() {
26 putValue(SHORT_DESCRIPTION, tr("Download all members of the selected relations"));
27 putValue(NAME, tr("Download members"));
28 new ImageProvider("dialogs", "downloadincomplete").getResource().attachImageIcon(this, true);
29 putValue("help", ht("/Dialog/RelationList#DownloadMembers"));
30 }
31
32 @Override
33 public void actionPerformed(ActionEvent e) {
34 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return;
35 MainApplication.worker.submit(new DownloadRelationTask(relations, MainApplication.getLayerManager().getEditLayer()));
36 }
37
38 @Override
39 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
40 // selected non-new relations
41 this.relations = SubclassFilteredCollection.filter(getRelations(primitives), r -> !r.isNew());
42 updateEnabledState();
43 }
44
45 @Override
46 protected void updateEnabledState() {
47 setEnabled(canDownload());
48 }
49}
Note: See TracBrowser for help on using the repository browser.