protected Command chainGuideAttachmentCommand(
      Request request, LogicSubpart part, Command cmd, boolean horizontal) {
    Command result = cmd;

    // Attach to guide, if one is given
    Integer guidePos =
        (Integer)
            request
                .getExtendedData()
                .get(
                    horizontal
                        ? SnapToGuides.KEY_HORIZONTAL_GUIDE
                        : SnapToGuides.KEY_VERTICAL_GUIDE);
    if (guidePos != null) {
      int alignment =
          ((Integer)
                  request
                      .getExtendedData()
                      .get(
                          horizontal
                              ? SnapToGuides.KEY_HORIZONTAL_ANCHOR
                              : SnapToGuides.KEY_VERTICAL_ANCHOR))
              .intValue();
      ChangeGuideCommand cgm = new ChangeGuideCommand(part, horizontal);
      cgm.setNewGuide(findGuideAt(guidePos.intValue(), horizontal), alignment);
      result = result.chain(cgm);
    }

    return result;
  }
  /** {@inheritDoc} */
  @Override
  public EditPart getTargetEditPart(Request request) {
    if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_COLUMN_GROUP.equals(request.getType())
        || ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN_GROUP.equals(
            request.getType())) {
      DirectEditRequest editRequest = (DirectEditRequest) request;

      TableView tableView = (TableView) this.getHost().getModel();
      ColumnGroup columnGroup =
          (ColumnGroup) ((Map) editRequest.getDirectEditFeature()).get("group");

      if (!tableView.getColumns().contains(columnGroup)) {
        return getHost();
      }

    } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_WORD.equals(
        request.getType())) {
      return getHost();

    } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN.equals(
        request.getType())) {
      return getHost();
    }

    return super.getTargetEditPart(request);
  }
  /**
   * Returns a composite command with the given initial command and the RegionContainer specific
   * auto-size commands to propagate the auto-size to the regions.
   *
   * @param request the initial request
   * @param autoSizeCommand the initial command
   * @return a composite command with the initial command and the region container specific
   *     additional commands.
   */
  protected Command getRegionContainerAutoSizeCommand(Request request, Command autoSizeCommand) {
    IDiagramElementEditPart host = (IDiagramElementEditPart) getHost();
    TransactionalEditingDomain domain = host.getEditingDomain();
    CompositeTransactionalCommand ctc =
        new CompositeTransactionalCommand(
            domain,
            Messages.RegionContainerResizableEditPolicy_regionContainerAutoSizeCommandLabel);
    ctc.add(new CommandProxy(autoSizeCommand));
    Command regionContainerAutoSizeCommand = new ICommandProxy(ctc);

    // Propagate the auto-size request to the regions.
    Request req = new Request();
    req.setType(request.getType());
    req.getExtendedData().put(REGION_AUTO_SIZE_PROPAGATOR, host);

    Object object = request.getExtendedData().get(REGION_AUTO_SIZE_PROPAGATOR);
    for (EditPart regionPart : getRegionParts()) {
      if (object != regionPart) {
        ctc.add(new CommandProxy(regionPart.getCommand(req)));
      }
    }

    ctc.add(
        CommandFactory.createICommand(
            domain, new RegionContainerUpdateLayoutOperation((Node) host.getModel())));
    return regionContainerAutoSizeCommand;
  }
  @Override
  public EditPart getTargetEditPart(Request request) {
    if (request == null || request.getType() == null) {
      return null;
    }

    return request.getType().equals(RequestConstants.REQ_SELECTION_HOVER) ? getHost() : null;
  }
 public void showTargetFeedback(Request request) {
   if (request.getType().equals(RequestConstants.REQ_MOVE)
       || request.getType().equals(RequestConstants.REQ_ADD)
       || request.getType().equals(RequestConstants.REQ_CLONE)
       || request.getType().equals(RequestConstants.REQ_CONNECTION_START)
       || request.getType().equals(RequestConstants.REQ_CONNECTION_END)
       || request.getType().equals(RequestConstants.REQ_CREATE)) showHighlight();
 }
  /** @see org.eclipse.gef.EditPolicy#getCommand(Request) */
  public Command getCommand(Request req) {
    if (req.getType().equals(REQ_MOVE_CHILDREN))
      return getMoveChildrenCommand((ChangeBoundsRequest) req);
    if (req.getType().equals(REQ_ADD)) return getAddCommand((ChangeBoundsRequest) req);
    if (req.getType().equals(REQ_CREATE)) return getCreateCommand((CreateRequest) req);

    return null;
  }
 public EditPart getTargetEditPart(Request request) {
   if (REQ_CREATE.equals(request.getType())) {
     return null;
   } else if (RequestConstants.REQ_AUTOSIZE.equals(request.getType())) {
     return getHost();
   }
   return super.getTargetEditPart(request);
 }
 public Command createOpacityCommand(final String opacity) {
   final Request opacityReq = new Request("opacity"); // $NON-NLS-1$
   final HashMap<String, String> reqData = new HashMap<String, String>();
   reqData.put("newOpacity", opacity); // $NON-NLS-1$
   opacityReq.setExtendedData(reqData);
   final EditPart object = (EditPart) getSelectedObjects().get(0);
   final Command cmd = object.getCommand(opacityReq);
   return cmd;
 }
 @Override
 public void performRequest(Request req) {
   if (req.getType() == RequestConstants.REQ_DIRECT_EDIT && !isLocked()) {
     createDirectEditManager().show();
   } else if (req.getType() == RequestConstants.REQ_OPEN) {
     // Show Properties view
     showPropertiesView();
   }
 }
 /** Avoid request of Re-Size and Move for pipeline procedures */
 public Command getCommand(Request request) {
   if (RequestConstants.REQ_MOVE.equals(request.getType())
       || RequestConstants.REQ_RESIZE.equals(request.getType())) {
     return new Command() {
       public boolean canExecute() {
         return false;
       }
     };
   }
   return super.getCommand(request);
 }
  @Override
  public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE)
        || request.getType().equals(RequestConstants.REQ_ADD)
        || request.getType().equals(RequestConstants.REQ_RECONNECT_SOURCE)
        || request.getType().equals(RequestConstants.REQ_RECONNECT_TARGET)
        || request.getType().equals(RequestConstants.REQ_CONNECTION_START)
        || request.getType().equals(RequestConstants.REQ_CONNECTION_END)
        || request.getType().equals(RequestConstants.REQ_CREATE)
        || request.getType().equals(DiagramDropRequest.REQ_DIAGRAM_DROP)) {

      getContainerFigure().showTargetFeedback();
    }
  }
  /** {@inheritDoc} */
  @Override
  public Command getCommand(Request request) {
    try {
      if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_COLUMN_GROUP.equals(
          request.getType())) {
        DirectEditRequest editRequest = (DirectEditRequest) request;

        TableView tableView = (TableView) this.getHost().getModel();
        ColumnGroup columnGroup =
            (ColumnGroup) ((Map) editRequest.getDirectEditFeature()).get("group");

        if (!tableView.getColumns().contains(columnGroup)) {
          return new AddColumnGroupCommand(
              tableView, columnGroup, this.getColumnIndex(editRequest));
        }

      } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_WORD.equals(
          request.getType())) {
        DirectEditRequest editRequest = (DirectEditRequest) request;

        TableView table = (TableView) this.getHost().getModel();
        Word word = (Word) editRequest.getDirectEditFeature();

        return new AddWordCommand(table, word, this.getColumnIndex(editRequest));

      } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN.equals(
          request.getType())) {
        DirectEditRequest editRequest = (DirectEditRequest) request;

        return ColumnSelectionHandlesEditPolicy.createMoveColumnCommand(
            editRequest,
            this.getHost().getViewer(),
            (TableView) this.getHost().getModel(),
            this.getColumnIndex(editRequest));

      } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN_GROUP.equals(
          request.getType())) {
        DirectEditRequest editRequest = (DirectEditRequest) request;

        return ColumnSelectionHandlesEditPolicy.createMoveColumnGroupCommand(
            editRequest, (TableView) this.getHost().getModel(), this.getColumnIndex(editRequest));
      }

    } catch (Exception e) {
      Activator.showExceptionDialog(e);
    }

    return super.getCommand(request);
  }
