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 | * Sort the relation members
|
---|
15 | * @since 9496
|
---|
16 | */
|
---|
17 | public class SortAction extends AbstractRelationEditorAction {
|
---|
18 | private static final long serialVersionUID = 1L;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Constructs a new {@code SortAction}.
|
---|
22 | * @param memberTable member table
|
---|
23 | * @param memberTableModel member table model
|
---|
24 | */
|
---|
25 | public SortAction(IRelationEditorActionAccess editorAccess) {
|
---|
26 | super(editorAccess, IRelationEditorUpdateOn.MEMBER_TABLE_CHANGE);
|
---|
27 | new ImageProvider("dialogs", "sort").getResource().attachImageIcon(this, true);
|
---|
28 | putValue(NAME, tr("Sort"));
|
---|
29 | Shortcut sc = Shortcut.registerShortcut("relationeditor:sort", tr("Relation Editor: Sort"), KeyEvent.VK_END, Shortcut.ALT);
|
---|
30 | sc.setAccelerator(this);
|
---|
31 | putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tr("Sort the relation members"), sc));
|
---|
32 | updateEnabledState();
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public void actionPerformed(ActionEvent e) {
|
---|
37 | editorAccess.getMemberTableModel().sort();
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Override
|
---|
41 | protected void updateEnabledState() {
|
---|
42 | setEnabled(editorAccess.getMemberTableModel().getRowCount() > 0);
|
---|
43 | }
|
---|
44 | }
|
---|