コード例 #1
0
  public void updateModelChoiceField(
      AbstractClass srcClazz, Association ass, ModelChoiceField mcf) {

    ModelChoiceField modelChoiceFieldForAssociation =
        ClassDiagramUtils.getModelChoiceFieldForAssociation(ass, srcClazz);

    int parseInt = modelChoiceFieldForAssociation.getMax_bound();
    // at least bounds must be compatible with constraints in the dt model
    boolean b = (((ModelChoiceField) mcf).getMax_bound() > parseInt) && (parseInt != -1);
    if (headless) {
      if (b) {
        mcf.setMax_bound(parseInt);
      }
    } else {
      if (b) {
        cc.append(
            SetCommand.create(
                domain, mcf, FormPackage.eINSTANCE.getModelChoiceField_Max_bound(), parseInt));
      }
    }
    // maybe the name or Label have been changed must be based on target name/Label if exists
    String id = modelChoiceFieldForAssociation.getId();
    if (updateId && !id.equals(mcf.getId())) {
      updateId(mcf, id);
    }
    String label = modelChoiceFieldForAssociation.getLabel();
    if (updateLabel && !label.equals(mcf.getLabel())) {
      updateLabel(mcf, label);
    }
  }
コード例 #2
0
  protected void synchronizeMissingAssociations(
      FormContainer o,
      List<FormElement> children,
      AbstractClass real_class,
      Set<FormGroup> groups,
      String filterNS) {

    List<Association> allAssociations = real_class.getAllSourceAssociations();

    // get FormElement that miss
    ArrayList<Association> missAtt = new ArrayList<Association>();

    if (allAssociations != null) {
      missAtt.addAll(allAssociations);
    }

    for (FormElement formElement : children) {
      ModelElement ref = formElement.getRef();
      if (ref != null && ref instanceof Association) {
        // linked element is attribute so remove this attribute from the missing list
        missAtt.remove(ref);
      }
    }

    EList<FormGroup> allSubGroups = o.getAllSubGroups();
    groups.addAll(allSubGroups);

    // now we have the attribute missing list
    // initialize missing Field
    for (Association ass : missAtt) {

      FormElement fieldForAssociation = null;
      if (o instanceof FormClass || o instanceof FormWorkflow) {
        fieldForAssociation = ClassDiagramUtils.getModelChoiceFieldForAssociation(ass, real_class);
      } else if (o instanceof FormSearch) {
        fieldForAssociation =
            ClassDiagramUtils.transformAssociationIntoModelChoiceSearchField(ass, real_class);
      }

      if (WorkflowInitialization.filterFormElement(filterNS, fieldForAssociation)) {

        // get where to add the field
        FormGroup parent = null;
        // mybe a group exist with ref to the attribute container

        // search for matching group

        for (FormGroup formGroup : groups) {
          ModelElement ref = formGroup.getRef();
          if (ref instanceof AbstractClass
              && ((AbstractClass) ref).getSourceAssociations().contains(ass)) {
            // matching group founded
            parent = formGroup;
            break;
          }
        }

        if (createMissingGroup && parent == null) {
          AbstractClass source = null;
          EList<AbstractClass> sources = ass.getSource();
          if (sources.size() == 1) {
            source = sources.get(0);
          } else {
            EList<AbstractClass> allLinkedAbstractClass = real_class.getAllLinkedAbstractClass();
            boolean contains = allLinkedAbstractClass.contains(sources.get(0));
            if (contains) {
              source = sources.get(0);
            } else {
              source = sources.get(1);
            }
          }
          parent = ClassInitialization.createGroup(source);
          addChild(o, parent);
        }

        // add new Field to the parent
        if (parent == null) {
          parent = o;
        }
        addChild(parent, fieldForAssociation);
      }
    }
  }