Ejemplo n.º 1
0
 /**
  * Get, or create if there is none, a migration annotation for a group.
  *
  * @param source the source of the annotation
  * @param representation the DRepresentation
  * @param eObject the data of the annotation
  * @return the annotation entry
  */
 public static AnnotationEntry getOrCreateAnnotation(
     final String source, final DRepresentation representation, final EObject eObject) {
   AnnotationEntry annotation =
       new DRepresentationQuery(representation).getAnnotation(source, eObject).get();
   if (annotation == null && eObject != null) {
     annotation = DescriptionFactory.eINSTANCE.createAnnotationEntry();
     annotation.setSource(source);
     annotation.setData(eObject);
     representation.getOwnedAnnotationEntries().add(annotation);
   }
   return annotation;
 }
 /**
  * Get the {@link ComputedStyleDescriptionRegistry} of the specified {@link DDiagram}.
  *
  * @param createIfNotExists true if we want to create a {@link ComputedStyleDescriptionRegistry}
  *     for the specified {@link DDiagram} if there is not one, false otherwise
  * @return the {@link ComputedStyleDescriptionRegistry} of the {@link DDiagram} or null if this
  *     last has not one
  */
 public ComputedStyleDescriptionRegistry getComputedStyleDescriptionRegistry(
     boolean createIfNotExists) {
   ComputedStyleDescriptionRegistry computedStyleDescriptionRegistry = null;
   AnnotationEntry annotationEntry = null;
   Collection<AnnotationEntry> annotationEntries =
       new DRepresentationQuery(dDiagram)
           .getAnnotation(BestStyleDescriptionRegistry.DANNOTATION_CUSTOMIZATION_KEY);
   if (annotationEntries == null || annotationEntries.isEmpty()) {
     annotationEntry = DescriptionFactory.eINSTANCE.createAnnotationEntry();
     annotationEntry.setSource(BestStyleDescriptionRegistry.DANNOTATION_CUSTOMIZATION_KEY);
     dDiagram.getOwnedAnnotationEntries().add(annotationEntry);
   } else {
     annotationEntry = annotationEntries.iterator().next();
   }
   if (annotationEntry.getData() == null
       || !(annotationEntry.getData() instanceof ComputedStyleDescriptionRegistry)) {
     computedStyleDescriptionRegistry =
         DiagramFactory.eINSTANCE.createComputedStyleDescriptionRegistry();
     annotationEntry.setData(computedStyleDescriptionRegistry);
   } else {
     computedStyleDescriptionRegistry =
         (ComputedStyleDescriptionRegistry) annotationEntry.getData();
   }
   return computedStyleDescriptionRegistry;
 }