Search in sources :

Example 1 with LinkkiSection

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

the class BindStyleNamesIntegrationTest method testSection_dynamic_inherited.

@Test
public void testSection_dynamic_inherited() {
    TestChildSectionPmoWithDynamicClassStyleNames pmo = new TestChildSectionPmoWithDynamicClassStyleNames();
    BindingContext bindingContext = new BindingContext();
    LinkkiSection section = PmoBasedSectionFactory.createAndBindSection(pmo, bindingContext);
    pmo.setStyleNames(Arrays.asList("ml"));
    bindingContext.modelChanged();
    assertThat(section.getClassName(), containsString("ml"));
    pmo.setStyleNames(Arrays.asList("lisp"));
    bindingContext.modelChanged();
    String styleNamesAfterUpdate = section.getClassName();
    assertThat(styleNamesAfterUpdate, not(containsString("ml")));
    assertThat(styleNamesAfterUpdate, containsString("lisp"));
}
Also used : LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection) Matchers.containsString(org.hamcrest.Matchers.containsString) BindingContext(org.linkki.core.binding.BindingContext) Test(org.junit.jupiter.api.Test)

Example 2 with LinkkiSection

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

the class PmoNlsServiceTableSectionTest method createAndGetTableSectionCaption.

private String createAndGetTableSectionCaption(ContainerPmo<NlsTableRowPmo> containerPmo) {
    PmoBasedSectionFactory factory = new PmoBasedSectionFactory();
    LinkkiSection tableSection = factory.createSection(containerPmo, bindingContext);
    return tableSection.getCaption();
}
Also used : LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection) PmoBasedSectionFactory(org.linkki.core.ui.creation.section.PmoBasedSectionFactory)

Example 3 with LinkkiSection

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

the class PmoBasedSectionFactory method createAndBindSection.

/**
 * Creates a new section based on the given annotated PMO and binds the created controls via the
 * given binding context to the PMO. If the given PMO is a {@link ContainerPmo}, a table section is
 * created.
 */
public static LinkkiSection createAndBindSection(Object pmo, BindingContext bindingContext) {
    requireNonNull(pmo, "pmo must not be null");
    requireNonNull(bindingContext, "bindingContext must not be null");
    Class<? extends Object> pmoClass = pmo.getClass();
    LinkkiComponentDefinition componentDefinition = ComponentAnnotationReader.findComponentDefinition(pmoClass).orElse(SectionComponentDefiniton.DEFAULT);
    LinkkiLayoutDefinition layoutDefinition = LayoutAnnotationReader.findLayoutDefinition(pmoClass).orElse(SectionLayoutDefinition.DEFAULT);
    ComponentWrapper componentWrapper = UiCreator.createComponent(pmo, bindingContext, componentDefinition, Optional.of(layoutDefinition));
    return (LinkkiSection) componentWrapper.getComponent();
}
Also used : LinkkiComponentDefinition(org.linkki.core.binding.uicreation.LinkkiComponentDefinition) LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection) LinkkiLayoutDefinition(org.linkki.core.uicreation.layout.LinkkiLayoutDefinition) ComponentWrapper(org.linkki.core.binding.wrapper.ComponentWrapper)

Example 4 with LinkkiSection

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

the class ContactComponent method createContent.

private void createContent() {
    LinkkiSection contactSection = sectionFactory.createSection(contactPmo, bindingContext);
    AddressFields addressFields = new AddressFields();
    AddressComponent addressComponent = new AddressComponent(addressFields);
    // tag::manual-binding[]
    new Binder(addressFields, addressPmo).setupBindings(bindingContext);
    // end::manual-binding[]
    LinkkiSection childrenSection = sectionFactory.createSection(childrenSectionPmo, bindingContext);
    Component buttonsSection = VaadinUiCreator.createComponent(buttonsSectionPmo, bindingContext);
    VerticalLayout wrapperLayout = new VerticalLayout(contactSection, addressComponent, childrenSection, buttonsSection);
    wrapperLayout.setHorizontalComponentAlignment(Alignment.END, buttonsSection);
    add(wrapperLayout);
}
Also used : Binder(org.linkki.core.binding.Binder) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection) Component(com.vaadin.flow.component.Component)

Example 5 with LinkkiSection

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

the class ProductsSampleOverviewPage method createContent.

@Override
public void createContent() {
    addSection(new ProductsSamplePmo.VerticalSamplePmo());
    addSection(new ProductsSamplePmo.HorizontalSamplePmo());
    // Two column layout
    addSections(new ProductsSamplePmo.VerticalSamplePmo(), new ProductsSamplePmo.VerticalSamplePmo());
    // Scroll and grow table section
    LinkkiSection tableSection = addSection(new ProductsSampleTablePmo(100, 0));
    ComponentStyles.setOverflowAuto(tableSection);
    addAndExpand(tableSection);
}
Also used : LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection)

Aggregations

LinkkiSection (org.linkki.core.vaadin.component.section.LinkkiSection)20 Test (org.junit.jupiter.api.Test)9 BindingContext (org.linkki.core.binding.BindingContext)6 Button (com.vaadin.flow.component.button.Button)3 PmoBasedSectionFactory (org.linkki.core.ui.creation.section.PmoBasedSectionFactory)3 Component (com.vaadin.flow.component.Component)2 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Binder (org.linkki.core.binding.Binder)2 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1 Div (com.vaadin.flow.component.html.Div)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 LinkkiComponentDefinition (org.linkki.core.binding.uicreation.LinkkiComponentDefinition)1 ComponentWrapper (org.linkki.core.binding.wrapper.ComponentWrapper)1 SamplePmo (org.linkki.core.nls.sample.SamplePmo)1 UIButton (org.linkki.core.ui.element.annotation.UIButton)1 LinkkiLayoutDefinition (org.linkki.core.uicreation.layout.LinkkiLayoutDefinition)1 Headline (org.linkki.framework.ui.component.Headline)1