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);
}
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);
}
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;
}
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);
}
}
}
}
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());
}
Aggregations