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.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
11 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Remove the currently selected members from this relation.
|
---|
15 | * @since 9496
|
---|
16 | */
|
---|
17 | public 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 | }
|
---|