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

Last change on this file since 14027 was 14027, checked in by michael2402, 5 months ago

See #16388: New mechanism for plugins to register relation editor actions.

File size: 1.9 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.tools.ImageProvider;
12
13/**
14 * Download selected incomplete members.
15 * @since 9496
16 */
17public class DownloadSelectedIncompleteMembersAction extends AbstractRelationEditorAction {
18        private static final long serialVersionUID = 1L;
19
20    /**
21     * Constructs a new {@code DownloadSelectedIncompleteMembersAction}.
22     * @param memberTable member table
23     * @param memberTableModel member table model
24     * @param actionMapKey action map key
25     * @param layer OSM data layer
26     * @param editor relation editor
27     */
28    public DownloadSelectedIncompleteMembersAction(IRelationEditorActionAccess editorAccess) {
29        super(editorAccess, IRelationEditorUpdateOn.MEMBER_TABLE_CHANGE, IRelationEditorUpdateOn.MEMBER_TABLE_SELECTION);
30        putValue(SHORT_DESCRIPTION, tr("Download selected incomplete members"));
31        new ImageProvider("dialogs/relation", "downloadincompleteselected").getResource().attachImageIcon(this, true);
32        putValue(NAME, tr("Download members"));
33        updateEnabledState();
34    }
35
36    @Override
37    public void actionPerformed(ActionEvent e) {
38        if (!isEnabled())
39            return;
40        MainApplication.worker.submit(new DownloadRelationMemberTask(
41                        getEditor().getRelation(),
42                getMemberTableModel().getSelectedIncompleteMemberPrimitives(),
43                getLayer(),
44                (Dialog) getEditor())
45        );
46    }
47
48    @Override
49    protected void updateEnabledState() {
50        setEnabled(getMemberTableModel().hasIncompleteSelectedMembers() && canDownload());
51    }
52}
Note: See TracBrowser for help on using the repository browser.