source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DownloadIncompleteMembersAction.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.4 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.gui.dialogs.relation.IRelationEditor;
14import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
15import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel;
16import org.openstreetmap.josm.gui.layer.OsmDataLayer;
17import org.openstreetmap.josm.tools.ImageProvider;
18import org.openstreetmap.josm.tools.Shortcut;
19
20/**
21 * Download all incomplete members.
22 * @since 9496
23 */
24public class DownloadIncompleteMembersAction extends AbstractRelationEditorAction {
25
26    /**
27     * Constructs a new {@code DownloadIncompleteMembersAction}.
28     * @param memberTable member table
29     * @param memberTableModel member table model
30     * @param actionMapKey action map key
31     * @param layer OSM data layer
32     * @param editor relation editor
33     */
34    public DownloadIncompleteMembersAction(MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey,
35            OsmDataLayer layer, IRelationEditor editor) {
36        super(memberTable, memberTableModel, actionMapKey, layer, editor);
37        Shortcut sc = Shortcut.registerShortcut("relationeditor:downloadincomplete", tr("Relation Editor: Download Members"),
38            KeyEvent.VK_HOME, Shortcut.ALT);
39        sc.setAccelerator(this);
40        putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tr("Download all incomplete members"), sc));
41        new ImageProvider("dialogs/relation", "downloadincomplete").getResource().attachImageIcon(this, true);
42        putValue(NAME, tr("Download Members"));
43        updateEnabledState();
44    }
45
46    @Override
47    public void actionPerformed(ActionEvent e) {
48        if (!isEnabled())
49            return;
50        MainApplication.worker.submit(new DownloadRelationMemberTask(
51                editor.getRelation(),
52                memberTableModel.getIncompleteMemberPrimitives(),
53                layer,
54                (Dialog) editor)
55        );
56    }
57
58    @Override
59    protected void updateEnabledState() {
60        setEnabled(memberTableModel.hasIncompleteMembers() && canDownload());
61    }
62}
Note: See TracBrowser for help on using the repository browser.