Search in sources :

Example 1 with FormRenderingContext

use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.

the class DynamicFormRenderer method renderDefaultForm.

public void renderDefaultForm(final Object model, final RenderMode renderMode, final Command callback) {
    PortablePreconditions.checkNotNull("model", model);
    FormRenderingContext context = dynamicFormModelGenerator.getContextForModel(model);
    if (context != null) {
        doRenderDefaultForm(context, model, renderMode, callback);
    }
}
Also used : FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext)

Example 2 with FormRenderingContext

use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.

the class FieldPropertiesRenderer method render.

protected void render() {
    FormRenderingContext context = dynamicFormModelGenerator.getContextForModel(fieldCopy);
    if (context != null) {
        FormEditorRenderingContext renderingContext = new FormEditorRenderingContext("properties", helper.getPath());
        renderingContext.setRootForm(context.getRootForm());
        renderingContext.getAvailableForms().putAll(context.getAvailableForms());
        renderingContext.setModel(fieldCopy);
        doRender(helper, renderingContext);
    }
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext)

Example 3 with FormRenderingContext

use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.

the class SubFormFieldRenderer method getFormGroup.

@Override
protected FormGroup getFormGroup(RenderMode renderMode) {
    String nestedNS = renderingContext.getNamespace() + FormRenderingContext.NAMESPACE_SEPARATOR + field.getName();
    FormRenderingContext nestedContext = renderingContext.getCopyFor(nestedNS, field.getNestedForm(), null);
    if (field.getReadOnly()) {
        nestedContext.setRenderMode(RenderMode.READ_ONLY_MODE);
    }
    subFormWidget.render(nestedContext);
    AbstractNestedFormFormGroup formGroup;
    if (Container.COLLAPSIBLE.equals(field.getContainer())) {
        formGroup = formGroupsInstance.select(CollapsibleFormGroup.class).get();
    } else {
        formGroup = formGroupsInstance.select(FieldSetFormGroup.class).get();
    }
    formGroup.render(subFormWidget, field);
    return formGroup;
}
Also used : FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) AbstractNestedFormFormGroup(org.kie.workbench.common.forms.dynamic.client.rendering.formGroups.impl.nestedForm.AbstractNestedFormFormGroup)

Example 4 with FormRenderingContext

use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.

the class ConditionEditorFieldEditorRendererTest method testInit.

@Test
public void testInit() {
    FormRenderingContext context = mock(FormRenderingContext.class);
    ConditionEditorFieldDefinition fieldDefinition = mock(ConditionEditorFieldDefinition.class);
    ClientSession session = mock(ClientSession.class);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    renderer.init(context, fieldDefinition);
    verify(widget).init(session);
}
Also used : ConditionEditorFieldDefinition(org.kie.workbench.common.stunner.bpmn.forms.model.ConditionEditorFieldDefinition) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) Test(org.junit.Test)

Example 5 with FormRenderingContext

use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.

the class CalledElementFormProviderTest method testGetSelectorData.

@Test
public void testGetSelectorData() {
    List<String> names = Arrays.asList("p1", "p2", "p3");
    when(dataProvider.getProcessIds()).thenReturn(names);
    FormRenderingContext context = mock(FormRenderingContext.class);
    SelectorData data = tested.getSelectorData(context);
    Map values = data.getValues();
    assertNotNull(values);
    assertEquals(3, values.size());
    assertTrue(values.containsKey("p1"));
    assertTrue(values.containsKey("p2"));
    assertTrue(values.containsKey("p3"));
    verify(event, times(1)).fire(any(RequestProcessDataEvent.class));
}
Also used : RequestProcessDataEvent(org.kie.workbench.common.stunner.bpmn.forms.dataproviders.RequestProcessDataEvent) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) Map(java.util.Map) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData) Test(org.junit.Test)

Aggregations

FormRenderingContext (org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext)9 Test (org.junit.Test)4 SelectorData (org.kie.workbench.common.forms.dynamic.model.config.SelectorData)4 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 FormEditorRenderingContext (org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext)2 RuleFlowGroup (org.kie.workbench.common.stunner.bpmn.definition.property.task.RuleFlowGroup)2 RequestRuleFlowGroupDataEvent (org.kie.workbench.common.stunner.bpmn.forms.dataproviders.RequestRuleFlowGroupDataEvent)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 Dependent (javax.enterprise.context.Dependent)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ModelFinderService (org.kie.workbench.common.forms.data.modeller.service.shared.ModelFinderService)1 AbstractNestedFormFormGroup (org.kie.workbench.common.forms.dynamic.client.rendering.formGroups.impl.nestedForm.AbstractNestedFormFormGroup)1 SelectorDataProvider (org.kie.workbench.common.forms.dynamic.model.config.SelectorDataProvider)1 SystemSelectorDataProvider (org.kie.workbench.common.forms.dynamic.model.config.SystemSelectorDataProvider)1