/** configure key handler */
  private void configureKeyHandler() {
    GraphicalViewer viewer = getGraphicalViewer();

    keyHandler = new KeyHandler();
    //		keyHandler.put(KeyStroke.getPressed('a', 0x61, SWT.COMMAND),
    //	getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    keyHandler.put(
        KeyStroke.getPressed('s', 0x61, SWT.CTRL),
        getActionRegistry().getAction(ActionFactory.SAVE.getId()));

    keyHandler.put(
        KeyStroke.getPressed('z', 0x7a, SWT.CTRL),
        getActionRegistry().getAction(ActionFactory.UNDO.getId()));
    keyHandler.put(
        KeyStroke.getPressed('z', 0x7a, SWT.CTRL | SWT.SHIFT),
        getActionRegistry().getAction(ActionFactory.REDO.getId()));
    keyHandler.put(
        KeyStroke.getPressed('a', 0x61, SWT.CTRL),
        getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));

    keyHandler.put(
        KeyStroke.getPressed(SWT.DEL, 127, 0),
        getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    keyHandler.put(
        KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0),
        getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(
        KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0),
        getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));

    viewer.setProperty(
        MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
  }
示例#2
0
 /**
  * Returns the KeyHandler with common bindings for both the Outline and Graphical Views. For
  * example, delete is a common action.
  */
 protected KeyHandler getCommonKeyHandler() {
   if (sharedKeyHandler == null) {
     sharedKeyHandler = new KeyHandler();
     sharedKeyHandler.put(
         KeyStroke.getPressed(SWT.F2, 0),
         getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
   }
   return sharedKeyHandler;
 }
 /** To handle 2 key handlers (otherwise there would be an action loop)</br> {@inheritDoc} */
 @Override
 public void put(KeyStroke keystroke, IAction action) {
   this.alternativeKeyHandler.put(keystroke, action);
   super.put(keystroke, action);
 }