Search in sources :

Example 1 with FormEditorHelper

use of org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method setup.

@BeforeClass
public static void setup() {
    FormModelPropertiesUtil.registerBaseType(DOCUMENT_TYPE);
    FormModelPropertiesUtil.registerBaseType(DocumentFieldType.DOCUMENT_IMPL_TYPE);
    fieldManager = new TestFieldManager() {

        {
            registerFieldProvider(new DocumentFieldProvider() {

                {
                    doRegisterFields();
                }
            });
        }
    };
    formSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    ioService = new IOServiceDotFileImpl();
    templateGenerator = new StaticFormLayoutTemplateGenerator();
    formModelSynchronizationUtil = new FormModelSynchronizationUtilImpl(fieldManager, templateGenerator);
    moduleClassLoader = FormGenerationIntegrationTest.class.getClassLoader();
    formGenerationProcessDefinitions = TestUtils.getDefinitionsFromResources(FormGenerationIntegrationTest.class, DEFINITION_PATH);
    formModelerContent = new FormModelerContent();
    formEditorHelper = new FormEditorHelper(fieldManager, null, mock(SyncBeanManager.class));
}
Also used : FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) IOServiceDotFileImpl(org.uberfire.io.impl.IOServiceDotFileImpl) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) DocumentFieldProvider(org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) BeforeClass(org.junit.BeforeClass)

Example 2 with FormEditorHelper

use of org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper in project kie-wb-common by kiegroup.

the class EditorFieldLayoutComponentTest method init.

@Before
public void init() {
    fieldManager = spy(new TestFieldManager());
    when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
        final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
        return mocked;
    });
    formEditorHelper = spy(new FormEditorHelper(new TestFieldManager(), editorFieldLayoutComponents, mock(SyncBeanManager.class)));
    fieldDefinition = new TextBoxFieldDefinition();
    fieldDefinition.setId(EditorFieldLayoutComponent.FIELD_ID);
    fieldDefinition.setName(EditorFieldLayoutComponent.FIELD_ID);
    fieldDefinition.setBinding(EditorFieldLayoutComponent.FIELD_ID);
    when(formDefinition.getId()).thenReturn(EditorFieldLayoutComponent.FORM_ID);
    when(formDefinition.getFieldById(anyString())).thenReturn(fieldDefinition);
    when(formDefinition.getModel()).thenReturn(formModel);
    when(context.getRootForm()).thenReturn(formDefinition);
    content = new FormModelerContent();
    content.setDefinition(formDefinition);
    content.setOverview(mock(Overview.class));
    formEditorHelper.initHelper(content);
    when(formEditorHelper.getRenderingContext()).thenReturn(context);
    when(formEditorHelper.getFormField(any())).thenReturn(fieldDefinition);
    layoutComponent.addProperty(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
    layoutComponent.addProperty(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
    ctx = new RenderingContext(layoutComponent, widget);
    when(fieldRendererManager.getRendererForField(any())).thenReturn(fieldRenderer);
    when(fieldRenderer.renderWidget()).thenReturn(widget);
    when(propertiesRenderer.getView()).thenReturn(fieldPropertiesRendererView);
    FormEditorContext.setActiveEditorHelper(formEditorHelper);
    editorFieldLayoutComponent = spy(new EditorFieldLayoutComponent(fieldRendererManager, translationService, propertiesRenderer, fieldManager, syncPaletteEvent));
    editorFieldLayoutComponent.initPropertiesConfig();
    propertiesRendererHelper = spy(editorFieldLayoutComponent.getPropertiesRendererHelper());
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) RenderingContext(org.uberfire.ext.layout.editor.client.api.RenderingContext) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) SyncBeanManager(org.jboss.errai.ioc.client.container.SyncBeanManager) Overview(org.guvnor.common.services.shared.metadata.model.Overview) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) Before(org.junit.Before)

Aggregations

FormEditorHelper (org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper)2 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)2 TestFieldManager (org.kie.workbench.common.forms.fields.test.TestFieldManager)2 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 SyncBeanManager (org.jboss.errai.ioc.client.container.SyncBeanManager)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 StaticFormLayoutTemplateGenerator (org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator)1 FormEditorRenderingContext (org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext)1 FormModelSynchronizationUtilImpl (org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl)1 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)1 TestMetaDataEntryManager (org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager)1 DocumentFieldProvider (org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider)1 FieldSerializer (org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer)1 FormDefinitionSerializerImpl (org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl)1 FormModelSerializer (org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer)1 RenderingContext (org.uberfire.ext.layout.editor.client.api.RenderingContext)1 IOServiceDotFileImpl (org.uberfire.io.impl.IOServiceDotFileImpl)1