@Override
 public void showSizeOnDropFeedback(CreateRequest request, IFigure feedback, Insets insets) {
   Point p = new Point(request.getLocation().getCopy());
   feedback.translateToRelative(p);
   Dimension size = request.getSize().getCopy();
   feedback.translateToRelative(size);
   feedback.setBounds(new Rectangle(p, size).expand(insets));
 }
 protected Command getCreateCommand(CreateRequest request) {
   NodeCreateCommand createCommand = new NodeCreateCommand();
   createCommand.setNode((Node) request.getNewObject());
   createCommand.setParent((ProcessDefinition) getHost().getModel());
   createCommand.setLocation(request.getLocation());
   createCommand.setLabel("create a node");
   return createCommand;
 }
 /* (non-Javadoc)
  * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
  */
 protected Command getCreateCommand(CreateRequest request) {
   Object newObjectType = request.getNewObjectType();
   Command createCommand = null;
   if (newObjectType == ProvidesDef.class
       || newObjectType == UsesDef.class
       || newObjectType == PublishesDef.class
       || newObjectType == ConsumesDef.class) {
     CreateNodeCommand create = new CreateNodeCommand();
     Dimension dim = request.getSize();
     if (dim == null) dim = new Dimension(100, 20);
     create.setConstraint(new Rectangle(request.getLocation(), dim));
     create.setParent((View) getHost().getModel());
     create.setModelParent(((View) getHost().getModel()).getModuleDef());
     create.setModelObject((Contained) request.getNewObject());
     create.setLabel("create a node");
     createCommand = create;
   }
   return createCommand;
 }
  @Override
  protected Command getCreateCommand(CreateRequest request) {
    if (request instanceof CreateViewAndElementRequest) {

      CreateViewAndElementRequest req = (CreateViewAndElementRequest) request;

      if (req.getViewAndElementDescriptor()
              .getSemanticHint()
              .equals(((IHintedType) UMLElementTypes.Pseudostate_16000).getSemanticHint())
          || req.getViewAndElementDescriptor()
              .getSemanticHint()
              .equals(((IHintedType) UMLElementTypes.Pseudostate_17000).getSemanticHint())
          || req.getViewAndElementDescriptor()
              .getSemanticHint()
              .equals(
                  ((IHintedType) UMLElementTypes.ConnectionPointReference_18000)
                      .getSemanticHint())) {

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

        CompositeTransactionalCommand cc =
            new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label);
        Iterator<?> iter = req.getViewDescriptors().iterator();

        // Retrieve parent location
        Point parentLoc = getHostFigure().getBounds().getLocation().getCopy();

        // Compute relative creation location
        Point requestedLocation = request.getLocation().getCopy();
        getHostFigure().translateToRelative(requestedLocation);

        // Create proposed creation bounds and use the locator to find the expected position
        CustomEntryExitPointPositionLocator locator =
            new CustomEntryExitPointPositionLocator(getHostFigure(), PositionConstants.NONE);
        Rectangle proposedBounds = new Rectangle(requestedLocation, new Dimension(20, 20));
        Rectangle preferredBounds = locator.getPreferredLocation(proposedBounds);

        // Convert the calculated preferred bounds as relative to parent location
        Rectangle creationBounds = preferredBounds.getTranslated(parentLoc.getNegated());

        while (iter.hasNext()) {

          CreateViewRequest.ViewDescriptor viewDescriptor =
              (CreateViewRequest.ViewDescriptor) iter.next();
          cc.compose(
              new SetBoundsCommand(
                  editingDomain,
                  DiagramUIMessages.SetLocationCommand_Label_Resize,
                  viewDescriptor,
                  creationBounds));
        }

        if (cc.reduce() == null) {
          return null;
        }

        return new ICommandProxy(cc.reduce());
      }
    }
    return null;
  }