/**
   * Checks if is correct graphical view.
   *
   * @param connectorEnd a connector end
   * @param view a view
   * @return <code>true</code> if the view represents the role of the connector AND if the view is
   *     encapsulated as required by the nested path of the connector end
   */
  protected boolean isCorrectGraphicalView(final ConnectorEnd connectorEnd, final View view) {
    final NestedConnectorEnd nestedConnectorEnd =
        org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(
            connectorEnd, NestedConnectorEnd.class);
    final Property partWithPort = connectorEnd.getPartWithPort();
    // final ConnectableElement role = end.getRole();
    // 1. we get the top view of this view with the same semantic element
    View localView = getTopViewWithSameSemanticElement(view);

    // 2. we verify the part with port
    if (partWithPort != null) {
      View parent = getTopViewWithSameSemanticElement(ViewUtil.getViewContainer(localView));
      if (parent.getElement() != partWithPort) {
        return false;
      }
    }

    // 3. we verify the nested path
    if (nestedConnectorEnd != null && nestedConnectorEnd.getPropertyPath().size() > 0) {
      View parent = view;
      final List<Property> paths = nestedConnectorEnd.getPropertyPath();
      for (int i = paths.size() - 1; i >= 0; i--) {
        final Property currentProperty = paths.get(i);
        parent = getTopViewWithSameSemanticElement(ViewUtil.getViewContainer(parent));
        if (parent.getElement() != currentProperty) {
          return false;
        }
      }
    }
    return true;
  }
  /**
   * Get the snap back hint for the view.
   *
   * @param view the view to snap back.
   * @return the snap back hint.
   */
  private String getSnapBackHint(View view) {

    String diagramType = view.getDiagram().getType();
    String parentType = ViewUtil.getViewContainer(view).getType();
    String labelType = view.getType();

    return diagramType + "_" + parentType + "-" + labelType;
  }
  /**
   * This methods looks for inconsistent views to delete in case a Part aggregation kind changes.
   *
   * @param modifiedObject the modified {@link EObject}
   * @return the list of {@link View} to delete
   */
  protected Set<View> getViewsToDestroy(EObject modifiedObject) {
    Set<View> viewsToDestroy = new HashSet<View>();

    Iterator<View> viewIt =
        CrossReferencerUtil.getCrossReferencingViews(modifiedObject, ElementTypes.DIAGRAM_ID)
            .iterator();
    while (viewIt.hasNext()) {
      View view = viewIt.next();

      String containerType =
          ViewUtil.getViewContainer(view) != null
              ? ViewUtil.getViewContainer(view).getType()
              : null;

      if (SysMLGraphicalTypes.COMPARTMENT_SYSML_PART_AS_LIST_ID.equals(containerType)) {
        viewsToDestroy.add(view);
      }
    }

    return viewsToDestroy;
  }