Package org.eclipse.gef.commands

Examples of org.eclipse.gef.commands.Command


    setHoverActive(false);

    if ((e.stateMask & SWT.ALT) != 0) {
      return false;
    }
    Command command = null;
    KeyboardData keyCode = null;
    switch (e.keyCode) {
    case SWT.F2:
      command = new SwitchSelectionCommand((IHTMLGraphicalViewer) this
          .getCurrentViewer());

      break;
    case SWT.ARROW_UP:
      command = new VerticalMoveCommand((IHTMLGraphicalViewer) this
          .getCurrentViewer(), true, (e.stateMask & SWT.SHIFT) != 0);
      break;
    case SWT.ARROW_DOWN:
      command = new VerticalMoveCommand((IHTMLGraphicalViewer) this
          .getCurrentViewer(), false, (e.stateMask & SWT.SHIFT) != 0);
      break;
    case SWT.ARROW_LEFT:
      command = new HorizontalMoveCommand((IHTMLGraphicalViewer) this
          .getCurrentViewer(), false, (e.stateMask & SWT.SHIFT) != 0);
      break;
    case SWT.ARROW_RIGHT:
      command = new HorizontalMoveCommand((IHTMLGraphicalViewer) this
          .getCurrentViewer(), true, (e.stateMask & SWT.SHIFT) != 0);
      break;
    case SWT.DEL:
      if ((e.stateMask & SWT.SHIFT) == 0) {
        if (getCurrentViewer().getSelection() != null) {
          ISelection selection = getCurrentViewer().getSelection();
          if (selection instanceof StructuredSelection) {
            Object object = ((StructuredSelection) selection)
                .getFirstElement();
            if (!(object instanceof DocumentEditPart)) {
              // "delete node"
              command = new DeleteNodeCommand(
                  (IHTMLGraphicalViewer) getCurrentViewer());
            }
          }
        }
        if (command == null) {
          // "delete"
          command = new DeleteCommand(true,
              (IHTMLGraphicalViewer) this.getCurrentViewer());
        }
      } else {
        // "cut"
        command = new CutCommand((IHTMLGraphicalViewer) this
            .getCurrentViewer());
        e.doit = false;
      }
      break;
    case SWT.BS:
      // "delete"
      command = new DeleteCommand(false, (IHTMLGraphicalViewer) this
          .getCurrentViewer());
      e.doit = false;
      break;
    case SWT.INSERT:
      if ((e.stateMask & SWT.SHIFT) != 0) {
        // "paste"
        command = new PasteCommand((IHTMLGraphicalViewer) this
            .getCurrentViewer());
        e.doit = false;
        break;
      } else if ((e.stateMask & SWT.CONTROL) != 0) {
        // "copy"
        command = new CopyCommand((IHTMLGraphicalViewer) this
            .getCurrentViewer());
        e.doit = false;
        break;
      }
      break;
    case SWT.LF:
    case SWT.CR:
      // "insert"
      keyCode = new KeyboardData(e.character, e.stateMask,
          (IHTMLGraphicalViewer) getCurrentViewer());
      command = new InsertCommand(
          PageDesignerResources.getInstance().getString(
              "RangeSelectionTool.CommandLabel.Insert"), (IHTMLGraphicalViewer) this.getCurrentViewer(), keyCode); //$NON-NLS-1$
      e.doit = false;
      break;
    default:
      if (e.keyCode == 'a' && (e.stateMask & SWT.CTRL) != 0) {
        command = new SelectAllCommand("selectAll", //$NON-NLS-1$
            (IHTMLGraphicalViewer) this.getCurrentViewer());
        e.doit = false;
      } else {
        if (getCurrentViewer() instanceof IHTMLGraphicalViewer
            && ((IHTMLGraphicalViewer) getCurrentViewer())
                .isInRangeMode()
            && (!Character.isIdentifierIgnorable(e.character) && !Character
                .isISOControl(e.character))
            || (e.character == '\r')) {
          keyCode = new KeyboardData(e.character, e.stateMask,
              (IHTMLGraphicalViewer) getCurrentViewer());
          // "insert"
          command = new InsertCommand(
              PageDesignerResources.getInstance().getString(
                  "RangeSelectionTool.CommandLabel.Insert"), (IHTMLGraphicalViewer) this.getCurrentViewer(), keyCode); //$NON-NLS-1$
          e.doit = false;
          break;
        }
                return super.handleKeyDown(e);
      }
    }
    if (command != null) {
      command.execute();
      e.doit = false;
      if (command instanceof ICaretPositionMover) {
        if (getCurrentViewer() instanceof IHTMLGraphicalViewer) {
          ((IHTMLGraphicalViewer) getCurrentViewer())
              .updateHorizontalPos();
View Full Code Here


  public void setPropertyValue(final Object id, final Object value) {
    Object oldValue = getPropertyValue(id);
    if (oldValue == value || (oldValue != null && oldValue.equals(value))) {
      return;
    }
    Command c = new ChangeAttributeCommand(
        PDPlugin
            .getResourceString("AttributePropertySource.CommandLabel.ChangeAttribute"), _element, (String) id, (String) value); //$NON-NLS-1$
    c.execute();
  }
View Full Code Here

   * publicly. Thus we have to check canExecute() here because remote
   * operations may have caused to make it non-executable.
   */
  @Override
  public boolean canRedo() {
    Command c = getRedoCommand();
    if (c != null && !c.canExecute())
      return false;
    return super.canRedo();

  }
View Full Code Here

  public void setPropertyValue(final Object id, final Object value) {
    Object oldValue = getPropertyValue(id);
    if (oldValue == value || (oldValue != null && oldValue.equals(value))) {
      return;
    }
    Command c = new ChangeAttributeCommand(
        PDPlugin
            .getResourceString("AttributePropertySource.CommandLabel.ChangeAttribute"), _element, (String) id, (String) value); //$NON-NLS-1$
    c.execute();
  }
View Full Code Here

  /**
     * @param button
     */
    protected void customizeDropAndMaybeExecute(final int button)
    {
        Command command = getCurrentCommand();

        IStatus status = Status.OK_STATUS;
        if (command instanceof CreateItemCommand)
        {
            status = new DropCustomizationController((CreateItemCommand) command,
View Full Code Here

      }
    }

    if (_linkType != null) {
      Request request = new LinkRequest(_linkType, _range);
      Command cmd = _editPart.getCommand(request);
      if (cmd != null && cmd.canExecute()) {
        cmd.execute();
      }
    }

  }
View Full Code Here

      request.setType("move");
  }

  public Command getCommand(Request request)
  {
    Command command = null;
    Command tmp;
    EditPolicyIterator i = getEditPolicyIterator();

    while (i.hasNext())
    {
      EditPolicy ep = i.next();
View Full Code Here

    boolean highlight = false;
    List<EdgeModel> highlightedEdges = new ArrayList();

    for (int i = 0; i < getCommands().size(); i++)
    {
      Command cmd = (Command) getCommands().get(i);

      if (cmd instanceof OrphanChildCommand)
      {
        node = ((OrphanChildCommand) cmd).getChild();
        // remove node highlight
        highlight = node.isHighlight();
        node.setHighlight(false);

        // remove edge highlights
        List edges = node.getSourceConnections();
        Iterator<EdgeModel> iter = edges.iterator();

        while (iter.hasNext())
        {
          EdgeModel edge = iter.next();

          if (edge.isHighlight())
          {
            highlightedEdges.add(edge);
            edge.setHighlight(false);
          }
        }
      }

      cmd.execute();
    }

    // restore node highlights
    for (int i = 0; i < getCommands().size(); i++)
    {
      Command cmd = (Command) getCommands().get(i);

      if (cmd instanceof OrphanChildCommand)
      {
        node = ((OrphanChildCommand) cmd).getChild();
View Full Code Here

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

    }

    boolean changed = deleteViews(orphaned.iterator());
    //
    CreateViewRequest request = getCreateViewRequest(viewDescriptors);
    Command cmd = getCreateViewCommand(request);
    if (cmd != null && cmd.canExecute()) {
      SetViewMutabilityCommand.makeMutable(
          new EObjectAdapter(host().getNotationView())).execute();
      executeCommand(cmd);
      @SuppressWarnings("unchecked")
      List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject();
View Full Code Here

TOP

Related Classes of org.eclipse.gef.commands.Command

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.