source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DownloadSelectedIncompleteMembersAction.java @ 13486

Last change on this file since 13486 was 13486, checked in by Don-vip, 5 months ago

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

File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.relation.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Dialog;
7import java.awt.event.ActionEvent;
8
9import org.openstreetmap.josm.gui.MainApplication;
10import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask;
11import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
12import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
13import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel;
14import org.openstreetmap.josm.gui.layer.OsmDataLayer;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17/**
18 * Download selected incomplete members.
19 * @since 9496
20 */
21public class DownloadSelectedIncompleteMembersAction extends AbstractRelationEditorAction {
22
23    /**
24     * Constructs a new {@code DownloadSelectedIncompleteMembersAction}.
25     * @param memberTable member table
26     * @param memberTableModel member table model
27     * @param actionMapKey action map key
28     * @param layer OSM data layer
29     * @param editor relation editor
30     */
31    public DownloadSelectedIncompleteMembersAction(MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey,
32            OsmDataLayer layer, IRelationEditor editor) {
33        super(memberTable, memberTableModel, actionMapKey, layer, editor);
34        putValue(SHORT_DESCRIPTION, tr("Download selected incomplete members"));
35        new ImageProvider("dialogs/relation", "downloadincompleteselected").getResource().attachImageIcon(this, true);
36        putValue(NAME, tr("Download Members"));
37        updateEnabledState();
38    }
39
40    @Override
41    public void actionPerformed(ActionEvent e) {
42        if (!isEnabled())
43            return;
44        MainApplication.worker.submit(new DownloadRelationMemberTask(
45                editor.getRelation(),
46                memberTableModel.getSelectedIncompleteMemberPrimitives(),
47                layer,
48                (Dialog) editor)
49        );
50    }
51
52    @Override
53    protected void updateEnabledState() {
54        setEnabled(memberTableModel.hasIncompleteSelectedMembers() && canDownload());
55    }
56}
Note: See TracBrowser for help on using the repository browser.