/**
  * Refresh the visibility of all dview diagrams elements.
  *
  * @param view the view containing diagrams to refresh elements.
  * @param transactionalEditingDomain the editing domain.
  * @param migrationCommandExecutor the command executor to execute the {@link
  *     RefreshAllElementsVisibilityCommand}
  */
 public void refreshAllElementsVisibility(
     final DView view,
     TransactionalEditingDomain transactionalEditingDomain,
     MigrationCommandExecutor migrationCommandExecutor) {
   for (final DRepresentation representation : view.getOwnedRepresentations()) {
     if (representation instanceof DDiagram) {
       Command refreshAllElementsVisibilityCommand =
           new RefreshAllElementsVisibilityCommand((DDiagram) representation);
       migrationCommandExecutor.execute(
           transactionalEditingDomain, refreshAllElementsVisibilityCommand);
     }
   }
 }
  /**
   * refresh representations.
   *
   * @param dAnalysis {@link DAnalysis} to refresh.
   * @param view current {@link DView}
   */
  public void refreshRepresentations(final DAnalysis dAnalysis, final DView view) {
    TransactionalEditingDomain transactionalEditingDomain =
        TransactionUtil.getEditingDomain(dAnalysis);
    boolean hasAlreadyModel = false;
    // The old representations have no a model.
    if (view instanceof DRepresentationContainer) {
      if (!((DAnalysis) view.eContainer()).getModels().isEmpty()) {
        // Set hasAlreadyModel to true only if almost one of the models
        // is not a proxy
        for (EObject model : ((DAnalysis) view.eContainer()).getModels()) {
          if (!model.eIsProxy()) {
            hasAlreadyModel = true;
          }
        }
      } else if (!hasAlreadyModel) {
        final Map<EObject, AnyType> extension =
            ((XMIResource) dAnalysis.eResource()).getEObjectToExtensionMap();
        final AnyType viewSettings = extension.get(view);
        if (viewSettings != null) {
          for (final FeatureMap.Entry feature : viewSettings.getMixed()) {
            if ("model".equals(feature.getEStructuralFeature().getName())) {
              ((DAnalysis) view.eContainer())
                  .getModels()
                  .add(
                      EcoreUtil.resolve(
                          (EObject) feature.getValue(), view.eResource().getResourceSet()));
              hasAlreadyModel = true;
            }
          }
        }
      }
    }

    // Command prepareImportsFromSessionCommand = new
    // PrepareImportsFromSessionCommand(this, view);
    MigrationCommandExecutor migrationCommandExecutor = new MigrationCommandExecutor();

    Command prepareImportsFromSessionCommand =
        new IdentityCommand() {
          @Override
          public void execute() {
            // Not seem to be necessary (done by handle view command)
            // initAnalysis(view);
            for (final EObject model : ((DAnalysis) view.eContainer()).getModels()) {
              if (!model.eIsProxy()) {
                InterpreterRegistry.prepareImportsFromSession(
                    SiriusPlugin.getDefault().getInterpreterRegistry().getInterpreter(model),
                    SessionManager.INSTANCE.getSession(model));
              }
            }
            for (DRepresentation dRepresentation : view.getOwnedRepresentations()) {
              DialectManager.INSTANCE.refresh(dRepresentation, new NullProgressMonitor());
            }
          }

          @Override
          public boolean canUndo() {
            return false;
          }
        };

    migrationCommandExecutor.execute(transactionalEditingDomain, prepareImportsFromSessionCommand);

    // This method calls a RecordingCommand
    refreshLostDiagramElements(view);

    refreshAllElementsVisibility(view, transactionalEditingDomain, migrationCommandExecutor);

    // if (!hasAlreadyModel) {
    // deinformModel((DRepresentationContainer) view);
    // }
    // Recompute the models references after the refresh.
    // Command cleanModelsCommand = new CleanModelsCommand(this, dAnalysis,
    // true);
    // migrationCommandExecutor.execute(transactionalEditingDomain,
    // cleanModelsCommand);
  }