@Override
  protected Command getCreateCommand(CreateViewRequest request) {
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    CompositeTransactionalCommand cc =
        new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label);

    Iterator descriptors = request.getViewDescriptors().iterator();

    while (descriptors.hasNext()) {
      CreateViewRequest.ViewDescriptor descriptor =
          (CreateViewRequest.ViewDescriptor) descriptors.next();

      CreateCommand createStateMachine =
          new CreateCommand(editingDomain, descriptor, (View) (getHost().getModel()));

      CustomStateMachineWithDefaultRegionCreateNodeCommand createRegion =
          new CustomStateMachineWithDefaultRegionCreateNodeCommand(
              (IAdaptable) createStateMachine.getCommandResult().getReturnValue(),
              ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint(),
              editingDomain,
              DiagramUIMessages.CreateCommand_Label,
              createStateMachine.getAffectedFiles());

      cc.compose(createStateMachine);
      cc.compose(createRegion);
    }
    return new ICommandProxy(cc.reduce());
  }
  public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
    EObject element = (EObject) adapter.getAdapter(EObject.class);
    TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
    if (editingDomain == null) {
      return UnexecutableCommand.INSTANCE;
    }
    int equalityPosition = newString.indexOf(NAME_TYPE_SEPARATOR);
    if (equalityPosition == -1) {
      return getSetNameCommand(element, newString);
    }
    String name = newString.substring(0, equalityPosition);
    String type = newString.substring(equalityPosition + 1);

    CompositeTransactionalCommand command =
        new CompositeTransactionalCommand(editingDomain, "Set Values"); // $NON-NLS-1$
    command.compose(getSetNameCommand(element, name));
    if (type != null) {
      ICommand setTypeCommand = getSetTypeCommand(element, type);
      if (setTypeCommand != null) {
        command.compose(setTypeCommand);
      }
    }
    return command;
  }
 /** @generated */
 protected ICommand getParseCommand(IAdaptable adapter, Object[] values, int flags) {
   if (values == null || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
     return UnexecutableCommand.INSTANCE;
   }
   EObject element = (EObject) adapter.getAdapter(EObject.class);
   TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
   if (editingDomain == null) {
     return UnexecutableCommand.INSTANCE;
   }
   CompositeTransactionalCommand command =
       new CompositeTransactionalCommand(editingDomain, "Set Values"); // $NON-NLS-1$
   for (int i = 0; i < values.length; i++) {
     command.compose(getModificationCommand(element, editableFeatures[i], values[i]));
   }
   return command;
 }
 public Command getSetBusinessElementStructuralFeatureCommand(
     View view, String featureName, Object value) {
   EObject instance = view.getElement();
   Assert.assertNotNull(
       "No business element bound to notation element", instance); // $NON-NLS-1$
   EStructuralFeature feature = instance.eClass().getEStructuralFeature(featureName);
   if (feature == null) {
     throw new IllegalArgumentException("Not existing feature: " + featureName); // $NON-NLS-1$
   }
   SetRequest setReq = new SetRequest(instance, feature, value);
   EditPart editPart = findEditPart(view);
   TransactionalEditingDomain txEditDomain = getEditDomain(editPart);
   CompositeTransactionalCommand modelCmd =
       new CompositeTransactionalCommand(txEditDomain, "Set feature"); // $NON-NLS-1$
   modelCmd.compose(new SetValueCommand(setReq));
   return new ICommandProxy(modelCmd);
 }
 /** @generated */
 protected Command getCommand(Request request) {
   List operationSet = getOperationSet();
   if (operationSet.isEmpty()) {
     return UnexecutableCommand.INSTANCE;
   }
   Iterator editParts = operationSet.iterator();
   CompositeTransactionalCommand command =
       new CompositeTransactionalCommand(getEditingDomain(), getCommandLabel());
   while (editParts.hasNext()) {
     EditPart editPart = (EditPart) editParts.next();
     Command curCommand = editPart.getCommand(request);
     if (curCommand != null) {
       command.compose(new CommandProxy(curCommand));
     }
   }
   if (command.isEmpty() || command.size() != operationSet.size()) {
     return UnexecutableCommand.INSTANCE;
   }
   return new ICommandProxy(command);
 }
  @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;
  }