public static void setStateMachineContextClasses(
     HashMap<org.eclipse.uml2.uml.StateMachine, Set<org.eclipse.uml2.uml.Class>> in_colContexts,
     ConfigurationSetter io_oConfigurationSetter) {
   for (StateMachine oStateMachine : in_colContexts.keySet()) {
     io_oConfigurationSetter.getName2StateMachine().put(oStateMachine.getName(), oStateMachine);
     HashMap<String, org.eclipse.uml2.uml.Class> oName2Class =
         new HashMap<String, org.eclipse.uml2.uml.Class>();
     io_oConfigurationSetter.getStateMachine2Name2Class().put(oStateMachine, oName2Class);
     for (org.eclipse.uml2.uml.Class oClass : in_colContexts.get(oStateMachine)) {
       oName2Class.put(oClass.getName(), oClass);
     }
   }
 }
  @Test
  public void shouldReturnFalseIfIsNotVariability2()
      throws ModelNotFoundException, ModelIncompleteException,
          SMartyProfileNotAppliedToModelExcepetion, IOException {

    String uri = getUrlToModel("variabilitySem");
    String absolutePath = new File(uri).getAbsolutePath();
    Package model = uml2Helper.load(absolutePath);

    org.eclipse.uml2.uml.Class klass = modelHelper.getAllClasses(model).get(0);
    assertNotNull(klass);

    assertEquals("Class1", klass.getName());
    assertFalse(StereotypeHelper.isVariability(klass));
  }
 public ComplexType find(Class source) {
   if (types == null) {
     types = Maps.newTreeMap(Comparators.stringComparator);
     for (IResourceDescription desc : index.getAllResourceDescriptions()) {
       for (IEObjectDescription objDesc :
           desc.getExportedObjectsByType(DatamodelPackage.eINSTANCE.getComplexType())) {
         ComplexType t = (ComplexType) objDesc.getEObjectOrProxy();
         types.put(t.getName(), t);
       }
     }
   }
   if (source.eIsProxy()) {
     throw new IllegalStateException("Proxy not resolved: " + source);
   }
   return types.get(source.getName());
 };
        public ComplexType configure(Class source, ComplexType target) {
          target.setName(source.getName());
          if (!source.getSuperClasses().isEmpty()) {
            ComplexType baseType = apply(source.getSuperClasses().get(0));
            target.setBaseType(baseType);
          }

          List<Property> properties =
              Lists.newArrayList(
                  Iterables.concat(
                      source.getOwnedAttributes(), getNavigableAssociationEnds(source)));
          Collections.sort(properties, Comparators.namedElementComparator);
          for (Property p : properties) {
            ElementDeclaration element = createElementDeclaration.apply(p);
            target.getElements().add(element);
          }

          target.setDoc(JavaExtensions.getDocumentationText(source));

          addXmiId(source, getXmiId(source));
          // target.getAnnotations().add(createTraceAnnotation.apply(source));

          return target;
        }
 /**
  * Computes the comma separated string for cvs output
  *
  * @return
  */
 public String commaSeparated() {
   String result = new String();
   result =
       "< " + name + "," + stateMachineName + "," + klass.getName() + "," + regionName + ">";
   return result;
 }
 /**
  * Overrides default toString
  *
  * @see java.lang.Object#toString()
  */
 public String toString() {
   String result = new String();
   result =
       "< " + name + " " + stateMachineName + " " + klass.getName() + " " + regionName + ">";
   return result;
 }
  /** {@inheritDoc} */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    if (!(selectedEObject instanceof Class)) {
      return null;
    }
    final Class selectedComposite = (Class) selectedEObject;

    CommandSupport.exec(
        Messages.CreateDepPlanHandler_CreateDPs,
        event,
        new Runnable() {

          public void run() {
            // execute with transaction support
            depPlans = DepPlanUtils.getDepPlanRoot(selectedComposite);
          }
        });

    try {
      String name = selectedComposite.getName() + DeployConstants.DepPlanPostfix;
      if (depPlans.getMember(name) != null) {
        Shell shell = new Shell();
        String dialogButtonLabels[] =
            new String[] {
              Messages.CreateDepPlanHandler_Cancel,
              Messages.CreateDepPlanHandler_Sync,
              Messages.CreateDepPlanHandler_CreateNew
            };
        MessageDialog dialog =
            new MessageDialog(
                shell,
                Messages.CreateDepPlanHandler_WhatShouldIDo,
                null,
                String.format(Messages.CreateDepPlanHandler_DPwithNameExistsAlready, name),
                MessageDialog.QUESTION,
                dialogButtonLabels,
                0);
        int result = dialog.open();
        if (result == 0) {
          return null;
        } else if (result == 1) {
          NamedElement existing = depPlans.getMember(name);
          if (existing instanceof Package) {
            DepPlanSync.syncDepPlan((Package) existing);
          } else {
            MessageDialog.openError(
                shell,
                Messages.CreateDepPlanHandler_CannotSync,
                String.format(Messages.CreateDepPlanHandler_DPwithNameExistsNoPackage, name));
          }
        } else {
          for (int i = 2; ; i++) {
            name = selectedComposite.getName() + DeployConstants.DepPlanPostfix + i;
            if (depPlans.getMember(name) == null) break;
          }
        }
      }
      final String depPlanName = name;

      CommandSupport.exec(
          Messages.CreateDepPlanHandler_CreateDP,
          event,
          new RunnableWithResult() {

            public CommandResult run() {
              Package cdp = depPlans.createNestedPackage(depPlanName);
              Stereotype st =
                  StereotypeUtil.apply(cdp, org.eclipse.papyrus.FCM.DeploymentPlan.class);
              if (st == null) {
                MessageDialog.openInformation(
                    new Shell(),
                    Messages.CreateDepPlanHandler_CannotCreateDP,
                    Messages.CreateDepPlanHandler_StereoApplicationFailed);
                return CommandResult.newErrorCommandResult(
                    Messages.CreateDepPlanHandler_CannotCreateDP);
              }
              try {
                InstanceSpecification newRootIS =
                    DepCreation.createDepPlan(
                        cdp, selectedComposite, DeployConstants.MAIN_INSTANCE, true);
                DepCreation.initAutoValues(newRootIS);
                return CommandResult.newOKCommandResult();
              } catch (TransformationException e) {
                MessageDialog.openInformation(
                    new Shell(), Messages.CreateDepPlanHandler_CannotCreateDP, e.getMessage());
                return CommandResult.newErrorCommandResult(e.getMessage());
              }
            }
          });

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
 public static String getComponentFileName(org.eclipse.uml2.uml.Class c, String end) {
   return c.getName() + end;
 }
Beispiel #9
0
  @Override
  protected void setUp() {
    super.setUp();

    pkg = umlf.createPackage();
    pkg.setName("pkg");

    valueType = pkg.createOwnedPrimitiveType("Value");
    valueType
        .createOwnedOperation(
            "<",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            "<=",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            ">",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);
    valueType
        .createOwnedOperation(
            ">=",
            new BasicEList<String>(Collections.singleton("v")),
            new BasicEList<Type>(Collections.singleton(valueType)),
            getUMLBoolean())
        .setIsQuery(true);

    thingType = pkg.createOwnedClass("Thing", false);

    values = thingType.createOwnedAttribute("values", valueType);
    values.setUpper(LiteralUnlimitedNatural.UNLIMITED);
    values.setIsOrdered(true);
    values.setIsUnique(true);

    bdValue = thingType.createOwnedAttribute("bdValue", getEcoreBigDecimal());
    biValue = thingType.createOwnedAttribute("biValue", getEcoreBigInteger());

    numeroType = pkg.createOwnedClass("Numero", false);

    numeroType
        .createOwnedOperation(
            "+",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "-",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "*",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "/",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            numeroType)
        .setIsQuery(true);

    numeroType
        .createOwnedOperation(
            "-", ECollections.<String>emptyEList(), ECollections.<Type>emptyEList(), numeroType)
        .setIsQuery(true);

    numeroType
        .createOwnedOperation(
            "<",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "<=",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            ">",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            ">=",
            new BasicEList<String>(Collections.singleton("n")),
            new BasicEList<Type>(Collections.singleton(numeroType)),
            getUMLBoolean())
        .setIsQuery(true);
    numeroType
        .createOwnedOperation(
            "asLong",
            ECollections.<String>emptyEList(),
            ECollections.<Type>emptyEList(),
            getEcoreLong())
        .setIsQuery(true);

    numeros = thingType.createOwnedAttribute("numeros", numeroType);
    numeros.setUpper(LiteralUnlimitedNatural.UNLIMITED);
    numeros.setIsOrdered(true);
    numeros.setIsUnique(true);

    comparable = pkg.createOwnedClass("Comparable", true);
    comparable
        .createOwnedOperation(
            "compareTo",
            new BasicEList<String>(Collections.singleton("c")),
            new BasicEList<Type>(Collections.singleton(comparable)),
            getUMLInteger())
        .setIsQuery(true);

    // the Ecore counterpart

    epkg = UMLUtil.convertToEcore(pkg, null).iterator().next();

    ethingType = (EClass) epkg.getEClassifier(thingType.getName());
    enumeros = (EReference) ethingType.getEStructuralFeature(numeros.getName());
    evalues = (EAttribute) ethingType.getEStructuralFeature(values.getName());
    ebdValue = (EAttribute) ethingType.getEStructuralFeature(bdValue.getName());
    ebiValue = (EAttribute) ethingType.getEStructuralFeature(biValue.getName());

    enumeroType = (EClass) epkg.getEClassifier(numeroType.getName());
    enumeroType.setInstanceClass(Numero.class);

    evalueType = (EDataType) epkg.getEClassifier(valueType.getName());
    evalueType.setInstanceClass(Value.class);

    efactory = epkg.getEFactoryInstance();
    thing = efactory.create(ethingType);

    EPackage.Registry.INSTANCE.put(epkg.getNsURI(), epkg);

    @SuppressWarnings("unchecked")
    EList<Numero> list = (EList<Numero>) thing.eGet(enumeros);
    list.add(new Numero(6));
    list.add(new Numero(2));
  }