Ignore:
Timestamp:
2008-10-05T17:06:27+02:00 (16 years ago)
Author:
stoecker
Message:

close bug #1622. Keyboard shortcuts and specific OS handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/MoveAction.java

    r627 r1023  
    1717import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1818import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
     19import org.openstreetmap.josm.tools.ShortCut;
    1920
    2021/**
    2122 * Moves the selection
    22  * 
     23 *
    2324 * @author Frederik Ramm
    2425 */
     
    2728        public enum Direction { UP, LEFT, RIGHT, DOWN }
    2829        private Direction myDirection;
    29        
     30
     31        // any better idea?
     32        private static Object calltosupermustbefirststatementinconstructor(Direction dir, boolean text) {
     33                ShortCut sc;
     34                String directiontext;
     35                if        (dir == Direction.UP)   {
     36                        directiontext = tr("up");
     37                        sc = ShortCut.registerShortCut("core:moveup",    tr("Move objects {0}", directiontext), KeyEvent.VK_UP,    ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT);
     38                } else if (dir == Direction.DOWN)  {
     39                        directiontext = tr("down");
     40                        sc = ShortCut.registerShortCut("core:movedown",  tr("Move objects {0}", directiontext), KeyEvent.VK_DOWN,  ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT);
     41                } else if (dir == Direction.LEFT)  {
     42                        directiontext = tr("left");
     43                        sc = ShortCut.registerShortCut("core:moveleft",  tr("Move objects {0}", directiontext), KeyEvent.VK_LEFT,  ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT);
     44                } else { //dir == Direction.RIGHT) {
     45                        directiontext = tr("right");
     46                        sc = ShortCut.registerShortCut("core:moveright", tr("Move objects {0}", directiontext), KeyEvent.VK_RIGHT, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT);
     47                }
     48                if (text) {
     49                        return directiontext;
     50                } else {
     51                        return sc;
     52                }
     53        }
     54
    3055        public MoveAction(Direction dir) {
    31                 super(tr("Move"), null, tr("Moves Objects"),
    32                 (dir == Direction.UP) ? KeyEvent.VK_UP :
    33                 (dir == Direction.DOWN) ? KeyEvent.VK_DOWN :
    34                 (dir == Direction.LEFT) ? KeyEvent.VK_LEFT :
    35                 KeyEvent.VK_RIGHT, 0, true);
     56                super(tr("Move {0}", calltosupermustbefirststatementinconstructor(dir, true)), null,
     57                      tr("Moves Objects {0}", calltosupermustbefirststatementinconstructor(dir, true)),
     58                      (ShortCut)calltosupermustbefirststatementinconstructor(dir, false), true);
    3659                myDirection = dir;
    3760        }
    3861
    3962        public void actionPerformed(ActionEvent event) {
    40                
     63
    4164                // find out how many "real" units the objects have to be moved in order to
    4265                // achive an 1-pixel movement
    43                
     66
    4467                EastNorth en1 = Main.map.mapView.getEastNorth(100, 100);
    4568                EastNorth en2 = Main.map.mapView.getEastNorth(101, 101);
    46                
     69
    4770                double distx = en2.east() - en1.east();
    4871                double disty = en2.north() - en1.north();
    49                
     72
    5073                switch (myDirection) {
    51                 case UP: 
     74                case UP:
    5275                        distx = 0;
    5376                        disty = -disty;
     
    6285                        disty = 0;
    6386                }
    64                
     87
    6588                Collection<OsmPrimitive> selection = Main.ds.getSelected();
    6689                Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
    67                
     90
    6891                Command c = !Main.main.undoRedo.commands.isEmpty()
    6992                ? Main.main.undoRedo.commands.getLast() : null;
Note: See TracChangeset for help on using the changeset viewer.