| 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.tools.ImageProvider;
|
|---|
| 10 | import org.openstreetmap.josm.tools.Shortcut;
|
|---|
| 11 |
|
|---|
| 12 | /**
|
|---|
| 13 | * Move the currently selected members up.
|
|---|
| 14 | * @since 9496
|
|---|
| 15 | */
|
|---|
| 16 | public class MoveUpAction extends AbstractRelationEditorAction {
|
|---|
| 17 | private static final long serialVersionUID = 1L;
|
|---|
| 18 |
|
|---|
| 19 | /**
|
|---|
| 20 | * Constructs a new {@code MoveUpAction}.
|
|---|
| 21 | * @param editorAccess An interface to access the relation editor contents.
|
|---|
| 22 | * @param actionMapKey action map key
|
|---|
| 23 | */
|
|---|
| 24 | public MoveUpAction(IRelationEditorActionAccess editorAccess, String actionMapKey) {
|
|---|
| 25 | super(editorAccess, actionMapKey, IRelationEditorUpdateOn.MEMBER_TABLE_SELECTION);
|
|---|
| 26 | new ImageProvider("dialogs", "up").getResource().attachImageIcon(this, true);
|
|---|
| 27 | Shortcut sc = Shortcut.registerShortcut("relationeditor:moveup", tr("Relation Editor: Move Up"), KeyEvent.VK_UP, Shortcut.ALT);
|
|---|
| 28 | sc.setAccelerator(this);
|
|---|
| 29 | sc.setTooltip(this, tr("Move the currently selected members up"));
|
|---|
| 30 | setEnabled(false);
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | @Override
|
|---|
| 34 | public void actionPerformed(ActionEvent e) {
|
|---|
| 35 | editorAccess.getMemberTableModel().moveUp(editorAccess.getMemberTable().getSelectedRows());
|
|---|
| 36 | editorAccess.stopMemberCellEditing();
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | @Override
|
|---|
| 40 | protected void updateEnabledState() {
|
|---|
| 41 | setEnabled(editorAccess.getMemberTableModel().canMoveUp(editorAccess.getMemberTable().getSelectedRows()));
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|