[9665] | 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 | * Move the currently selected members up.
|
---|
| 15 | * @since 9496
|
---|
| 16 | */
|
---|
| 17 | public class MoveUpAction extends AbstractRelationEditorAction {
|
---|
[14027] | 18 | private static final long serialVersionUID = 1L;
|
---|
[9665] | 19 |
|
---|
| 20 | /**
|
---|
| 21 | * Constructs a new {@code MoveUpAction}.
|
---|
| 22 | * @param memberTable member table
|
---|
| 23 | * @param memberTableModel member table model
|
---|
| 24 | * @param actionMapKey key in table action map
|
---|
| 25 | */
|
---|
[14027] | 26 | public MoveUpAction(IRelationEditorActionAccess editorAccess, String actionMapKey) {
|
---|
| 27 | super(editorAccess, actionMapKey, IRelationEditorUpdateOn.MEMBER_TABLE_SELECTION);
|
---|
[13130] | 28 | new ImageProvider("dialogs", "moveup").getResource().attachImageIcon(this, true);
|
---|
[9665] | 29 | Shortcut sc = Shortcut.registerShortcut("relationeditor:moveup", tr("Relation Editor: Move Up"), KeyEvent.VK_UP, Shortcut.ALT);
|
---|
| 30 | sc.setAccelerator(this);
|
---|
| 31 | putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tr("Move the currently selected members up"), sc));
|
---|
| 32 | setEnabled(false);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | @Override
|
---|
| 36 | public void actionPerformed(ActionEvent e) {
|
---|
[14027] | 37 | editorAccess.getMemberTableModel().moveUp(editorAccess.getMemberTable().getSelectedRows());
|
---|
[9665] | 38 | }
|
---|
| 39 |
|
---|
| 40 | @Override
|
---|
| 41 | protected void updateEnabledState() {
|
---|
[14027] | 42 | setEnabled(editorAccess.getMemberTableModel().canMoveUp(editorAccess.getMemberTable().getSelectedRows()));
|
---|
[9665] | 43 | }
|
---|
| 44 | }
|
---|