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