Beispiel #13
0
 /** @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request) */
 public void performRequest(Request request) {
   if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
     if (request instanceof DirectEditRequest
         && !directEditHitTest(((DirectEditRequest) request).getLocation().getCopy())) return;
     performDirectEdit();
   }
 }
 @Override
 public Command getCommand(Request request) {
   if (RequestConstants.REQ_SEMANTIC_WRAPPER.equals(request.getType())) {
     return getSemanticCommand(((EditCommandRequestWrapper) request).getEditCommandRequest());
   }
   return null;
 }
  /**
   * Returns a <code>Command</code> which sets the label's offset to its original position.
   *
   * @param request the request
   * @return the command
   */
  @Override
  public Command getCommand(Request request) {
    if (RequestConstants.REQ_SNAP_BACK.equals(request.getType())) {
      View view = (View) getHost().getModel();

      // YT - Use a snap back hint that takes into account the diagram
      // and parent view type.
      String hint = getSnapBackHint(view);

      Point offset = LabelEditPart.getSnapBackPosition(hint);
      if (offset == null) {
        return null;
      }

      TransactionalEditingDomain editingDomain =
          ((IGraphicalEditPart) getHost()).getEditingDomain();

      ICommand moveCommand =
          new SetBoundsCommand(
              editingDomain,
              DiagramUIMessages.SetLocationCommand_Label_Resize,
              new EObjectAdapter(view),
              offset);
      return new ICommandProxy(moveCommand);
    }
    return null;
  }
