use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class PmoBasedDialogFactory method newOkCancelDialog.
/**
* Creates a new {@link OkCancelDialog}.
*
* @param title The dialog title.
* @param okHandler The called when OK is clicked.
* @param pmos The presentation model objects providing the data and the layout information.
* @return A dialog with the content defined by the given PMO.
*/
public OkCancelDialog newOkCancelDialog(String title, Handler okHandler, Object... pmos) {
OkCancelDialog dialog = new OkCancelDialog(title, okHandler, ButtonOption.OK_CANCEL);
DialogBindingManager bindingManager = new DialogBindingManager(dialog, validationService, propertyBehaviorProvider);
BindingContext bindingContext = bindingManager.startNewContext(dialog.getClass());
for (Object pmo : pmos) {
AbstractSection content;
if (pmo instanceof ContainerPmo) {
content = pmoBasedSectionFactory.createTableSection((ContainerPmo<?>) pmo, bindingContext);
} else {
content = pmoBasedSectionFactory.createSection(pmo, bindingContext);
}
float expRatio = 0f;
if (pmo == pmos[pmos.length - 1]) {
expRatio = 1f;
}
dialog.addContent(content, expRatio);
}
bindingContext.updateUI();
return dialog;
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class PmoBasedTableSectionFactoryTest method testCreateSection_SectionHasAddButtonInHeader.
@Test
public void testCreateSection_SectionHasAddButtonInHeader() {
TestTablePmo containerPmo = new TestTablePmo();
BindingContext bindingContext = TestBindingContext.create();
PmoBasedTableSectionFactory<TestRowPmo> factory = new PmoBasedTableSectionFactory<TestRowPmo>(containerPmo, bindingContext);
TableSection<TestRowPmo> tableSection = factory.createSection();
assertThat(tableSection, is(notNullValue()));
// header and table
assertThat(tableSection.getComponentCount(), is(2));
assertThat(tableSection.getComponent(0), is(instanceOf(HorizontalLayout.class)));
HorizontalLayout header = (HorizontalLayout) tableSection.getComponent(0);
// caption, add button and close button
assertThat(header.getComponentCount(), is(3));
assertThat(header.getComponent(1), is(instanceOf(Button.class)));
Button addButton = (Button) header.getComponent(1);
assertThat(addButton.getIcon(), is(FontAwesome.PLUS));
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class PmoBasedTableSectionFactoryTest method testCreateSection_TableIsAddedAndBound.
@Test
public void testCreateSection_TableIsAddedAndBound() {
TestTablePmo containerPmo = new TestTablePmo();
BindingContext bindingContext = TestBindingContext.create();
PmoBasedTableSectionFactory<TestRowPmo> factory = new PmoBasedTableSectionFactory<TestRowPmo>(containerPmo, bindingContext);
TableSection<TestRowPmo> tableSection = factory.createSection();
assertThat(tableSection, is(notNullValue()));
// header and table
assertThat(tableSection.getComponentCount(), is(2));
assertThat(tableSection.getComponent(1), is(instanceOf(Table.class)));
Table table = (Table) tableSection.getComponent(1);
assertThat(table.getContainerDataSource(), is(instanceOf(TableBinding.class)));
TableBinding<?> tableBinding = (TableBinding<?>) table.getContainerDataSource();
assertThat(bindingContext.getTableBindings(), hasItem(tableBinding));
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class GettingStartedUI method init.
@Override
protected void init(VaadinRequest request) {
Page.getCurrent().setTitle("Linkki :: Getting Started");
DefaultPmoBasedSectionFactory sectionFactory = new DefaultPmoBasedSectionFactory();
AbstractSection section = sectionFactory.createSection(new ReportSectionPmo(new Report()), new BindingContext("report-context", PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER, Handler.NOP_HANDLER));
setContent(section);
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class BindingSampleUI method init.
@Override
protected void init(VaadinRequest request) {
Page.getCurrent().setTitle("linkki Sample :: Bindings");
List<Contact> personStorage = new ArrayList<>();
BindingManager bindingManager = new DefaultBindingManager(ValidationService.NOP_VALIDATION_SERVICE);
BindingContext context = bindingManager.startNewContext("binding-sample");
ContactComponent contactComponent = new ContactComponent(p -> save(p, personStorage), context);
ContactsTableComponent contactsTable = new ContactsTableComponent(personStorage, contactComponent::editContact, context);
bindingManager.addUiUpdateObserver(contactsTable);
HorizontalSplitPanel panel = new HorizontalSplitPanel(contactComponent, contactsTable);
panel.setLocked(true);
setContent(panel);
}
Aggregations