Search in sources :

Example 11 with LayoutComponent

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

the class AbstractBPMNFormGeneratorService method generateHTMLElement.

protected LayoutComponent generateHTMLElement(String content) {
    LayoutComponent htmlComponent = new LayoutComponent(HTML_COMPONENT);
    htmlComponent.addProperty(HTML_CODE_PARAMETER, content);
    return htmlComponent;
}
Also used : FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Example 12 with LayoutComponent

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

the class AbstractFormLayoutTemplateGenerator method addFieldsToTemplate.

protected void addFieldsToTemplate(LayoutTemplate template, List<FieldDefinition> fields, String formId) {
    fields.forEach(field -> {
        LayoutComponent layoutComponent = new LayoutComponent(getDraggableType());
        layoutComponent.addProperty(FormLayoutComponent.FORM_ID, formId);
        layoutComponent.addProperty(FormLayoutComponent.FIELD_ID, field.getId());
        LayoutColumn column = new LayoutColumn("12");
        column.add(layoutComponent);
        LayoutRow row = new LayoutRow();
        row.add(column);
        template.addRow(row);
    });
}
Also used : LayoutRow(org.uberfire.ext.layout.editor.api.editor.LayoutRow) LayoutColumn(org.uberfire.ext.layout.editor.api.editor.LayoutColumn) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Example 13 with LayoutComponent

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

the class DecoratorFieldAdapter method parseField.

@Override
public void parseField(Field originalField, FormMigrationSummary formSummary, FormDefinition fieldDefinitionConsumer, Consumer<LayoutComponent> layoutElementConsumer) {
    String htmlContent;
    switch(originalField.getFieldType().getCode()) {
        case FieldTypeBuilder.HTML_LABEL:
            htmlContent = lookupI18nValue(originalField.getHtmlContent());
            break;
        default:
            htmlContent = "<HR/>";
            break;
    }
    LayoutComponent component = new LayoutComponent(FormsMigrationConstants.HTML_COMPONENT);
    component.addProperty(FormsMigrationConstants.HTML_CODE_PARAMETER, htmlContent);
    layoutElementConsumer.accept(component);
}
Also used : LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Example 14 with LayoutComponent

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

the class AbstractFieldAdapter method parseField.

@Override
public void parseField(Field originalField, FormMigrationSummary formSummary, FormDefinition newFormDefinition, Consumer<LayoutComponent> layoutElementConsumer) {
    FieldDefinition fieldDefinition = getFieldDefinition(originalField);
    fieldDefinition.setId(String.valueOf(originalField.getId()));
    fieldDefinition.setName(originalField.getFieldName());
    fieldDefinition.setLabel(lookupI18nValue(originalField.getLabel()));
    fieldDefinition.setHelpMessage(lookupI18nValue(originalField.getTitle()));
    fieldDefinition.setStandaloneClassName(StringUtils.defaultIfBlank(originalField.getBag(), originalField.getFieldType().getFieldClass()));
    fieldDefinition.setReadOnly(originalField.getReadonly());
    fieldDefinition.setRequired(originalField.getFieldRequired());
    String binding = StringUtils.defaultString(StringUtils.defaultIfBlank(originalField.getInputBinding(), originalField.getOutputBinding()));
    if (!StringUtils.isEmpty(binding)) {
        if (binding.contains("/")) {
            binding = binding.substring(binding.indexOf("/") + 1);
        }
        ModelPropertyImpl property = new ModelPropertyImpl(binding, fieldDefinition.getFieldTypeInfo());
        newFormDefinition.getModel().getProperties().add(property);
    }
    fieldDefinition.setBinding(binding);
    newFormDefinition.getFields().add(fieldDefinition);
    LayoutComponent component = new LayoutComponent(DRAGGABLE_TYPE);
    component.addProperty(FormLayoutComponent.FORM_ID, newFormDefinition.getId());
    component.addProperty(FormLayoutComponent.FIELD_ID, fieldDefinition.getId());
    layoutElementConsumer.accept(component);
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Example 15 with LayoutComponent

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

the class AllFieldTypesFormGenerationTest method checkDecoratorRow.

protected void checkDecoratorRow(LayoutRow row) {
    LayoutComponent component = checkRow(row);
    Assertions.assertThat(component).isNotNull().hasFieldOrPropertyWithValue("dragTypeName", FormsMigrationConstants.HTML_COMPONENT);
}
Also used : LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Aggregations

LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)15 FormLayoutComponent (org.kie.workbench.common.forms.model.FormLayoutComponent)7 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)6 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)5 Test (org.junit.Test)4 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)4 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)4 LayoutColumnDefinition (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition)3 LayoutSettings (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings)3 Formatter (java.util.Formatter)2 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)2 Field (org.kie.workbench.common.forms.migration.legacy.model.Field)2 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)2 FormMigrationSummary (org.kie.workbench.common.forms.migration.tool.FormMigrationSummary)2 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)2 Path (org.uberfire.backend.vfs.Path)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IntStream (java.util.stream.IntStream)1 Assertions (org.assertj.core.api.Assertions)1