Beispiel #16
0
 @Override
 public EditPart getTargetEditPart(Request request) {
   EditPart ep = super.getTargetEditPart(request);
   if (ep != null) return ep;
   if (REQ_DIRECT_EDIT.equals(request.getType())) return getHost();
   return null;
 }
Beispiel #17
0
 public void performRequest(Request request) {
   if (RequestConstants.REQ_DIRECT_EDIT.equals(request.getType())) {
     performDirectEdit();
   } else {
     super.performRequest(request);
   }
 }
Beispiel #18
0
 @Override
 public Command getCommand(Request request) {
   if (request.getType().equals(RequestConstants.REQ_DELETE)) {
     return UnexecutableCommand.INSTANCE;
   }
   return super.getCommand(request);
 }
 @Override
 public void performRequest(Request request) {
   if (request.getType() == REQ_DIRECT_EDIT) {
     performDirectEdit();
   } else {
     super.performRequest(request);
   }
 }
 /**
  * @see
  *     org.eclipse.gmf.runtime.diagram.ui.editpolicies.PropertyHandlerEditPolicy#getCommand(org.eclipse.gef.Request)
  * @param request
  * @return
  */
 @Override
 public Command getCommand(Request request) {
   if (request.getType().equals(ShowHideCompartmentRequest.SHOW_HIDE_COMPARTMENT)) {
     ShowHideCompartmentRequest req = (ShowHideCompartmentRequest) request;
     return getShowHideCompartmentCommand(req);
   }
   return null;
 }
 /** @see org.eclipse.gef.EditPart#understandsRequest(org.eclipse.gef.Request) */
 public boolean understandsRequest(Request req) {
   if (req.getType().equals(RequestConstants.REQ_DELETE)) return true;
   if (req instanceof AddOperationDefRequest) return true;
   else if (req instanceof AddValueMembertDefRequest) return true;
   else if (req instanceof AddAttributeDefRequest) return true;
   else {
     return super.understandsRequest(req);
   }
 }
 /**
  * Extended request data key to hold editpart visual id. Add visual id of edited editpart to
  * extended data of the request so command switch can decide what kind of diagram element is being
  * edited. It is done in those cases when it's not possible to deduce diagram element kind from
  * domain element.
  *
  * @generated
  */
 public Command getCommand(Request request) {
   if (request instanceof ReconnectRequest) {
     Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
     if (view instanceof View) {
       Integer id = new Integer(OrocosComponentModelVisualIDRegistry.getVisualID((View) view));
       request.getExtendedData().put(VISUAL_ID_KEY, id);
     }
   }
   return super.getCommand(request);
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#showTargetFeedback(org.eclipse.gef.Request)
  */
 public void showTargetFeedback(Request request) {
   if (request instanceof DropRequest
       && request.getType() == ItemCreationRequest.REQ_ITEM_CREATION) {
     super.showTargetFeedback(request);
     if (getHost() instanceof GraphicalEditPart) {
       ExposeHelper exposeHelper = new ExposeHelper(getViewer(getHost()));
       exposeHelper.adjustVertical(((DropRequest) request).getLocation());
     }
   }
 }
 /** @see org.eclipse.gef.EditPart#getCommand(org.eclipse.gef.Request) */
 public Command getCommand(Request request) {
   if (request.getType().equals(RequestConstants.REQ_DELETE))
     return new DeleteNodeCommand(
         (Node) getModelNode(),
         ((Node) getModelNode()).getView(),
         ((Node) getModel()).getContained());
   if (request instanceof AddOperationDefRequest) return new AddOperationDefCommand();
   else if (request instanceof AddValueMembertDefRequest) return new AddValueMemberDefCommand();
   else if (request instanceof AddAttributeDefRequest) return new AddAttributeDefCommand();
   else return super.getCommand(request);
 }
 /**
  * Extended request data key to hold editpart visual id. Add visual id of edited editpart to
  * extended data of the request so command switch can decide what kind of diagram element is being
  * edited. It is done in those cases when it's not possible to deduce diagram element kind from
  * domain element. Add the reoriented view to the request extended data so that the view currently
  * edited can be distinguished from other views of the same element and these latter possibly
  * removed if they become inconsistent after reconnect
  *
  * @generated
  */
 @SuppressWarnings("unchecked")
 public Command getCommand(Request request) {
   if (request instanceof ReconnectRequest) {
     Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
     if (view instanceof View) {
       Integer id = new Integer(UMLVisualIDRegistry.getVisualID((View) view));
       request.getExtendedData().put(VISUAL_ID_KEY, id);
       request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, (View) view);
     }
   }
   return super.getCommand(request);
 }
