/**
   * Update connections after EditPart was collapsed/opened.
   *
   * @param collapseEvent
   */
  public void updateConnections(final Notification collapseEvent) {

    editPartOfCompartment = (ShapeNodeEditPart) compartmentToSupport.getParent();

    compartmentChildren = EditPartService.getAllShapesInSideCompartment(compartmentToSupport);

    if (collapseEvent.getNewBooleanValue()) {
      collapseEditPart();
    } else {
      openEditPart();
    }
  }
 /**
  * @return Returns view for corresponding model element.
  * @param containerEditPart Edit part containing the given shape.
  * @param shapeOfNode Model shape of the view to be searched and returned.
  */
 private static NodeImpl getViewFromModel(
     final EditPart containerEditPart, final Shape shapeOfNode) {
   final List<EditPart> editParts =
       EditPartService.getAllShapesInSideCompartment(containerEditPart);
   for (final EditPart i : editParts) {
     if (i.getModel() instanceof NodeImpl) {
       final NodeImpl shapeImpl = (NodeImpl) i.getModel();
       final Shape element = (Shape) shapeImpl.getElement();
       if (element.equals(shapeOfNode)) {
         return shapeImpl;
       }
     }
   }
   return null;
 }
  /** @return Returns all connections from the children. */
  @SuppressWarnings("unchecked")
  private Set<ConnectionEditPart> getChildrenConnections() {
    final List<EditPart> children =
        EditPartService.getAllShapesInSideCompartment(compartmentToSupport);

    final Set<ConnectionEditPart> childrenConnections = new HashSet<ConnectionEditPart>();

    // all connections from inside
    for (final EditPart o : children) {
      if (o instanceof GraphicalEditPart) {
        childrenConnections.addAll(((GraphicalEditPart) o).getSourceConnections());
        childrenConnections.addAll(((GraphicalEditPart) o).getTargetConnections());
      }
    }
    return childrenConnections;
  }
  /**
   * @param connections
   * @return Returns the given connections without intra-connections, i.e. connections between
   *     children or connections between child and parent.
   */
  private Set<ConnectionEditPart> excludeInternConnections(
      final Set<ConnectionEditPart> connections) {
    final List<EditPart> internalParts =
        EditPartService.getAllShapesInSideCompartment(compartmentToSupport);

    // connections from children to its parent are also internal
    internalParts.add(editPartOfCompartment);

    for (final ConnectionEditPart c : connections) {
      // check if connection has one end outside of compartment
      if (internalParts.contains(c.getSource()) ^ internalParts.contains(c.getTarget())) {
        connections.add(c);
      }
    }

    return connections;
  }