Search in sources :

Example 1 with BaseSection

use of org.linkki.core.vaadin.component.section.BaseSection in project linkki by linkki-framework.

the class PmoBasedSectionFactoryTest method testSetComponentId.

@Test
public void testSetComponentId() {
    BaseSection section = (BaseSection) PmoBasedSectionFactory.createAndBindSection(new SCCPmoWithID(), bindingContext);
    Component textField = TestUiUtil.getComponentAtIndex(0, section.getContentWrapper());
    assertThat(textField.getId(), hasValue("testProperty"));
}
Also used : BaseSection(org.linkki.core.vaadin.component.section.BaseSection) Component(com.vaadin.flow.component.Component) Test(org.junit.jupiter.api.Test)

Example 2 with BaseSection

use of org.linkki.core.vaadin.component.section.BaseSection in project linkki by linkki-framework.

the class SectionComponentDefiniton method createComponent.

private Object createComponent(Class<?> pmoClass) {
    String nlsCaption = PmoNlsService.get().getSectionCaption(pmoClass, this.caption);
    if (ContainerPmo.class.isAssignableFrom(pmoClass)) {
        return createTableSection(nlsCaption);
    } else {
        BaseSection baseSection = new BaseSection(nlsCaption, closeable);
        baseSection.getElement().getThemeList().addAll(layout.getThemeNames());
        return baseSection;
    }
}
Also used : BaseSection(org.linkki.core.vaadin.component.section.BaseSection)

Example 3 with BaseSection

use of org.linkki.core.vaadin.component.section.BaseSection in project linkki by linkki-framework.

the class UINestedComponentIntegrationTest method testCreateNestedComponent.

@Test
public void testCreateNestedComponent() {
    BaseSection component = (BaseSection) VaadinUiCreator.createComponent(new NestedComponentPmo(), new BindingContext());
    List<FormItem> childComponents = component.getContentWrapper().getChildren().map(FormItem.class::cast).collect(Collectors.toList());
    assertThat(childComponents.stream().map(i -> getChild(i, 0)).collect(Collectors.toList()), contains(instanceOf(TextField.class), instanceOf(Div.class)));
    FormItem nestedComponentFormItem = childComponents.get(1);
    assertThat(getChild(nestedComponentFormItem, 1).getElement().getText(), is("Name/Vorname"));
    Div nestedComponentWrapper = (Div) getChild(nestedComponentFormItem, 0);
    assertThat(nestedComponentWrapper.getWidth(), is("100px"));
    assertThat(nestedComponentWrapper.getClassName(), is("style1 style2"));
    Component nestedComponent = getChild(nestedComponentWrapper, 0);
    assertThat(nestedComponent, instanceOf(HorizontalLayout.class));
    assertThat(((HorizontalLayout) nestedComponent).getWidth(), is("100px"));
    assertThat(getChild(nestedComponent, 0), instanceOf(TextField.class));
}
Also used : Div(com.vaadin.flow.component.html.Div) BaseSection(org.linkki.core.vaadin.component.section.BaseSection) LabelComponentFormItem(org.linkki.core.vaadin.component.base.LabelComponentFormItem) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) UITextField(org.linkki.core.ui.element.annotation.UITextField) TextField(com.vaadin.flow.component.textfield.TextField) BindingContext(org.linkki.core.binding.BindingContext) Component(com.vaadin.flow.component.Component) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) UIHorizontalLayout(org.linkki.core.ui.layout.annotation.UIHorizontalLayout) Test(org.junit.jupiter.api.Test)

Example 4 with BaseSection

use of org.linkki.core.vaadin.component.section.BaseSection in project linkki by linkki-framework.

the class UINestedComponentIntegrationTest method testApsectOnNestedComponent.

@Test
public void testApsectOnNestedComponent() {
    NestedComponentPmo pmo = new NestedComponentPmo();
    BindingContext bindingContext = new BindingContext();
    BaseSection component = (BaseSection) VaadinUiCreator.createComponent(pmo, bindingContext);
    LabelComponentFormItem nestedComponent = (LabelComponentFormItem) getChild(component.getContentWrapper(), 1);
    assertThat(nestedComponent.isVisible(), is(true));
    pmo.setVisible(false);
    bindingContext.modelChanged();
    assertThat(nestedComponent.isVisible(), is(false));
}
Also used : BaseSection(org.linkki.core.vaadin.component.section.BaseSection) LabelComponentFormItem(org.linkki.core.vaadin.component.base.LabelComponentFormItem) BindingContext(org.linkki.core.binding.BindingContext) Test(org.junit.jupiter.api.Test)

Example 5 with BaseSection

use of org.linkki.core.vaadin.component.section.BaseSection in project linkki by linkki-framework.

the class UIFormSectionIntegrationTest method testCreation.

@Test
void testCreation() {
    BindingContext bindingContext = new BindingContext();
    FormSectionPmo pmo = new FormSectionPmo();
    Component component = VaadinUiCreator.createComponent(pmo, bindingContext);
    assertThat("UiCreator should be able to create a FormSection", component, is(instanceOf(BaseSection.class)));
    BaseSection formSection = (BaseSection) component;
    assertThat(formSection.getCaption(), is("Caption"));
    assertThat(formSection.getContentWrapper().getComponentCount(), is(1));
}
Also used : BaseSection(org.linkki.core.vaadin.component.section.BaseSection) BindingContext(org.linkki.core.binding.BindingContext) Component(com.vaadin.flow.component.Component) Test(org.junit.jupiter.api.Test)

Aggregations

BaseSection (org.linkki.core.vaadin.component.section.BaseSection)5 Test (org.junit.jupiter.api.Test)4 Component (com.vaadin.flow.component.Component)3 BindingContext (org.linkki.core.binding.BindingContext)3 LabelComponentFormItem (org.linkki.core.vaadin.component.base.LabelComponentFormItem)2 FormItem (com.vaadin.flow.component.formlayout.FormLayout.FormItem)1 Div (com.vaadin.flow.component.html.Div)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 TextField (com.vaadin.flow.component.textfield.TextField)1 UITextField (org.linkki.core.ui.element.annotation.UITextField)1 UIHorizontalLayout (org.linkki.core.ui.layout.annotation.UIHorizontalLayout)1