| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.gui.dialogs.relation.actions;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 5 |
|
|---|
| 6 | import java.awt.Dialog;
|
|---|
| 7 | import java.awt.event.ActionEvent;
|
|---|
| 8 | import java.awt.event.KeyEvent;
|
|---|
| 9 |
|
|---|
| 10 | import org.openstreetmap.josm.gui.MainApplication;
|
|---|
| 11 | import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask;
|
|---|
| 12 | import org.openstreetmap.josm.tools.ImageProvider;
|
|---|
| 13 | import org.openstreetmap.josm.tools.Shortcut;
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * Download all incomplete members.
|
|---|
| 17 | * @since 9496
|
|---|
| 18 | */
|
|---|
| 19 | public class DownloadIncompleteMembersAction extends AbstractRelationEditorAction {
|
|---|
| 20 | private static final long serialVersionUID = 1L;
|
|---|
| 21 |
|
|---|
| 22 | /**
|
|---|
| 23 | * Constructs a new {@code DownloadIncompleteMembersAction}.
|
|---|
| 24 | * @param editorAccess An interface to access the relation editor contents.
|
|---|
| 25 | * @param actionMapKey action map key
|
|---|
| 26 | */
|
|---|
| 27 | public DownloadIncompleteMembersAction(IRelationEditorActionAccess editorAccess, String actionMapKey) {
|
|---|
| 28 | super(editorAccess, actionMapKey, IRelationEditorUpdateOn.MEMBER_TABLE_CHANGE);
|
|---|
| 29 | Shortcut sc = Shortcut.registerShortcut("relationeditor:downloadincomplete", tr("Relation Editor: Download Members"),
|
|---|
| 30 | KeyEvent.VK_HOME, Shortcut.ALT);
|
|---|
| 31 | sc.setAccelerator(this);
|
|---|
| 32 | sc.setTooltip(this, tr("Download all incomplete members"));
|
|---|
| 33 | new ImageProvider("dialogs/relation", "downloadincomplete").getResource().attachImageIcon(this, true);
|
|---|
| 34 | putValue(NAME, tr("Download members"));
|
|---|
| 35 | updateEnabledState();
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | @Override
|
|---|
| 39 | public void actionPerformed(ActionEvent e) {
|
|---|
| 40 | if (!isEnabled())
|
|---|
| 41 | return;
|
|---|
| 42 | MainApplication.worker.submit(new DownloadRelationMemberTask(
|
|---|
| 43 | getEditor().getRelation(),
|
|---|
| 44 | getMemberTableModel().getIncompleteMemberPrimitives(),
|
|---|
| 45 | getLayer(),
|
|---|
| 46 | (Dialog) getEditor())
|
|---|
| 47 | );
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | @Override
|
|---|
| 51 | protected void updateEnabledState() {
|
|---|
| 52 | setEnabled(getMemberTableModel().hasIncompleteMembers() && canDownload());
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|