/**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.sirius.diagram.business.api.componentization.DiagramMappingsManagerRegistry#getDiagramMappingsManager(Session,
   *     DDiagram)
   */
  @Override
  public DiagramMappingsManager getDiagramMappingsManager(
      final Session session, final DDiagram diagram) {
    if (diagram == null) {
      throw new IllegalArgumentException(
          Messages.DiagramMappingsManagerRegistryImpl_diagramParamErrorMsg);
    }
    if (diagramMappingsManagers.containsKey(diagram)) {
      return diagramMappingsManagers.get(diagram);
    } else {
      final DiagramDescription desc = diagram.getDescription();
      final DiagramDescriptionMappingsRegistry mappingsRegistry =
          DiagramDescriptionMappingsRegistry.INSTANCE;
      final DiagramDescriptionMappingsManager descManager =
          mappingsRegistry.getDiagramDescriptionMappingsManager(session, desc);

      final DiagramMappingsManager newManager =
          new DiagramMappingsManagerImpl(diagram, descManager);
      diagram.eAdapters().add(this);
      if (session != null) {
        newManager.computeMappings(session.getSelectedViewpoints(false), false);
      } else {
        newManager.computeMappings(null, false);
      }
      diagramMappingsManagers.put(diagram, newManager);
      return newManager;
    }
  }
 private void removeSemanticListener(final DDiagram dia) {
   dia.eAdapters().remove(viewpointListener);
 }
 private void addSemanticListener(final DDiagram viewPoint) {
   viewPoint.eAdapters().add(viewpointListener);
 }