@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); }
void addMissing(FormContainer o, List<FormElement> allchildren) { if (o instanceof ClassReference) { // get the attached class ClassReference cr = (ClassReference) o; AbstractClass real_class = cr.getReal_class(); addMissing(o, allchildren, real_class, null); } }
protected void updateFormContainerId(FormContainer formContainer) { if (formContainer instanceof FormSearch) { SearchInitialization.initializeFormProperties((FormSearch) formContainer); updateId(formContainer, formContainer.getId()); } else if (formContainer instanceof ClassReference) { ClassReference cref = (ClassReference) formContainer; AbstractClass abstractClass = cref.getReal_class(); if (!abstractClass.getName().equals(formContainer.getId())) { updateId(formContainer, abstractClass.getName()); } } }
void update(FormContainer formContainer, List<FormElement> allchildren) { // update id if (updateId) { updateFormContainerId(formContainer); } if (updateLabel) { updateLabel( formContainer, ((TitledNamedClassModelElement) formContainer.getRef()).getLabel()); } for (FormElement formElement : allchildren) { ModelElement ref = formElement.getRef(); if (ref instanceof NamedModelElement) { NamedModelElement nme = (NamedModelElement) ref; String name = nme.getName(); if (updateId && !name.equals(formElement.getId())) { updateId(formElement, name); } if (updateLabel && ref instanceof TitledNamedClassModelElement) { updateLabel(formContainer, ((TitledNamedClassModelElement) ref).getLabel()); } } // check Field subType if (ref instanceof Attribute) { Attribute att = (Attribute) ref; updateAttributeFields(formContainer, formElement, att); } else if (ref instanceof Association) { Association ass = (Association) ref; if (formElement instanceof ModelChoiceField) { ModelChoiceField mcf = (ModelChoiceField) formElement; ClassReference cref = (ClassReference) formContainer; AbstractClass srcClazz = cref.getReal_class(); updateModelChoiceField(srcClazz, ass, mcf); } } } }
protected void setFormContainer(AbstractClass abstractClass, FormContainer formContainer) { ClassReference cref = (ClassReference) formContainer; cref.setReal_class(abstractClass); }