Esempio n. 1
0
  public RefOntoUML.DataType DealDataType(org.eclipse.uml2.uml.DataType dt1) {
    RefOntoUML.DataType dt2 = null;

    if (dt1 instanceof org.eclipse.uml2.uml.PrimitiveType) {
      // FIXME: Esperar consertarem esse Bug 262140 -  UML primitive types cannot be accessed
      System.out.print("<PrimitiveType> ");
      dt2 = myfactory.createPrimitiveType();
    } else if (dt1 instanceof org.eclipse.uml2.uml.Enumeration) {
      System.out.print("<Enumeration> ");
      dt2 = myfactory.createEnumeration();
    } else {
      System.out.print("<DataType> ");
      dt2 = myfactory.createDataType();
    }

    DealClassifier(dt1, dt2);

    // Attributes
    RefOntoUML.Property p2;
    for (org.eclipse.uml2.uml.Property p1 : dt1.getAttributes()) {
      p2 = myfactory.createProperty();
      DealProperty(p1, p2);
      dt2.getOwnedAttribute().add(p2);
    }

    // Enumeration Literals
    if (dt1 instanceof org.eclipse.uml2.uml.Enumeration) {
      org.eclipse.uml2.uml.Enumeration enum1 = (org.eclipse.uml2.uml.Enumeration) dt1;
      RefOntoUML.Enumeration enum2 = (RefOntoUML.Enumeration) dt2;

      RefOntoUML.EnumerationLiteral el2;
      for (org.eclipse.uml2.uml.EnumerationLiteral el1 : enum1.getOwnedLiterals()) {
        System.out.print("    <EnumLiteral> ");
        el2 = myfactory.createEnumerationLiteral();
        DealNamedElement(el1, el2);

        enum2.getOwnedLiteral().add(el2);
      }
    }

    return dt2;
  }
Esempio n. 2
0
 /** @generated */
 protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
     throws ExecutionException {
   EnumerationLiteral newElement = UMLFactory.eINSTANCE.createEnumerationLiteral();
   EObject target = getElementToEdit();
   ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
   if (data.isPermitted()) {
     if (data.isPathDefined()) {
       if (!data.execute(target, newElement))
         return CommandResult.newErrorCommandResult(
             "Failed to follow the policy-specified for the insertion of the new element");
     } else {
       Enumeration qualifiedTarget = (Enumeration) target;
       qualifiedTarget.getOwnedLiterals().add(newElement);
     }
   } else {
     return CommandResult.newErrorCommandResult(
         "The active policy restricts the addition of this element");
   }
   ElementInitializers.getInstance().init_EnumerationLiteral_3066(newElement);
   doConfigure(newElement, monitor, info);
   ((CreateElementRequest) getRequest()).setNewElement(newElement);
   return CommandResult.newOKCommandResult(newElement);
 }