/** Refreshes the stereotype display */
 protected void refreshAppliedStereotypesPropertiesInCompartment(
     String stereotypesPropertiesToDisplay, IPapyrusNodeUMLElementFigure figure) {
   final boolean displayInCompartment =
       AppliedStereotypeHelper.hasAppliedStereotypesPropertiesToDisplay(
           (View) (View) getHost().getModel(),
           UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);
   // if the string is not empty, then, the figure has to display it. Else,
   // it displays nothing
   final GraphicalEditPart editPart = (GraphicalEditPart) getHost();
   final View node = editPart.getNotationView();
   int i = 0;
   // we go through all sub nodes
   while (i < node.getChildren().size()) {
     if ((node.getChildren().get(i)) instanceof Node) {
       final Node currentNode = (Node) (node.getChildren().get(i));
       if (currentNode.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
         EObject stereotypeApplication = currentNode.getElement();
         Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
         if (stereotype != null
             && stereotypesPropertiesToDisplay.contains(stereotype.getQualifiedName())) {
           setVisivility(currentNode, displayInCompartment);
         } else {
           setVisivility(currentNode, false);
         }
       }
     }
     i++;
   }
 }
  /**
   * this method suppress the sub-nodes that references the stereotype application it cleans also
   * all sub-nodes with the type ApplicationStereotype that not references an application of
   * stereotypes (this is the case when a stereotype has been unapplied without suppress the
   * compartment.
   *
   * @param stereotypeApplication
   */
  public void removeAppliedStereotypeCompartment(final EObject stereotypeApplication) {
    if (stereotypeApplication == null) {
      return;
    }
    final GraphicalEditPart editPart = (GraphicalEditPart) getHost();
    final View node = editPart.getNotationView();
    try {
      int i = 0;
      // we go through all sub nodes
      while (i < node.getChildren().size()) {
        if ((node.getChildren().get(i)) instanceof Node) {
          final Node currentNode = (Node) (node.getChildren().get(i));
          // it references the stereotype application?
          if (stereotypeApplication.equals(currentNode.getElement())) {
            // yes, Execution of the Deletion command
            editPart
                .getEditingDomain()
                .runExclusive(
                    new Runnable() {

                      public void run() {
                        Display.getCurrent()
                            .asyncExec(
                                new Runnable() {

                                  public void run() {
                                    DeleteCommand command = new DeleteCommand(currentNode);
                                    editPart
                                        .getEditingDomain()
                                        .getCommandStack()
                                        .execute(new GMFtoEMFCommandWrapper(command));
                                  }
                                });
                      }
                    });
          }
          // the sub nodes has the type appliedStereotypeCompartment but does not references a
          // application of stereotype
          if ((currentNode.getType().equals(AppliedStereotypeConpartmentEditPart.ID))
              && (!(currentNode.getElement() instanceof DynamicEObjectImpl))) {
            // yes, Execution of the Deletion command
            editPart
                .getEditingDomain()
                .runExclusive(
                    new Runnable() {

                      public void run() {
                        Display.getCurrent()
                            .asyncExec(
                                new Runnable() {

                                  public void run() {
                                    DeleteCommand command = new DeleteCommand(currentNode);
                                    editPart
                                        .getEditingDomain()
                                        .getCommandStack()
                                        .execute(new GMFtoEMFCommandWrapper(command));
                                  }
                                });
                      }
                    });
          }
        }
        i++;
      }
    } catch (Exception e) {
      System.err.println(e);
    }
  }