Search in sources :

Example 1 with RenderingContext

use of org.uberfire.ext.layout.editor.client.api.RenderingContext 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));
    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);
    editorFieldLayoutComponent = spy(new EditorFieldLayoutComponent(propertiesRenderer, layoutDragComponentHelper, fieldManager, formEditorContext, syncPaletteEvent) {

        {
            fieldRendererManager = EditorFieldLayoutComponentTest.this.fieldRendererManager;
            translationService = EditorFieldLayoutComponentTest.this.translationService;
        }

        @Override
        protected FormEditorHelper getHelperInstance() {
            return formEditorHelper;
        }
    });
    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) 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)

Example 2 with RenderingContext

use of org.uberfire.ext.layout.editor.client.api.RenderingContext in project kie-wb-common by kiegroup.

the class FormGeneratorDriver method createComponent.

@Override
public IsWidget createComponent(HTMLElement column, LayoutComponent layoutComponent) {
    final LayoutDragComponent dragComponent = lookupComponent(layoutComponent);
    if (dragComponent != null) {
        Widget columnWidget = ElementWrapperWidget.getWidget(column);
        RenderingContext componentContext = new RenderingContext(layoutComponent, columnWidget);
        return dragComponent.getShowWidget(componentContext);
    }
    return null;
}
Also used : FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) RenderingContext(org.uberfire.ext.layout.editor.client.api.RenderingContext) LayoutDragComponent(org.uberfire.ext.layout.editor.client.api.LayoutDragComponent) IsWidget(com.google.gwt.user.client.ui.IsWidget) Widget(com.google.gwt.user.client.ui.Widget) ElementWrapperWidget(org.jboss.errai.common.client.ui.ElementWrapperWidget)

Aggregations

RenderingContext (org.uberfire.ext.layout.editor.client.api.RenderingContext)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 Widget (com.google.gwt.user.client.ui.Widget)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 ElementWrapperWidget (org.jboss.errai.common.client.ui.ElementWrapperWidget)1 Before (org.junit.Before)1 FormRenderingContext (org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext)1 FormEditorHelper (org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper)1 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)1 FormEditorRenderingContext (org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext)1 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)1 TestFieldManager (org.kie.workbench.common.forms.fields.test.TestFieldManager)1 LayoutDragComponent (org.uberfire.ext.layout.editor.client.api.LayoutDragComponent)1