Search in sources :

Example 16 with FieldDefinition

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

the class EditorFieldLayoutComponentTest method testHelperGetCurrentField.

@Test
public void testHelperGetCurrentField() {
    FieldDefinition result = propertiesRendererHelper.getCurrentField();
    assertSame(editorFieldLayoutComponent.getField(), result);
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) Test(org.junit.Test)

Example 17 with FieldDefinition

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

the class EditorFieldLayoutComponentTest method testHelperOnPressOk.

@Test
public void testHelperOnPressOk() {
    FieldDefinition fieldCopy = setupFormEditorHelper();
    propertiesRendererHelper.onPressOk(fieldCopy);
    verify(editorFieldLayoutComponent).onPressOk(fieldCopy);
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) Test(org.junit.Test)

Example 18 with FieldDefinition

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

the class DataObjectFormModelHandlerTest method checkCommonProperties.

private FieldDefinition checkCommonProperties(String dataFieldName) {
    ObjectProperty dataField = dataObject.getProperty(dataFieldName);
    FieldDefinition formField = fieldManager.getDefinitionByModelProperty(formModel.getProperty(dataFieldName));
    String dataFieldClassName = dataField.getClassName();
    TypeInfo fieldTypeInfo = formField.getFieldTypeInfo();
    // test common properties
    assertEquals(dataFieldClassName, fieldTypeInfo.getClassName());
    assertNotEquals(TypeKind.ENUM, fieldTypeInfo.getType());
    assertEquals(dataField.isMultiple(), fieldTypeInfo.isMultiple());
    assertEquals(dataField.getName().toLowerCase(), formField.getLabel().toLowerCase());
    assertEquals(dataField.getName(), formField.getBinding());
    assertEquals(dataFieldClassName, formField.getStandaloneClassName());
    assertFalse(formField.getReadOnly());
    assertFalse(formField.getRequired());
    assertTrue(formField.getValidateOnChange());
    // test interface specific properties
    if (formField instanceof HasPlaceHolder) {
        assertEquals(dataField.getName().toLowerCase(), ((HasPlaceHolder) formField).getPlaceHolder().toLowerCase());
    }
    if (formField instanceof HasMaxLength) {
        long maxLength = ((HasMaxLength) formField).getMaxLength();
        assertTrue(formField instanceof CharacterBoxFieldDefinition ? maxLength == 1 : maxLength == 100);
    }
    return formField;
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) HasMaxLength(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.HasMaxLength) CharacterBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.CharacterBoxFieldDefinition) HasPlaceHolder(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.HasPlaceHolder) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CharacterBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.CharacterBoxFieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo)

Example 19 with FieldDefinition

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

the class AbstractBPMNFormGeneratorService method processFieldDefinition.

protected void processFieldDefinition(FieldDefinition field, GenerationContext<SOURCE> context) {
    if (field instanceof EntityRelationField) {
        if (field instanceof HasNestedForm) {
            HasNestedForm nestedFormField = (HasNestedForm) field;
            FormDefinition nestedForm = findFormDefinitionForModelType(field.getStandaloneClassName(), context);
            if (nestedForm == null) {
                nestedForm = createModelFormDefinition(field.getStandaloneClassName(), context);
            }
            nestedFormField.setNestedForm(nestedForm.getId());
        } else if (field instanceof IsCRUDDefinition) {
            IsCRUDDefinition crudField = (IsCRUDDefinition) field;
            FormDefinition nestedForm = findFormDefinitionForModelType(field.getStandaloneClassName(), context);
            if (nestedForm == null) {
                nestedForm = createModelFormDefinition(field.getStandaloneClassName(), context);
                crudField.setCreationForm(nestedForm.getId());
                crudField.setEditionForm(nestedForm.getId());
                List<TableColumnMeta> tableColumnMetas = new ArrayList<>();
                nestedForm.getFields().forEach(nestedField -> {
                    tableColumnMetas.add(new TableColumnMeta(nestedField.getLabel(), nestedField.getBinding()));
                });
                crudField.setColumnMetas(tableColumnMetas);
            }
        }
    }
}
Also used : LayoutColumnDefinition(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) UIDGenerator(org.kie.workbench.common.forms.services.backend.util.UIDGenerator) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) IsCRUDDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.IsCRUDDefinition) BPMNFormGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.BPMNFormGeneratorService) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent) ArrayList(java.util.ArrayList) ColSpan(org.kie.workbench.common.forms.adf.definitions.settings.ColSpan) HasNestedForm(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.HasNestedForm) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) List(java.util.List) LayoutGenerator(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) FieldManager(org.kie.workbench.common.forms.service.shared.FieldManager) LayoutSettings(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel) EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) IsCRUDDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.IsCRUDDefinition) HasNestedForm(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.HasNestedForm) ArrayList(java.util.ArrayList) List(java.util.List) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 20 with FieldDefinition

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

the class AbstractBPMNFormGeneratorService method createFormLayout.

protected void createFormLayout(FormDefinition form) {
    LayoutGenerator layoutGenerator = new LayoutGenerator();
    layoutGenerator.init(new LayoutColumnDefinition[] { new LayoutColumnDefinition(ColSpan.SPAN_12) });
    if (form.getFields().size() > 0) {
        boolean separeateInputsAndOutputs = form.getModel() instanceof TaskFormModel;
        boolean mightAddOtuputsLabel = form.getFields().get(0).getReadOnly();
        if (separeateInputsAndOutputs) {
            if (mightAddOtuputsLabel) {
                layoutGenerator.addComponent(generateHTMLElement(INPUTS), new LayoutSettings());
            } else {
                layoutGenerator.addComponent(generateHTMLElement(OUTPUTS), new LayoutSettings());
            }
        }
        for (FieldDefinition fieldDefinition : form.getFields()) {
            if (separeateInputsAndOutputs && mightAddOtuputsLabel && !fieldDefinition.getReadOnly()) {
                mightAddOtuputsLabel = false;
                layoutGenerator.addComponent(generateHTMLElement(OUTPUTS), new LayoutSettings());
            }
            LayoutComponent fieldComponent = new LayoutComponent(StaticFormLayoutTemplateGenerator.DRAGGABLE_TYPE);
            fieldComponent.addProperty(FormLayoutComponent.FORM_ID, form.getId());
            fieldComponent.addProperty(FormLayoutComponent.FIELD_ID, fieldDefinition.getId());
            layoutGenerator.addComponent(fieldComponent, new LayoutSettings());
        }
    }
    form.setLayoutTemplate(layoutGenerator.build());
}
Also used : LayoutColumnDefinition(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition) LayoutGenerator(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator) LayoutSettings(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

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