Search in sources :

Example 11 with LayoutTemplate

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

the class LayoutGeneratorTest method testTwoColumnsLayout.

@Test
public void testTwoColumnsLayout() {
    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, result.getRows().size());
    result.getRows().forEach(row -> {
        checkTwoColumnsRow(row);
    });
}
Also used : LayoutColumnDefinition(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition) LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) Test(org.junit.Test)

Example 12 with LayoutTemplate

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

the class FormEditorServiceImpl method createForm.

@Override
public Path createForm(Path path, String formName, FormModel formModel) {
    org.uberfire.java.nio.file.Path kiePath = Paths.convert(path).resolve(formName);
    try {
        if (ioService.exists(kiePath)) {
            throw new FileAlreadyExistsException(kiePath.toString());
        }
        FormDefinition form = new FormDefinition(formModel);
        form.setId(UIDGenerator.generateUID());
        form.setName(formName.substring(0, formName.lastIndexOf(".")));
        form.setLayoutTemplate(new LayoutTemplate());
        ioService.write(kiePath, formDefinitionSerializer.serialize(form), commentedOptionFactory.makeCommentedOption(""));
        return Paths.convert(kiePath);
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 13 with LayoutTemplate

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

the class FormEditorPresenterAbstractTest method loadContent.

protected void loadContent() {
    when(formDefinitionResourceType.getSuffix()).thenReturn("form.frm");
    when(formDefinitionResourceType.accept(path)).thenReturn(true);
    when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> mock(EditorFieldLayoutComponent.class));
    when(formEditorService.loadContent(any())).then(invocation -> serviceLoad());
    editorServiceCallerMock = new CallerMock<>(formEditorService);
    editorHelper = spy(new TestFormEditorHelper(fieldManager, editorFieldLayoutComponents));
    when(layoutEditorMock.getLayout()).thenReturn(new LayoutTemplate());
    when(menuBuilderMock.addSave(any(MenuItem.class))).thenReturn(menuBuilderMock);
    when(menuBuilderMock.addCopy(any(ObservablePath.class), any(DefaultFileNameValidator.class))).thenReturn(menuBuilderMock);
    when(menuBuilderMock.addRename(any(ObservablePath.class), any(DefaultFileNameValidator.class))).thenReturn(menuBuilderMock);
    when(menuBuilderMock.addRename(any(Command.class))).thenReturn(menuBuilderMock);
    when(menuBuilderMock.addDelete(any(ObservablePath.class))).thenReturn(menuBuilderMock);
    when(menuBuilderMock.addNewTopLevelMenu(any(MenuItem.class))).thenReturn(menuBuilderMock);
    when(menuBuilderMock.build()).thenReturn(mock(Menus.class));
    when(versionRecordManager.getCurrentPath()).thenReturn(path);
    when(translationService.format(anyString(), anyString())).thenReturn("");
    showAssetUsagesDisplayer = spy(new ShowAssetUsagesDisplayer(assetUsagesDisplayerView, translationService, new CallerMock<>(assetsUsagService)));
    when(assetUsagesDisplayerView.getDefaultMessageContainer()).thenReturn(mock(HTMLElement.class));
    when(assetsUsagService.getAssetUsages(anyString(), any(), any())).thenReturn(assetUsages);
    deletePopUpPresenter = spy(new DeletePopUpPresenter(deletePopUpView, toggleCommentPresenter));
    presenter = new FormEditorPresenter(view, modelChangesDisplayer, formDefinitionResourceType, editorServiceCallerMock, translationService, editorFieldLayoutComponents, showAssetUsagesDisplayer) {

        {
            kieView = mock(KieEditorWrapperView.class);
            versionRecordManager = FormEditorPresenterAbstractTest.this.versionRecordManager;
            editorHelper = FormEditorPresenterAbstractTest.this.editorHelper;
            busyIndicatorView = mock(BusyIndicatorView.class);
            overviewWidget = mock(OverviewWidgetPresenter.class);
            layoutEditor = layoutEditorMock;
            layoutDragComponentPalette = layoutDragComponentPaletteMock;
            layoutFocusEvent = layoutFocusEventMock;
            htmlLayoutDragComponent = FormEditorPresenterAbstractTest.this.htmlLayoutDragComponent;
            notification = notificationEvent;
            fileMenuBuilder = menuBuilderMock;
            workbenchContext = FormEditorPresenterAbstractTest.this.workbenchContext;
            projectController = FormEditorPresenterAbstractTest.this.projectController;
            deletePopUpPresenter = FormEditorPresenterAbstractTest.this.deletePopUpPresenter;
            renamePopUpPresenter = FormEditorPresenterAbstractTest.this.renamePopUpPresenter;
            alertsButtonMenuItemBuilder = FormEditorPresenterAbstractTest.this.alertsButtonMenuItemBuilder;
            formEditorContext = mock(FormEditorContext.class);
        }

        @Override
        public void doLoadContent(FormModelerContent content) {
            super.doLoadContent(content);
            employeeFields.addAll(editorHelper.getAvailableFields().values());
        }

        @Override
        protected void addSourcePage() {
        }
    };
    presenter.onStartup(path, mock(PlaceRequest.class));
    assertTrue("There should exist base field draggables", editorHelper.getBaseFieldsDraggables().size() > 0);
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) ShowAssetUsagesDisplayer(org.kie.workbench.common.services.refactoring.client.usages.ShowAssetUsagesDisplayer) LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) EditorFieldLayoutComponent(org.kie.workbench.common.forms.editor.client.editor.rendering.EditorFieldLayoutComponent) MenuItem(org.uberfire.workbench.model.menu.MenuItem) DefaultFileNameValidator(org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator) DeletePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.DeletePopUpPresenter) Command(org.uberfire.mvp.Command) Menus(org.uberfire.workbench.model.menu.Menus) TestFormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.test.TestFormEditorHelper) ObservablePath(org.uberfire.backend.vfs.ObservablePath)

