Search in sources :

Example 6 with BasicTypeFieldProvider

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider in project kie-wb-common by kiegroup.

the class AbstractFieldManager method registerFieldProvider.

protected void registerFieldProvider(FieldProvider provider) {
    boolean isMultiple = provider instanceof MultipleValueFieldProvider;
    if (provider instanceof BasicTypeFieldProvider) {
        BasicTypeFieldProvider basicTypeProvider = (BasicTypeFieldProvider) provider;
        if (isMultiple) {
            basicMultipleProviders.add(basicTypeProvider);
        } else {
            basicProviders.add(basicTypeProvider);
        }
    } else {
        if (isMultiple) {
            multipleEntityTypeFieldProvider.put(provider.getFieldTypeName(), provider);
        } else {
            entityTypeFieldProvider.put(provider.getFieldTypeName(), provider);
        }
    }
    providersByFieldCode.put(provider.getFieldTypeName(), provider);
    providerByFieldType.put(provider.getFieldType(), provider);
}
Also used : BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)

Example 7 with BasicTypeFieldProvider

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider in project kie-wb-common by kiegroup.

the class FormDefinitionSerializerImplTest method initTest.

@Before
public void initTest() {
    fieldManager = new TestFieldManager();
    definitionSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    JavaFormModel model = new PortableJavaModel("org.test.MyParentModel");
    formDefinition = new FormDefinition(model);
    formDefinition.setId("testForm");
    formDefinition.setName("testForm");
    formDefinition.setLayoutTemplate(new LayoutTemplate());
    for (BasicTypeFieldProvider provider : fieldManager.getAllBasicTypeProviders()) {
        for (String type : provider.getSupportedTypes()) {
            FieldDefinition field = provider.getFieldByType(new TypeInfoImpl(type));
            assertNotNull(field);
            String fieldDescription = provider.getFieldTypeName() + "_" + type;
            field.setName(fieldDescription);
            field.setLabel(fieldDescription);
            field.setStandaloneClassName(type);
            field.setBinding(fieldDescription);
            model.getProperties().add(new ModelPropertyImpl(fieldDescription, new TypeInfoImpl(type)));
            formDefinition.getFields().add(field);
        }
    }
    SubFormFieldDefinition subForm = new SubFormFieldDefinition();
    subForm.setLabel("SubForm");
    subForm.setNestedForm("");
    subForm.setBinding("model");
    subForm.setStandaloneClassName("org.test.MyTestModel");
    subForm.setBinding("SubForm");
    formDefinition.getFields().add(subForm);
    model.getProperties().add(new ModelPropertyImpl(subForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, subForm.getStandaloneClassName(), false)));
    MultipleSubFormFieldDefinition multipleSubForm = new MultipleSubFormFieldDefinition();
    multipleSubForm.setLabel("MultipleSubForm");
    multipleSubForm.setCreationForm("");
    multipleSubForm.setEditionForm("");
    multipleSubForm.setStandaloneClassName("org.test.MyTestModel");
    multipleSubForm.setBinding("MultipleSubForm");
    formDefinition.getFields().add(multipleSubForm);
    model.getProperties().add(new ModelPropertyImpl(multipleSubForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, multipleSubForm.getStandaloneClassName(), true)));
    EnumListBoxFieldDefinition enumListBox = new EnumListBoxFieldDefinition();
    enumListBox.setLabel("EnumListBox");
    enumListBox.setBinding("EnumListBox");
    enumListBox.setStandaloneClassName("org.test.MyTestModel");
    formDefinition.getFields().add(enumListBox);
    model.getProperties().add(new ModelPropertyImpl(enumListBox.getBinding(), new TypeInfoImpl(TypeKind.ENUM, enumListBox.getStandaloneClassName(), false)));
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider) Before(org.junit.Before)

Aggregations

BasicTypeFieldProvider (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)7 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)3 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)3 Test (org.junit.Test)2 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)2 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)2 TypeInfo (org.kie.workbench.common.forms.model.TypeInfo)2 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Before (org.junit.Before)1 EnumListBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition)1 EntityRelationField (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField)1 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)1 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)1 TestFieldManager (org.kie.workbench.common.forms.fields.test.TestFieldManager)1 TestMetaDataEntryManager (org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager)1 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)1 JavaFormModel (org.kie.workbench.common.forms.model.JavaFormModel)1 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)1