public void synchronize(FormCollection fc) throws Exception {
    InternalModification.dontMoveToDisabled();
    removeInvalide(fc);

    EList<FormContainer> forms = fc.getForms();
    for (FormContainer formContainer : forms) {
      synchronizeFormContainer(formContainer);
    }

    // add Missing FormClass (new Class in dt model)

    if (addNewFormClass) {
      // get All Class
      Collection<AbstractClass> missing = getAllClassesFromReferedModels(fc);
      for (AbstractClass abstractClass : missing) {

        if (!(abstractClass instanceof Clazz) ^ !((Clazz) abstractClass).isAbstract()) {
          FormContainer formContainer = null;

          if (!CommonServices.isNativeModel(abstractClass) || includeAlfrescoNativeClass) {

            if (fc instanceof ClassFormCollection) {
              formContainer = FormFactory.eINSTANCE.createFormClass();
              setFormContainer(abstractClass, formContainer);
              formContainer.setId(abstractClass.getName());
              formContainer.setLabel(abstractClass.getLabel());
            } else if (fc instanceof SearchFormCollection) {
              formContainer = FormFactory.eINSTANCE.createFormSearch();
              setFormContainer(abstractClass, formContainer);
              SearchInitialization.initializeFormProperties((FormSearch) formContainer);
            } else if (fc instanceof WorkflowFormCollection) {
              formContainer = FormFactory.eINSTANCE.createFormWorkflow();
            }

            if (headless) {
              fc.getForms().add(formContainer);
            } else {
              cc.append(
                  AddCommand.create(
                      domain, fc, FormPackage.eINSTANCE.getFormCollection_Forms(), formContainer));
            }
            if (formContainer instanceof ClassReference) {
              synchronizeFormContainer(formContainer);
            }
          }
        }
      }
    }
    InternalModification.moveToDisabled();
  }
  @SuppressWarnings("unchecked")
  Collection<AbstractClass> getAllClassesFromReferedModels(FormCollection fc) {
    Set<AbstractClass> existing = new HashSet<AbstractClass>();
    Set<AbstractClass> all = new HashSet<AbstractClass>();

    EList<FormContainer> forms = fc.getForms();
    for (FormContainer formContainer : forms) {
      if (formContainer instanceof ClassReference) {
        ClassReference cr = (ClassReference) formContainer;
        AbstractClass real_class = cr.getReal_class();
        if (real_class instanceof Clazz) {
          existing.add(real_class);
        }
      }
    }
    List<Model> lm = new ArrayList<Model>();

    for (AbstractClass abstractClass : existing) {
      EObject rootContainer2 = CommonServices.getRootContainer(abstractClass);
      if (rootContainer2 instanceof Model) {
        Model rootContainer = (Model) rootContainer2;
        lm.add(rootContainer);
      }
    }

    for (Model package1 : lm) {
      EList<Clazz> allClasses = package1.getAllClasses();
      all.addAll(allClasses);
    }

    return CollectionUtils.subtract(all, existing);
  }