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