Ejemplo n.º 1
0
 /**
  * Collecting all properties from a EMF object, if contansReferences is TRUE, all features should
  * be contained, otherwise, only EAttrubutes will be returned.
  */
 public static List<EStructuralFeature> collectProperties(
     EClass eClass,
     boolean containsSupers,
     boolean containsReferences,
     boolean containsUnsettables) {
   if (eClass == null) {
     return Collections.emptyList();
   }
   List<EStructuralFeature> properties = new ArrayList<EStructuralFeature>();
   List<EStructuralFeature> features = null;
   if (containsReferences) {
     features = eClass.getEStructuralFeatures();
   } else {
     features = new ArrayList<EStructuralFeature>(eClass.getEAttributes());
   }
   for (EStructuralFeature sf : features) {
     try {
       if (containsUnsettables || eClass.eIsSet(sf)) {
         properties.add(sf);
       }
     } catch (Exception e) {
     }
   }
   if (containsSupers) {
     EList<EClass> eSuperTypes = eClass.getESuperTypes();
     for (EClass eSuperClass : eSuperTypes) {
       properties.addAll(
           collectProperties(
               eSuperClass, containsSupers, containsReferences, containsUnsettables));
     }
   }
   return properties;
 }
Ejemplo n.º 2
0
 public String getClassAttributes(EClass eClass) {
   // if attributes exist
   if (eClass.getEAttributes().size() > 0) {
     StringBuilder sb = new StringBuilder();
     sb.append("\\subsubsection*{Attributes}\n");
     sb.append("\\begin{itemize}\n");
     // for each attribute
     for (EAttribute eAttribute : eClass.getEAttributes()) {
       sb.append("\\item ");
       // Name
       sb.append(eAttribute.getName()).append(": ");
       // Type
       if (eAttribute.getEAttributeType().getInstanceClass() != null) {
         sb.append(eAttribute.getEAttributeType().getInstanceClass().getSimpleName()).append(" ");
       } else {
         sb.append("\\nameref{").append(eAttribute.getEAttributeType().getName()).append("} ");
       }
       // Mult
       sb.append(getMultiplicity(eAttribute)).append(" ");
       // Default Value
       if (eAttribute.getDefaultValue() != null) {
         sb.append(" \\textit{~=~").append(eAttribute.getDefaultValue()).append("} ");
       }
       // Description
       if (getLatexDocAnnotation(
               eAttribute, prefs.getPreferenceString(PreferenceConstants.P_DESCRIPTION_KEY))
           != null) {
         sb.append("\\newline\n")
             .append(
                 getLatexDocAnnotation(
                     eAttribute,
                     prefs.getPreferenceString(PreferenceConstants.P_DESCRIPTION_KEY)));
       }
       sb.append("\n");
     } // for each attribute
     sb.append("\\end{itemize}");
     return sb.toString();
   }
   return "\\subsubsection*{Attributes} ~\\\\ No additional attributes";
 }