Example 14 with LayoutTemplate

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

the class FormEditorPresenter method doLoadContent.

public void doLoadContent(FormModelerContent content) {
    busyIndicatorView.hideBusyIndicator();
    // Clear LayoutEditor before loading new content.
    if (editorHelper.getContent() != null) {
        layoutEditor.clear();
    }
    editorHelper.initHelper(content);
    if (content.getDefinition().getLayoutTemplate() == null) {
        content.getDefinition().setLayoutTemplate(new LayoutTemplate());
    }
    resetEditorPages(content.getOverview());
    setOriginalHash(content.getDefinition().hashCode());
    view.init(this);
    loadLayoutEditor();
    view.setupLayoutEditor(layoutEditor);
    changesNotificationDisplayer.show(content, this::synchronizeLayoutEditor);
    if (setActiveOnLoad) {
        setActiveInstance();
        setActiveOnLoad = false;
    }
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)

Example 15 with LayoutTemplate

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

the class AbstractFormLayoutTemplateGenerator method generateLayoutTemplate.

@Override
public void generateLayoutTemplate(FormDefinition formDefinition) {
    formDefinition.setLayoutTemplate(new LayoutTemplate());
    addFieldsToTemplate(formDefinition.getLayoutTemplate(), formDefinition.getFields(), formDefinition.getId());
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)

Aggregations

LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)20 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)9 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)8 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)8 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)8 Test (org.junit.Test)7 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)7 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)7 LayoutColumnDefinition (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition)6 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)6 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)6 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)6 IntStream (java.util.stream.IntStream)5 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)5 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)4 LayoutSettings (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings)3 Field (org.kie.workbench.common.forms.migration.legacy.model.Field)3 FormMigrationSummary (org.kie.workbench.common.forms.migration.tool.FormMigrationSummary)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2