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

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

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

File size: 2.2 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;
8import java.awt.event.KeyEvent;
9
10import org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.gui.MainApplication;
12import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask;
13import org.openstreetmap.josm.tools.ImageProvider;
14import org.openstreetmap.josm.tools.Shortcut;
15
16/**
17 * Download all incomplete members.
18 * @since 9496
19 */
20public class DownloadIncompleteMembersAction extends AbstractRelationEditorAction {
21        private static final long serialVersionUID = 1L;
22
23    /**
24     * Constructs a new {@code DownloadIncompleteMembersAction}.
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 DownloadIncompleteMembersAction(IRelationEditorActionAccess editorAccess, String actionMapKey) {
32        super(editorAccess, actionMapKey, IRelationEditorUpdateOn.MEMBER_TABLE_CHANGE);
33        Shortcut sc = Shortcut.registerShortcut("relationeditor:downloadincomplete", tr("Relation Editor: Download Members"),
34            KeyEvent.VK_HOME, Shortcut.ALT);
35        sc.setAccelerator(this);
36        putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tr("Download all incomplete members"), sc));
37        new ImageProvider("dialogs/relation", "downloadincomplete").getResource().attachImageIcon(this, true);
38        putValue(NAME, tr("Download members"));
39        updateEnabledState();
40    }
41
42    @Override
43    public void actionPerformed(ActionEvent e) {
44        if (!isEnabled())
45            return;
46        MainApplication.worker.submit(new DownloadRelationMemberTask(
47                        getEditor().getRelation(),
48                getMemberTableModel().getIncompleteMemberPrimitives(),
49                getLayer(),
50                (Dialog) getEditor())
51        );
52    }
53
54    @Override
55    protected void updateEnabledState() {
56        setEnabled(getMemberTableModel().hasIncompleteMembers() && canDownload());
57    }
58}
Note: See TracBrowser for help on using the repository browser.