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

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

fix #15572 - use ImageProvider attach API for all JOSM actions to ensure proper icon size everywhere

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;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.gui.MainApplication;
11import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask;
12import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
13import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
14import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel;
15import org.openstreetmap.josm.gui.layer.OsmDataLayer;
16import org.openstreetmap.josm.io.OnlineResource;
17import org.openstreetmap.josm.tools.ImageProvider;
18
19/**
20 * Download selected incomplete members.
21 * @since 9496
22 */
23public class DownloadSelectedIncompleteMembersAction extends AbstractRelationEditorAction {
24
25    /**
26     * Constructs a new {@code DownloadSelectedIncompleteMembersAction}.
27     * @param memberTable member table
28     * @param memberTableModel member table model
29     * @param actionMapKey action map key
30     * @param layer OSM data layer
31     * @param editor relation editor
32     */
33    public DownloadSelectedIncompleteMembersAction(MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey,
34            OsmDataLayer layer, IRelationEditor editor) {
35        super(memberTable, memberTableModel, actionMapKey, layer, editor);
36        putValue(SHORT_DESCRIPTION, tr("Download selected incomplete members"));
37        new ImageProvider("dialogs/relation", "downloadincompleteselected").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                editor.getRelation(),
48                memberTableModel.getSelectedIncompleteMemberPrimitives(),
49                layer,
50                (Dialog) editor)
51        );
52    }
53
54    @Override
55    protected void updateEnabledState() {
56        setEnabled(memberTableModel.hasIncompleteSelectedMembers() && !Main.isOffline(OnlineResource.OSM_API));
57    }
58}
Note: See TracBrowser for help on using the repository browser.