/**
   * Check if the creation context is allowed.
   *
   * @see
   *     org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
   * @param request
   * @return true if the request is approved
   */
  @Override
  public boolean approveRequest(IEditCommandRequest request) {
    boolean isApproved = super.approveRequest(request);

    if ((request != null) && (request instanceof GetEditContextRequest)) {

      // Retrieve the edit context from request
      GetEditContextRequest editContextRequest = (GetEditContextRequest) request;

      // Test context type
      if (editContextRequest.getEditContext() instanceof Element) {
        Element contextElement = (Element) editContextRequest.getEditContext();

        IElementMatcher matcher;

        // Cannot create a nested requirement in FlowSpecification
        matcher = new FlowSpecificationMatcher();
        if (matcher.matches(contextElement)) {
          isApproved = false;
        }
      }
    }

    return isApproved;
  }
  /**
   * Check if the creation context is a {@link Block}.
   *
   * @see
   *     org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
   * @param request
   * @return true if the request is approved
   */
  @Override
  public boolean approveRequest(IEditCommandRequest request) {
    boolean isApproved = super.approveRequest(request);

    if ((request != null) && (request instanceof GetEditContextRequest)) {

      // Retrieve the edit context from request
      GetEditContextRequest editContextRequest = (GetEditContextRequest) request;

      // Test if the edit context is a Block
      if (editContextRequest.getEditContext() instanceof Element) {
        Element contextElement = (Element) editContextRequest.getEditContext();

        IElementMatcher matcher = new BlockMatcher();
        if (!matcher.matches(contextElement)) {
          isApproved = false;
        }
      }
    }

    return isApproved;
  }