use of org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings 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.service.definitions.layout.LayoutSettings in project kie-wb-common by kiegroup.
the class LayoutGeneratorTest method testTwoColumnsWithWraps.
@Test
public void testTwoColumnsWithWraps() {
LayoutComponent component = mock(LayoutComponent.class);
when(component.getDragTypeName()).thenReturn("wrap");
LayoutSettings settings = new LayoutSettings();
settings.setWrap(true);
settingsMap.put(component, settings);
component = mock(LayoutComponent.class);
when(component.getDragTypeName()).thenReturn("wrap");
settingsMap.put(component, settings);
LayoutColumnDefinition[] structure = new LayoutColumnDefinition[] { new LayoutColumnDefinition(), new LayoutColumnDefinition() };
generator.init(structure);
settingsMap.entrySet().forEach(entry -> generator.addComponent(entry.getKey(), entry.getValue()));
LayoutTemplate result = generator.build();
assertNotNull(result);
assertNotNull(result.getRows());
assertEquals(settingsMap.size() / 2 + 1, result.getRows().size());
result.getRows().forEach(row -> {
assertNotNull(row);
assertNotNull(row.getLayoutColumns());
LayoutComponent layoutComponent = row.getLayoutColumns().get(0).getLayoutComponents().get(0);
if ("wrap".equals(layoutComponent.getDragTypeName())) {
checkTwoColumnsRowWraps(row);
} else {
checkTwoColumnsRow(row);
}
});
}
use of org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings in project kie-wb-common by kiegroup.
the class LayoutGeneratorTest method testTwoColumnsLayoutWithSpans.
@Test
public void testTwoColumnsLayoutWithSpans() {
LayoutComponent component = mock(LayoutComponent.class);
when(component.getDragTypeName()).thenReturn("span");
LayoutSettings settings = new LayoutSettings();
settings.setHorizontalSpan(2);
settingsMap.put(component, settings);
component = mock(LayoutComponent.class);
when(component.getDragTypeName()).thenReturn("span");
settingsMap.put(component, settings);
LayoutColumnDefinition[] structure = new LayoutColumnDefinition[] { new LayoutColumnDefinition(), new LayoutColumnDefinition() };
generator.init(structure);
settingsMap.entrySet().forEach(entry -> generator.addComponent(entry.getKey(), entry.getValue()));
LayoutTemplate result = generator.build();
assertNotNull(result);
assertNotNull(result.getRows());
assertEquals(settingsMap.size() / 2 + 1, result.getRows().size());
result.getRows().forEach(row -> {
assertNotNull(row);
assertNotNull(row.getLayoutColumns());
LayoutComponent layoutComponent = row.getLayoutColumns().get(0).getLayoutComponents().get(0);
if ("span".equals(layoutComponent.getDragTypeName())) {
checkSingleColumnRow(row);
} else {
checkTwoColumnsRow(row);
}
});
}
use of org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings in project kie-wb-common by kiegroup.
the class LayoutGeneratorTest method initTest.
@Before
public void initTest() {
settingsMap.put(mock(LayoutComponent.class), new LayoutSettings());
settingsMap.put(mock(LayoutComponent.class), new LayoutSettings());
settingsMap.put(mock(LayoutComponent.class), new LayoutSettings());
settingsMap.put(mock(LayoutComponent.class), new LayoutSettings());
settingsMap.put(mock(LayoutComponent.class), new LayoutSettings());
settingsMap.put(mock(LayoutComponent.class), new LayoutSettings());
}
Aggregations