Search in sources :

Example 1 with LayoutGenerator

use of org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator in project kie-wb-common by kiegroup.

the class AbstractBPMNFormGeneratorService method createFormLayout.

protected void createFormLayout(FormDefinition form) {
    LayoutGenerator layoutGenerator = new LayoutGenerator();
    layoutGenerator.init(new LayoutColumnDefinition[] { new LayoutColumnDefinition(ColSpan.SPAN_12) });
    if (form.getFields().size() > 0) {
        boolean separeateInputsAndOutputs = form.getModel() instanceof TaskFormModel;
        boolean mightAddOtuputsLabel = form.getFields().get(0).getReadOnly();
        if (separeateInputsAndOutputs) {
            if (mightAddOtuputsLabel) {
                layoutGenerator.addComponent(generateHTMLElement(INPUTS), new LayoutSettings());
            } else {
                layoutGenerator.addComponent(generateHTMLElement(OUTPUTS), new LayoutSettings());
            }
        }
        for (FieldDefinition fieldDefinition : form.getFields()) {
            if (separeateInputsAndOutputs && mightAddOtuputsLabel && !fieldDefinition.getReadOnly()) {
                mightAddOtuputsLabel = false;
                layoutGenerator.addComponent(generateHTMLElement(OUTPUTS), new LayoutSettings());
            }
            LayoutComponent fieldComponent = new LayoutComponent(StaticFormLayoutTemplateGenerator.DRAGGABLE_TYPE);
            fieldComponent.addProperty(FormLayoutComponent.FORM_ID, form.getId());
            fieldComponent.addProperty(FormLayoutComponent.FIELD_ID, fieldDefinition.getId());
            layoutGenerator.addComponent(fieldComponent, new LayoutSettings());
        }
    }
    form.setLayoutTemplate(layoutGenerator.build());
}
Also used : LayoutColumnDefinition(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition) LayoutGenerator(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator) LayoutSettings(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Example 2 with LayoutGenerator

use of org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator in project kie-wb-common by kiegroup.

the class AbstractFormGenerationTest method init.

protected void init() {
    i18nHelper = spy(I18nHelper.class);
    resourcesProvider = new TestFormGenerationResourcesProvider();
    generator = new TestFormGenerator(new LayoutGenerator(), i18nHelper);
    generator.registerProcessor(new TestFieldElementProcessor(fieldManager, new TestPropertyValueExtractor()));
    generator.registerResources(resourcesProvider);
    model.setName("John");
    model.setLastName("Snow");
    model.setMarried(Boolean.FALSE);
    model.setBirthDay(new Date());
    model.setWeight(new Weight(75));
    model.setHeight(new Height(1.80));
    model.setAddress(new Address("Main Street", 1, "Winterfell"));
    model.getWeapons().add(new Weapon("Sword", 10));
    model.getWeapons().add(new Weapon("Axe", 15));
}
Also used : LayoutGenerator(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator) I18nHelper(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.I18nHelper) Address(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Address) Height(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Height) Date(java.util.Date) Weight(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Weight) Weapon(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Weapon)

Aggregations

LayoutGenerator (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator)2 Date (java.util.Date)1 I18nHelper (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.I18nHelper)1 Address (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Address)1 Height (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Height)1 Weapon (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Weapon)1 Weight (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Weight)1 LayoutColumnDefinition (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition)1 LayoutSettings (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings)1 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)1 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)1 FormLayoutComponent (org.kie.workbench.common.forms.model.FormLayoutComponent)1 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)1