Package org.eclipse.gef

Examples of org.eclipse.gef.KeyHandler


        }
    }

    protected KeyHandler getCommonKeyHandler() {
        if (sharedKeyHandler == null) {
            sharedKeyHandler = new KeyHandler();
            sharedKeyHandler
                    .put(KeyStroke.getPressed(SWT.DEL, 127, 0),
                            getActionRegistry().getAction(
                                    ActionFactory.DELETE.getId()));
            sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
View Full Code Here


                EditPart editPart = element.getTypeDefinition().createGraphicalEditPart(element);
                return editPart;
            }
        });

        KeyHandler keyHandler = new GraphicalViewerKeyHandler(getGraphicalViewer());
        keyHandler.setParent(getCommonKeyHandler());
        getGraphicalViewer().setKeyHandler(keyHandler);
        getGraphicalViewer().setContextMenu(createContextMenu());
        getSite().setSelectionProvider(getGraphicalViewer());
    }
View Full Code Here

        getSite().setSelectionProvider(getGraphicalViewer());
    }

    protected KeyHandler getCommonKeyHandler() {
        if (commonKeyHandler == null) {
            commonKeyHandler = new KeyHandler();
            commonKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
            commonKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
        }
        return commonKeyHandler;
    }
View Full Code Here

    /*
     * A workaround because - when embedded in a ViewPart - the SWT.DEL key
     * is not recognized. This problem might be related to the GEF
     * EditDomain, that should be hooked separately in the ViewPart.
     */
    keyHandler = new KeyHandler() {

      @Override
      public boolean keyPressed(KeyEvent event) {
        if (event.keyCode == 127) {
          return performDelete();
View Full Code Here

    viewer.setRootEditPart(_root);
    getEditDomain().addViewer(viewer);
    getSite().setSelectionProvider(viewer);
    viewer.setEditPartFactory(getEditPartFactory());

    final KeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer) {
      @SuppressWarnings("unchecked")
      @Override
      public boolean keyPressed(final KeyEvent event) {
        if (event.stateMask == SWT.MOD1 && event.keyCode == SWT.DEL) {
          final List<? extends EditorPart> objects = viewer.getSelectedEditParts();
          if (objects == null || objects.isEmpty())
            return true;
          final GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
          final CompoundCommand compoundCmd = new CompoundCommand("Delete"); //$NON-NLS-1$
          for (int i = 0; i < objects.size(); i++) {
            final EditPart object = (EditPart) objects.get(i);
            deleteReq.setEditParts(object);
            final Command cmd = object.getCommand(deleteReq);
            if (cmd != null)
              compoundCmd.add(cmd);
          }
          getCommandStack().execute(compoundCmd);
          return true;
        }
        if (event.stateMask == SWT.MOD3
          && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT
            || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
          final List<? extends EditorPart> objects = viewer.getSelectedEditParts();
          if (objects == null || objects.isEmpty())
            return true;
          // move request
          final GroupRequest moveReq = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
          final CompoundCommand compoundCmd = new CompoundCommand("Move"); //$NON-NLS-1$
          for (int i = 0; i < objects.size(); i++) {
            final EditPart object = (EditPart) objects.get(i);
            moveReq.setEditParts(object);
            final LocationCommand cmd = (LocationCommand) object.getCommand(moveReq);
            if (cmd != null) {
              cmd.setLocation(new Point(event.keyCode == SWT.ARROW_LEFT ? -1
                : event.keyCode == SWT.ARROW_RIGHT ? 1 : 0,
                event.keyCode == SWT.ARROW_DOWN ? 1
                  : event.keyCode == SWT.ARROW_UP ? -1 : 0));
              cmd.setRelative(true);
              compoundCmd.add(cmd);
            }
          }
          getCommandStack().execute(compoundCmd);
          return true;
        }
        return super.keyPressed(event);
      }
    };
    keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(
      GEFActionConstants.DIRECT_EDIT));
    viewer.setKeyHandler(keyHandler);

    viewer.setContents(getEditorInput().getAdapter(NamedUuidEntity.class));
    viewer.addDropTargetListener(createTransferDropTargetListener(viewer));
View Full Code Here

   * 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));
    }
View Full Code Here

        }
    }

    protected KeyHandler getCommonKeyHandler() {
        if (sharedKeyHandler == null) {
            sharedKeyHandler = new KeyHandler();
            sharedKeyHandler
                    .put(KeyStroke.getPressed(SWT.DEL, 127, 0),
                            getActionRegistry().getAction(
                                    ActionFactory.DELETE.getId()));
            sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
View Full Code Here

    this.diagramKeyHandler = new SapphireDiagramKeyHandler(this, selectedParts);
        if (this.graphicalViewerKeyHandler == null)
        {
          graphicalViewerKeyHandler = new GraphicalViewerKeyHandler(getGraphicalViewer());
        }
    KeyHandler parentKeyHandler = graphicalViewerKeyHandler.setParent(this.diagramKeyHandler);
    getGraphicalViewer().setKeyHandler(parentKeyHandler);
  }
View Full Code Here

* 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;
View Full Code Here

    return adapterDefinitions;
  }

  protected KeyHandler getCommonKeyHandler() {
    if (keyHandler == null) {
      keyHandler = new KeyHandler();
      // 127 is ASCII value for delete key
      keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
          getActionRegistry().getAction(ActionFactory.DELETE.getId()));
      // 8 is ASCII value for backspace key
      keyHandler.put(KeyStroke.getReleased(SWT.BS, 8, 0),
View Full Code Here

TOP

Related Classes of org.eclipse.gef.KeyHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.