source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/RemoveAction.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: 1.7 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.event.ActionEvent;
7import java.awt.event.KeyEvent;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.tools.ImageProvider;
11import org.openstreetmap.josm.tools.Shortcut;
12
13/**
14 * Remove the currently selected members from this relation.
15 * @since 9496
16 */
17public class RemoveAction extends AbstractRelationEditorAction {
18        private static final long serialVersionUID = 1L;
19
20    /**
21     * Constructs a new {@code RemoveAction}.
22     * @param memberTable member table
23     * @param memberTableModel member table model
24     * @param actionMapKey action map key
25     */
26    public RemoveAction(IRelationEditorActionAccess editorAccess, String actionMapKey) {
27        super(editorAccess, actionMapKey, IRelationEditorUpdateOn.MEMBER_TABLE_SELECTION);
28        new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
29        putValue(NAME, tr("Remove"));
30        Shortcut sc = Shortcut.registerShortcut("relationeditor:remove", tr("Relation Editor: Remove"), KeyEvent.VK_DELETE, Shortcut.ALT);
31        sc.setAccelerator(this);
32        putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tr("Remove the currently selected members from this relation"), sc));
33        setEnabled(false);
34    }
35
36    @Override
37    public void actionPerformed(ActionEvent e) {
38        editorAccess.getMemberTableModel().remove(editorAccess.getMemberTable().getSelectedRows());
39    }
40
41    @Override
42    protected void updateEnabledState() {
43        setEnabled(editorAccess.getMemberTableModel().canRemove(editorAccess.getMemberTable().getSelectedRows()));
44    }
45}
Note: See TracBrowser for help on using the repository browser.