Beispiel #26
0
 @Override
 public void performRequest(Request req) {
   if (req.getType().equals(RequestConstants.REQ_OPEN)) {
     try {
       PlatformUI.getWorkbench()
           .getActiveWorkbenchWindow()
           .getActivePage()
           .showView("org.eclipse.ui.views.PropertySheet");
     } catch (PartInitException e) {
       throw new RuntimeException(e);
     }
   }
 }
  /** @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request) */
  public void performRequest(Request req) {
    if (req.getType().equals(REQ_OPEN) && (getModel() instanceof Relationship)) {
      Relationship model = (Relationship) getModel();

      RelationshipPropertiesInputDialog dialog =
          new RelationshipPropertiesInputDialog(
              new Shell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL, model);
      dialog.open();

      // Effettuo il refresh della selezione
      setSelected(SELECTED);
    }
  }
 /**
  * Returns the host EditPart when appropriate. Targeting is done by checking if the mouse is
  * clearly over the host's TreeItem.
  *
  * @see org.eclipse.gef.EditPolicy#getTargetEditPart(Request)
  */
 public EditPart getTargetEditPart(Request req) {
   if (req.getType().equals(REQ_ADD)
       || req.getType().equals(REQ_MOVE)
       || req.getType().equals(REQ_CREATE)) {
     DropRequest drop = (DropRequest) req;
     Point where = new Point(drop.getLocation().x, drop.getLocation().y);
     Widget widget = ((TreeEditPart) getHost()).getWidget();
     if (widget instanceof Tree) return getHost();
     TreeItem treeitem = (TreeItem) widget;
     Rectangle bounds = treeitem.getBounds();
     int fudge = bounds.height / 5;
     Rectangle inner =
         new Rectangle(
             bounds.x,
             bounds.y + fudge,
             bounds.width,
             bounds.height - (treeitem.getExpanded() ? 0 : fudge * 2));
     // Point is either outside the Treeitem, or inside the inner Rect.
     if (!bounds.contains(where) || inner.contains(where)) return getHost();
   }
   return null;
 }
 /**
  * @see
  *     org.eclipse.gmf.runtime.diagram.ui.editpolicies.PropertyHandlerEditPolicy#getCommand(org.eclipse.gef.Request)
  * @param request
  * @return
  */
 @Override
 public Command getCommand(Request request) {
   if (request.getType().equals(ShowHideElementsRequest.SHOW_HIDE_ELEMENTS)) {
     ShowHideElementsRequest req = (ShowHideElementsRequest) request;
     if (req.getHidedEditPart() != null) {
       return getDestroyViewCommand(req.getHidedEditPart());
     } else if (req.getContainer() != null && req.getSemanticElement() != null) {
       return getCreateViewCommand(
           req.getContainer(), req.getSemanticElement(), req.getLocation());
     }
   }
   return null;
 }
 /**
  * Extended request data key to hold editpart visual id. Add visual id of edited editpart to
  * extended data of the request so command switch can decide what kind of diagram element is being
  * edited. It is done in those cases when it's not possible to deduce diagram element kind from
  * domain element.
  *
  * @generated
  */
 public Command getCommand(Request request) {
   if (request instanceof ReconnectRequest) {
     Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
     if (view instanceof View) {
       Integer id =
           new Integer(
               edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part
                   .ClassDiagram_MAVOVisualIDRegistry.getVisualID((View) view));
       request.getExtendedData().put(VISUAL_ID_KEY, id);
     }
   }
   return super.getCommand(request);
 }