/**
   * This method looks for inconsistent views to delete in case the message is deleted or the
   * connector of the message is re-oriented.
   *
   * @param destructee the modified message
   * @param request the request to destroy a message or to re-orient a message
   * @return the list of {@link View} to delete
   */
  public static Set<View> getMemberViewsToDestroy(Message destructee, IEditCommandRequest request) {
    Set<View> viewsToDestroy = new HashSet<View>();
    CrossReferenceAdapter crossReferenceAdapter =
        InconsistentMessageViewsHelper.getCrossReferenceAdapter(request, destructee);
    if (crossReferenceAdapter != null) {

      Collection<Setting> revRefs =
          crossReferenceAdapter.getNonNavigableInverseReferences(destructee);
      if (!revRefs.isEmpty()) {
        for (Setting current : revRefs) {
          // test if the view is linked with the removed message
          if (current.getEObject() instanceof View) {
            View view = (View) current.getEObject();
            // we remove the view only if they are owned by the CompositeStructureDiagram
            if (InconsistentMessageViewsHelper.isOwnedByCommunicationDiagram(view)) {

              viewsToDestroy.add(view);
              if (InconsistentMessageViewsHelper.isLastMessageOnConnection(view)) {
                // remove the connector
                // System.err.println("+-> the connector will be deleted : " +
                // (View)view.eContainer());
                // System.err.println("+-> the parent of the connector is : " +
                // (View)view.eContainer().eContainer());
                viewsToDestroy.add((View) view.eContainer());
              }
            }
          }
        }
      }
    }

    return viewsToDestroy;
  }
  /**
   * Returns the {@link CrossReferenceAdapter} corresponding to the element to destroy.
   *
   * @param request the request
   * @param destructee the destroyed element
   * @return the cross reference adapter the {@link CrossReferenceAdapter} corresponding to this
   *     element
   */
  public static CrossReferenceAdapter getCrossReferenceAdapter(
      IEditCommandRequest request, EObject destructee) {

    CrossReferenceAdapter crossReferenceAdapter = null;
    @SuppressWarnings("rawtypes")
    Map cacheMaps =
        (Map) request.getParameter("Cache_Maps"); // $NON-NLS-1$ RequestCacheEntries.Cache_Maps
    if (cacheMaps != null) {
      crossReferenceAdapter =
          (CrossReferenceAdapter)
              cacheMaps.get("CrossRefAdapter"); // $NON-NLS-1$ RequestCacheEntries.CrossRefAdapter
    }

    if (crossReferenceAdapter == null) {
      crossReferenceAdapter = CrossReferenceAdapter.getExistingCrossReferenceAdapter(destructee);
      if (crossReferenceAdapter == null) {
        TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(destructee);
        if (domain != null) {
          crossReferenceAdapter =
              CrossReferenceAdapter.getCrossReferenceAdapter(domain.getResourceSet());
        }
      }
    }
    return crossReferenceAdapter;
  }