Search in sources :

Example 31 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormGeneratorDriver method lookupComponent.

protected LayoutDragComponent lookupComponent(LayoutComponent layoutComponent) {
    Class<? extends LayoutDragComponent> clazz = componentsCache.get(layoutComponent.getDragTypeName());
    if (clazz == null) {
        SyncBeanDef dragTypeDef = beanManager.lookupBeans(layoutComponent.getDragTypeName()).iterator().next();
        componentsCache.put(layoutComponent.getDragTypeName(), dragTypeDef.getBeanClass());
        clazz = dragTypeDef.getBeanClass();
    }
    LayoutDragComponent dragComponent = instance.select(clazz).get();
    if (dragComponent instanceof FieldLayoutComponent) {
        FieldLayoutComponent fieldComponent = (FieldLayoutComponent) dragComponent;
        FieldDefinition field = renderingContext.getRootForm().getFieldById(layoutComponent.getProperties().get(FieldLayoutComponent.FIELD_ID));
        fieldComponent.init(renderingContext, field);
        layoutComponents.add(fieldComponent);
    }
    return dragComponent;
}
Also used : LayoutDragComponent(org.uberfire.ext.layout.editor.client.api.LayoutDragComponent) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef)

Example 32 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class AbstractFieldManager method getDefinitionByDataType.

@Override
public FieldDefinition getDefinitionByDataType(TypeInfo typeInfo) {
    if (!TypeKind.OBJECT.equals(typeInfo.getType())) {
        return getFieldDefinitionFromBasicProvider(typeInfo);
    }
    FieldProvider provider;
    if (typeInfo.isMultiple()) {
        provider = multipleEntityTypeFieldProvider.get(defaultMultipleEntity);
    } else {
        provider = entityTypeFieldProvider.get(defaultSingleEntity);
    }
    if (provider != null) {
        FieldDefinition instance = provider.getFieldByType(typeInfo);
        instance.setStandaloneClassName(typeInfo.getClassName());
        return instance;
    }
    return null;
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)

Example 33 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FieldManagerTest method testGetDefaultFieldTypes.

@Test
public void testGetDefaultFieldTypes() {
    for (String typeCode : fieldManager.getBaseFieldTypes()) {
        FieldDefinition fieldDefinition = fieldManager.getDefinitionByFieldTypeName(typeCode);
        Assertions.assertThat(fieldDefinition).isNotNull();
        Assertions.assertThat(fieldDefinition.getFieldType().getTypeName()).isEqualTo(typeCode);
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) Test(org.junit.Test)

Example 34 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FieldManagerTest method testGettingAllMultipleProvidersDefinitions.

@Test
public void testGettingAllMultipleProvidersDefinitions() {
    for (BasicTypeFieldProvider provider : fieldManager.getAllBasicMultipleTypeProviders()) {
        for (String className : provider.getSupportedTypes()) {
            TypeInfo typeInfo = new TypeInfoImpl(TypeKind.BASE, className, true);
            FieldDefinition fieldDefinition = fieldManager.getFieldFromProvider(provider.getFieldTypeName(), typeInfo);
            Assertions.assertThat(fieldDefinition).isNotNull();
        }
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider) Test(org.junit.Test)

Example 35 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FieldManagerTest method testGettingAllProvidersDefinitions.

@Test
public void testGettingAllProvidersDefinitions() {
    for (BasicTypeFieldProvider provider : fieldManager.getAllBasicTypeProviders()) {
        for (String className : provider.getSupportedTypes()) {
            try {
                Class clazz = Class.forName(className);
                TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
                FieldDefinition fieldDefinition = fieldManager.getFieldFromProvider(provider.getFieldTypeName(), typeInfo);
                Assertions.assertThat(fieldDefinition).isNotNull();
            } catch (ClassNotFoundException e) {
            // swallow error caused by looking up simple types
            }
        }
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider) Test(org.junit.Test)

Aggregations

FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)85 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)42 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)29 Test (org.junit.Test)27 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)24 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)22 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)21 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)20 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)18 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)17 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)14 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)13 ArrayList (java.util.ArrayList)11 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)8 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)7 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)7 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)7 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)7 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)7