Exemplo n.º 1
0
  public void updateAttributeFields(
      FormContainer formContainer, FormElement formElement, Attribute att) {
    FormElement fieldForAttribute = null;
    if (formContainer instanceof FormSearch) {
      fieldForAttribute = SearchInitialization.getSearchFieldForAttribute(att);
    } else if (formContainer instanceof FormClass || formContainer instanceof FormWorkflow) {
      fieldForAttribute = ClassDiagramUtils.getFieldForAttribute(att);
    }

    if (!fieldForAttribute.getClass().isInstance(formElement)) {
      // mismatch so we replace the Field
      FormGroup eContainer = (FormGroup) formElement.eContainer();
      boolean contains = eContainer.getChildren().contains(formElement);

      if (headless) {
        EList<FormElement> children = null;
        if (contains) {
          children = eContainer.getChildren();
        } else {
          children = eContainer.getDisabled();
        }
        // add the new Field
        children.add(fieldForAttribute);
        // remove
        children.remove(formElement);
      } else {
        if (contains) {
          cc.append(
              AddCommand.create(
                  domain,
                  eContainer,
                  FormPackage.eINSTANCE.getFormGroup_Children(),
                  fieldForAttribute));
        } else {
          cc.append(
              AddCommand.create(
                  domain,
                  eContainer,
                  FormPackage.eINSTANCE.getFormGroup_Disabled(),
                  fieldForAttribute));
        }
        Command rmCmd = RemoveCommand.create(domain, formElement);
        cc.append(rmCmd);
      }
    }
  }
Exemplo n.º 2
0
  void removeInvalide(EObject o) {
    CompoundCommand removeCommands = new CompoundCommand();
    List<EObject> validationErrors = EcoreHelper.getValidationErrors(o);
    for (EObject eObject : validationErrors) {
      if (eObject instanceof FormElement) {

        System.out.println("SynchronizeWithClass.removeInvalide() remove :" + eObject);
        if (headless) {
          EList<?> children = null;
          EObject eContainer = eObject.eContainer();
          System.out.println("SynchronizeWithClass.removeInvalide() eContainer :" + eContainer);
          if (eContainer != null) {
            if (eContainer instanceof FormGroup) {
              FormGroup fg = (FormGroup) eContainer;

              if (fg.getChildren().contains(eObject)) {
                children = fg.getChildren();
              } else if (fg.getDisabled().contains(eObject)) {
                children = fg.getDisabled();
              }
            } else if (eContainer instanceof FormCollection) {
              children = ((FormCollection) eContainer).getForms();
            }

            boolean remove = children.remove(eObject);
            System.out.println("SynchronizeWithClass.removeInvalide() removed? " + remove);
          } else {
            System.out.println("SynchronizeWithClass.removeInvalide() allready removed !");
          }

        } else {
          Command delCmd = RemoveCommand.create(domain, eObject);
          removeCommands.append(delCmd);
        }
      }
    }
    if (!headless) {
      domain.getCommandStack().execute(removeCommands);
    }
  }
Exemplo n.º 3
0
 protected void addChild(FormGroup fw, FormElement f) {
   if (headless) {
     fw.getChildren().add(f);
   } else {
     Command create =
         AddCommand.create(domain, fw, FormPackage.eINSTANCE.getFormGroup_Children(), f);
     boolean canExecute = create.canExecute();
     System.out.println(
         "SynchronizeWorkflowFormWithClass.addChild() canExecute :"
             + fw.getId()
             + "->"
             + f
             + canExecute);
     cc.append(create);
   }
 }