Search in sources :

Example 1 with PmoBasedSectionFactory

use of org.linkki.core.ui.creation.section.PmoBasedSectionFactory in project linkki by linkki-framework.

the class SelectableTableSection method create.

public static Component create() {
    List<TableModelObject> modelObjects = IntStream.range(1, 10).mapToObj(TableModelObject::new).collect(Collectors.toList());
    PlaygroundSelectableTablePmo selectableTableSectionPmo = new PlaygroundSelectableTablePmo(() -> modelObjects, () -> modelObjects.add(new TableModelObject(modelObjects.size() + 1)), o -> modelObjects.remove(o));
    GridSection gridSection = (GridSection) new PmoBasedSectionFactory().createSection(selectableTableSectionPmo, new BindingContext("selectableTable"));
    SingleSelect<?, ?> singleSelect = gridSection.getGrid().asSingleSelect();
    BindingContext comparisonBindingContext = new BindingContext("selectableTableComparison");
    Component comparisonSection = VaadinUiCreator.createComponent(new SelectionComparisonSectionPmo(() -> (PlaygroundRowPmo) singleSelect.getValue(), () -> selectableTableSectionPmo.getSelection(), comparisonBindingContext::modelChanged), comparisonBindingContext);
    Div div = new Div();
    div.setWidthFull();
    div.add(gridSection);
    div.add(comparisonSection);
    return div;
}
Also used : Div(com.vaadin.flow.component.html.Div) TableModelObject(org.linkki.samples.playground.table.TableModelObject) BindingContext(org.linkki.core.binding.BindingContext) Component(com.vaadin.flow.component.Component) PlaygroundRowPmo(org.linkki.samples.playground.table.PlaygroundRowPmo) GridSection(org.linkki.core.vaadin.component.section.GridSection) PmoBasedSectionFactory(org.linkki.core.ui.creation.section.PmoBasedSectionFactory)

Example 2 with PmoBasedSectionFactory

use of org.linkki.core.ui.creation.section.PmoBasedSectionFactory 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 PmoBasedSectionFactory

use of org.linkki.core.ui.creation.section.PmoBasedSectionFactory in project linkki by linkki-framework.

the class TestUiUtil method createSectionWith.

public static Div createSectionWith(Object pmo, BindingContext bindingContext) {
    PmoBasedSectionFactory sectionFactory = new PmoBasedSectionFactory();
    LinkkiSection section = sectionFactory.createSection(pmo, bindingContext);
    bindingContext.modelChanged();
    return section.getContentWrapper();
}
Also used : LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection) PmoBasedSectionFactory(org.linkki.core.ui.creation.section.PmoBasedSectionFactory)

Example 4 with PmoBasedSectionFactory

use of org.linkki.core.ui.creation.section.PmoBasedSectionFactory in project linkki by linkki-framework.

the class TableSelectionAspectIntegrationTest method testTableSectionSelectable.

@Test
public void testTableSectionSelectable() {
    GridSection table = (GridSection) new PmoBasedSectionFactory().createSection(new TestSelectableTablePmo(), new BindingContext());
    table.getGrid().setPageSize(1);
    assertThat("Table in table section is selectable", table.getGrid().getSelectionModel(), is(instanceOf(GridSingleSelectionModel.class)));
}
Also used : BindingContext(org.linkki.core.binding.BindingContext) GridSection(org.linkki.core.vaadin.component.section.GridSection) PmoBasedSectionFactory(org.linkki.core.ui.creation.section.PmoBasedSectionFactory) Test(org.junit.jupiter.api.Test)

Example 5 with PmoBasedSectionFactory

use of org.linkki.core.ui.creation.section.PmoBasedSectionFactory in project linkki by linkki-framework.

the class PmoNlsServiceSectionTest method setUp.

@BeforeEach
public void setUp() {
    BindingContext context = new BindingContext();
    LinkkiSection section = new PmoBasedSectionFactory().createSection(new SamplePmo(), context);
    sectionCaption = section.getCaption();
    Div sectionContent = section.getContentWrapper();
    textfieldLabelWithTranslation = TestUiUtil.getLabelOfComponentAt(sectionContent, 0);
    textfieldLabelWithoutTranslation = TestUiUtil.getLabelOfComponentAt(sectionContent, 1);
    buttonWithTranslatedCaption = (Button) TestUiUtil.getComponentAtIndex(2, sectionContent);
    buttonWithoutTranslatedCaption = (Button) TestUiUtil.getComponentAtIndex(3, sectionContent);
    // test setup
    PmoNlsService.get();
    textfieldLabelTranslation = getLabelTranslation(SamplePmo.PROPERTY_TEXTFIELD);
    assertThat(textfieldLabelTranslation, is(not(SamplePmo.PMO_LABEL)));
    buttonLabelTranslation = getLabelTranslation(SamplePmo.PROPERTY_MYBUTTON);
    assertThat(buttonLabelTranslation, is(not(SamplePmo.PMO_LABEL)));
    buttonCaptionTranslation = getCaptionTranslation(SamplePmo.PROPERTY_MYBUTTON);
    assertThat(buttonCaptionTranslation, is(not(SamplePmo.PMO_CAPTION)));
    assertThat(getLabelTranslation(SamplePmo.PROPERTY_CBFIELD), is(SamplePmo.PMO_LABEL));
    assertThat(getCaptionTranslation(SamplePmo.PROPERTY_MYBUTTON2), is(SamplePmo.PMO_CAPTION));
}
Also used : Div(com.vaadin.flow.component.html.Div) SamplePmo(org.linkki.core.nls.sample.SamplePmo) LinkkiSection(org.linkki.core.vaadin.component.section.LinkkiSection) BindingContext(org.linkki.core.binding.BindingContext) PmoBasedSectionFactory(org.linkki.core.ui.creation.section.PmoBasedSectionFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PmoBasedSectionFactory (org.linkki.core.ui.creation.section.PmoBasedSectionFactory)6 BindingContext (org.linkki.core.binding.BindingContext)4 LinkkiSection (org.linkki.core.vaadin.component.section.LinkkiSection)3 Div (com.vaadin.flow.component.html.Div)2 GridSection (org.linkki.core.vaadin.component.section.GridSection)2 Component (com.vaadin.flow.component.Component)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 SamplePmo (org.linkki.core.nls.sample.SamplePmo)1 PlaygroundRowPmo (org.linkki.samples.playground.table.PlaygroundRowPmo)1 TableModelObject (org.linkki.samples.playground.table.TableModelObject)1