use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class DialogBindingManagerTest method testBindingsInCreatedContextsDisplayMessagesFromDialog.
@Test
public void testBindingsInCreatedContextsDisplayMessagesFromDialog() {
OkCancelDialog dialog = new OkCancelDialog("");
// Use the NOP validation service in the binding manager
DialogBindingManager manager = new DialogBindingManager(dialog, ValidationService.NOP_VALIDATION_SERVICE);
BindingContext ctx = manager.startNewContext("foo");
// Change the dialog's validation service to make sure dialog's validate method is used and
// not the validation service the manager was created with (so that the dialog could filter
// the messages)
MessageList messages = new MessageList(Message.newError("code", "text"));
dialog.setValidationService(ValidationService.of(messages));
PropertyDispatcher propertyDispatcher = mock(PropertyDispatcher.class);
Object pmo = mock(Object.class);
when(propertyDispatcher.getBoundObject()).thenReturn(pmo);
when(propertyDispatcher.getMessages(any())).thenReturn(new MessageList());
ComponentBinding binding = spy(new ComponentBinding(new LabelComponentWrapper(new Label(), new Button()), propertyDispatcher, Handler.NOP_HANDLER, new ArrayList<>()));
ctx.add(binding);
ctx.updateUI();
verify(binding).displayMessages(messages);
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class PmoNlsServiceSectionTest method setUp.
@Before
public void setUp() {
BindingContext context = TestBindingContext.create();
BaseSection section = new DefaultPmoBasedSectionFactory().createBaseSection(new SamplePmo(), context);
HorizontalLayout header = (HorizontalLayout) section.getComponent(0);
sectionHeader = (Label) header.getComponent(0);
GridLayout sectionContent = (GridLayout) ((Panel) section.getComponent(1)).getContent();
textfieldLabelWithTranslation = (Label) sectionContent.getComponent(0, 0);
textfieldLabelWithoutTranslation = (Label) sectionContent.getComponent(0, 1);
buttonLabelWithTranslation = (Label) sectionContent.getComponent(0, 2);
buttonWithTranslatedCaption = (Button) sectionContent.getComponent(1, 2);
invisibleButtonLabelWithTranslation = (Label) sectionContent.getComponent(0, 3);
buttonWithoutTranslatedCaption = (Button) sectionContent.getComponent(1, 3);
// 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(getLabelTranslation(SamplePmo.PROPERTY_MYBUTTON2), is(buttonLabelTranslation));
assertThat(getCaptionTranslation(SamplePmo.PROPERTY_MYBUTTON2), is(SamplePmo.PMO_CAPTION));
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class PmoBasedTableSectionFactoryTest method testCreateSection_NoAnnotation.
@Test
public void testCreateSection_NoAnnotation() {
NoAnnotationTablePmo containerPmo = new NoAnnotationTablePmo();
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 CustomLayoutUI method init.
@Override
protected void init(VaadinRequest request) {
Page.getCurrent().setTitle("Linkki :: Custom Layout Sample");
BindingContext bindingContext = new BindingContext();
AbstractSection section = new DefaultPmoBasedSectionFactory().createSection(new AddressSectionPmo(), bindingContext);
setContent(section);
}
use of org.linkki.core.binding.BindingContext in project linkki by linkki-framework.
the class DynamicFieldUI method init.
@Override
protected void init(VaadinRequest request) {
Page.getCurrent().setTitle("Linkki :: Dynamic Fields Sample");
List<Car> carStorage = getCarStorage();
BindingContext bindingContext = new BindingContext();
TableSection<CarRowPmo> table = new DefaultPmoBasedSectionFactory().createTableSection(new CarTablePmo(carStorage, () -> new NewCarDialog(carStorage, bindingContext::updateUI)), bindingContext);
setContent(table);
}
Aggregations