- Timestamp:
- 2020-01-04T20:07:39+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r14960 r15630 8 8 import java.awt.event.KeyEvent; 9 9 import java.util.Collection; 10 import java.util.Locale; 10 11 11 12 import javax.swing.JOptionPane; … … 35 36 public enum Direction { 36 37 /** Move up */ 37 UP ,38 UP(tr("up"), "up", KeyEvent.VK_UP), 38 39 /** Move left */ 39 LEFT ,40 LEFT(tr("left"), "previous", KeyEvent.VK_LEFT), 40 41 /** Move right */ 41 RIGHT ,42 RIGHT(tr("right"), "next", KeyEvent.VK_RIGHT), 42 43 /** Move down */ 43 DOWN 44 DOWN(tr("down"), "down", KeyEvent.VK_DOWN); 45 46 private final String localizedName; 47 private final String icon; 48 private final int shortcutKey; 49 50 Direction(String localizedName, String icon, int shortcutKey) { 51 this.localizedName = localizedName; 52 this.icon = icon; 53 this.shortcutKey = shortcutKey; 54 } 55 56 String getId() { 57 return name().toLowerCase(Locale.ENGLISH); 58 } 59 60 String getLocalizedName() { 61 return localizedName; 62 } 63 64 String getIcon() { 65 return "dialogs/" + icon; 66 } 67 68 String getToolbarName() { 69 return "action/move/" + getId(); 70 } 71 72 int getShortcutKey() { 73 return shortcutKey; 74 } 75 76 Shortcut getShortcut() { 77 return Shortcut.registerShortcut( 78 "core:move" + getId(), tr("Move objects {0}", getLocalizedName()), getShortcutKey(), Shortcut.SHIFT); 79 } 44 80 } 45 81 46 82 private final Direction myDirection; 47 48 // any better idea?49 private static String calltosupermustbefirststatementinconstructortext(Direction dir) {50 String directiontext;51 if (dir == Direction.UP) {52 directiontext = tr("up");53 } else if (dir == Direction.DOWN) {54 directiontext = tr("down");55 } else if (dir == Direction.LEFT) {56 directiontext = tr("left");57 } else {58 directiontext = tr("right");59 }60 return directiontext;61 }62 63 // any better idea?64 private static Shortcut calltosupermustbefirststatementinconstructor(Direction dir) {65 Shortcut sc;66 // CHECKSTYLE.OFF: SingleSpaceSeparator67 if (dir == Direction.UP) {68 sc = Shortcut.registerShortcut("core:moveup", tr("Move objects {0}", tr("up")), KeyEvent.VK_UP, Shortcut.SHIFT);69 } else if (dir == Direction.DOWN) {70 sc = Shortcut.registerShortcut("core:movedown", tr("Move objects {0}", tr("down")), KeyEvent.VK_DOWN, Shortcut.SHIFT);71 } else if (dir == Direction.LEFT) {72 sc = Shortcut.registerShortcut("core:moveleft", tr("Move objects {0}", tr("left")), KeyEvent.VK_LEFT, Shortcut.SHIFT);73 } else { //dir == Direction.RIGHT74 sc = Shortcut.registerShortcut("core:moveright", tr("Move objects {0}", tr("right")), KeyEvent.VK_RIGHT, Shortcut.SHIFT);75 }76 // CHECKSTYLE.ON: SingleSpaceSeparator77 return sc;78 }79 83 80 84 /** … … 83 87 */ 84 88 public MoveAction(Direction dir) { 85 super(tr("Move {0}", calltosupermustbefirststatementinconstructortext(dir)), null,86 tr("Moves Objects {0}", calltosupermustbefirststatementinconstructortext(dir)),87 calltosupermustbefirststatementinconstructor(dir), false);89 super(tr("Move {0}", dir.getLocalizedName()), dir.getIcon(), 90 tr("Moves Objects {0}", dir.getLocalizedName()), 91 dir.getShortcut(), true, dir.getToolbarName(), true); 88 92 myDirection = dir; 89 93 setHelpId(ht("/Action/Move")); 90 if (dir == Direction.UP) {91 putValue("toolbar", "action/move/up");92 } else if (dir == Direction.DOWN) {93 putValue("toolbar", "action/move/down");94 } else if (dir == Direction.LEFT) {95 putValue("toolbar", "action/move/left");96 } else { //dir == Direction.RIGHT97 putValue("toolbar", "action/move/right");98 }99 MainApplication.getToolbar().register(this);100 94 } 101 95
Note:
See TracChangeset
for help on using the changeset viewer.