use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class SimpleFieldTypesBackendFormRenderingContextManagerTest method getRootForm.
@Override
protected FormDefinition getRootForm() {
FormDefinition form = new FormDefinition();
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName(STRING_FIELD);
field.setBinding(STRING_FIELD);
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Integer.class.getName()));
field.setName(INTEGER_FIELD);
field.setBinding(INTEGER_FIELD);
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
field.setName(DATE_FIELD);
field.setBinding(DATE_FIELD);
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Boolean.class.getName()));
field.setName(BOOLEAN_FIELD);
field.setBinding(BOOLEAN_FIELD);
form.getFields().add(field);
field = fieldManager.getDefinitionByFieldType(new MultipleInputFieldType());
field.setName(MULTIPLE_INPUT_FIELD);
field.setBinding(MULTIPLE_INPUT_FIELD);
form.getFields().add(field);
field = fieldManager.getDefinitionByFieldType(new MultipleSelectorFieldType());
field.setName(MULTIPLE_SELECTOR_FIELD);
field.setBinding(MULTIPLE_SELECTOR_FIELD);
form.getFields().add(field);
return form;
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class MultipleSubformBackendFormRenderingContextManagerTest method getRootForm.
@Override
protected FormDefinition getRootForm() {
FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
form.setId("form");
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(TypeKind.OBJECT, Person.class.getName(), true));
field.setName("persons");
field.setBinding("persons");
MultipleSubFormFieldDefinition multpleSubForm = (MultipleSubFormFieldDefinition) field;
multpleSubForm.setCreationForm("person-creation");
multpleSubForm.setEditionForm("person-edition");
form.getFields().add(field);
return form;
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class ProcessableModelBackendFormRenderingContextManagerTest method getFormDefinition.
private FormDefinition getFormDefinition(final String id, final boolean appendNested) {
final FormDefinition formDefinition = new FormDefinition(new PortableJavaModel(ProcessableModel.class.getName()));
formDefinition.setId(id);
appendFieldDefinition(new ModelPropertyImpl(BIG_DECIMAL, new TypeInfoImpl(BigDecimal.class.getName())), formDefinition);
appendFieldDefinition(new ModelPropertyImpl(BIG_INTEGER, new TypeInfoImpl(BigInteger.class.getName())), formDefinition);
appendFieldDefinition(new ModelPropertyImpl(A_FLOAT, new TypeInfoImpl(Float.class.getName())), formDefinition);
appendFieldDefinition(new ModelPropertyImpl(LOCAL_DATE, new TypeInfoImpl(LocalDate.class.getName())), formDefinition);
appendFieldDefinition(new ModelPropertyImpl(LOCAL_DATE_TIME, new TypeInfoImpl(LocalDateTime.class.getName())), formDefinition);
appendFieldDefinition(new ModelPropertyImpl(LOCAL_TIME, new TypeInfoImpl(LocalTime.class.getName())), formDefinition);
appendFieldDefinition(new ModelPropertyImpl(OFFSET_DATE_TIME, new TypeInfoImpl(OffsetDateTime.class.getName())), formDefinition);
if (appendNested) {
appendFieldDefinition(new ModelPropertyImpl(CHILD, new TypeInfoImpl(TypeKind.OBJECT, ProcessableModel.class.getName(), false)), formDefinition);
((SubFormFieldDefinition) formDefinition.getFieldByBinding(CHILD)).setNestedForm(NESTED_FORM_ID);
appendFieldDefinition(new ModelPropertyImpl(CHILDREN, new TypeInfoImpl(TypeKind.OBJECT, ProcessableModel.class.getName(), true)), formDefinition);
((MultipleSubFormFieldDefinition) formDefinition.getFieldByBinding(CHILDREN)).setCreationForm(NESTED_FORM_ID);
((MultipleSubFormFieldDefinition) formDefinition.getFieldByBinding(CHILDREN)).setEditionForm(NESTED_FORM_ID);
}
return formDefinition;
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method initFields.
private void initFields() {
TextBoxFieldDefinition name = new TextBoxFieldDefinition();
name.setId("name");
name.setName("name");
name.setLabel("Name");
name.setPlaceHolder("Name");
name.setBinding("name");
name.setStandaloneClassName(String.class.getName());
nameField = name;
TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
lastName.setId("lastName");
lastName.setName("lastName");
lastName.setLabel("Last Name");
lastName.setPlaceHolder("Last Name");
lastName.setBinding("lastName");
lastName.setStandaloneClassName(String.class.getName());
lastNameField = lastName;
DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
birthday.setId("birthday");
birthday.setName("birthday");
birthday.setLabel("Birthday");
birthday.setBinding("birthday");
birthday.setStandaloneClassName(Date.class.getName());
CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
married.setId("married");
married.setName("married");
married.setLabel("Married");
married.setBinding("married");
married.setStandaloneClassName(Boolean.class.getName());
marriedField = married;
IntegerBoxFieldDefinition age = new IntegerBoxFieldDefinition();
age.setId("age");
age.setName("age");
age.setLabel("Age");
age.setBinding("age");
ageField = age;
DecimalBoxFieldDefinition weight = new DecimalBoxFieldDefinition();
weight.setId("weight");
weight.setName("weight");
weight.setLabel("Weight");
weight.setBinding("weight");
weightField = weight;
employeeFields = new ArrayList<>();
employeeFields.add(name);
employeeFields.add(lastName);
employeeFields.add(birthday);
employeeFields.add(married);
employeeFields.add(age);
employeeFields.add(weight);
modelProperties = new ArrayList<>();
employeeFields.forEach(fieldDefinition -> modelProperties.add(new ModelPropertyImpl(fieldDefinition.getBinding(), new TypeInfoImpl(fieldDefinition.getStandaloneClassName()))));
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class FieldManagerTest method testCompatiblefields.
protected void testCompatiblefields(boolean addFieldType) {
for (Class clazz : basicTypesSupported) {
TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
FieldDefinition fieldDefinition = fieldManager.getDefinitionByDataType(typeInfo);
Assertions.assertThat(fieldDefinition).isNotNull();
if (addFieldType) {
fieldDefinition.setStandaloneClassName(typeInfo.getClassName());
}
Collection<String> compatibles = fieldManager.getCompatibleFields(fieldDefinition);
Assertions.assertThat(compatibles).isNotNull().isNotEmpty();
}
}
Aggregations