Search in sources :

Example 11 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class ButtonPmoBindingTest method testUpdateFromPmo_PmoSublass.

@Test
public void testUpdateFromPmo_PmoSublass() {
    TestButtonPmo pmo = new TestButtonPmo();
    PropertyDispatcher propertyDispatcher = new org.linkki.core.binding.dispatcher.ButtonPmoDispatcher(new ReflectionPropertyDispatcher(() -> pmo, StringUtils.EMPTY, wrappedDispatcher));
    ButtonPmoBinding binding = new ButtonPmoBinding(button, propertyDispatcher, bindingContext::updateUI);
    bindingContext.add(binding);
    pmo.enabled = true;
    pmo.visible = true;
    binding.updateFromPmo();
    assertThat(button.isVisible(), is(true));
    assertThat(button.isEnabled(), is(true));
    pmo.enabled = false;
    pmo.visible = false;
    binding.updateFromPmo();
    assertThat(button.isVisible(), is(false));
    assertThat(button.isEnabled(), is(false));
}
Also used : ReflectionPropertyDispatcher(org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher) ReflectionPropertyDispatcher(org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) Test(org.junit.Test)

Example 12 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_getValueFromPmo.

@Test
public void testCreateDispatcherChain_getValueFromPmo() {
    setUpPmo();
    when(elementDescriptor.getModelPropertyName()).thenReturn("foo");
    when(elementDescriptor.getModelObjectName()).thenReturn(ModelObject.DEFAULT_NAME);
    when(elementDescriptor.getPmoPropertyName()).thenReturn("value");
    PropertyDispatcher defaultDispatcher = propertyDispatcherFactory.createDispatcherChain(pmo, elementDescriptor, PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER);
    pmo.setValue(ANY_VALUE);
    Object pmoProp = defaultDispatcher.pull(Aspect.of(""));
    assertThat(pmoProp, is(ANY_VALUE));
}
Also used : PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) ModelObject(org.linkki.core.ui.section.annotations.ModelObject) TestModelObject(org.linkki.core.binding.BindingContextTest.TestModelObject) Test(org.junit.Test)

Example 13 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_getValueFromModelObject.

@Test
public void testCreateDispatcherChain_getValueFromModelObject() {
    setUpPmo();
    when(elementDescriptor.getModelPropertyName()).thenReturn(TestModelObject.PROPERTY_MODEL_PROP);
    when(elementDescriptor.getModelObjectName()).thenReturn(ModelObject.DEFAULT_NAME);
    when(elementDescriptor.getPmoPropertyName()).thenReturn("foo");
    PropertyDispatcher defaultDispatcher = propertyDispatcherFactory.createDispatcherChain(pmo, elementDescriptor, PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER);
    modelObject.setModelProp("testValue");
    Object modelProp = defaultDispatcher.pull(Aspect.of(""));
    assertThat(modelProp, is("testValue"));
}
Also used : PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) ModelObject(org.linkki.core.ui.section.annotations.ModelObject) TestModelObject(org.linkki.core.binding.BindingContextTest.TestModelObject) Test(org.junit.Test)

Example 14 with PropertyDispatcher

use of org.linkki.core.binding.dispatcher.PropertyDispatcher in project linkki by linkki-framework.

the class PropertyDispatcherFactoryTest method testCreateDispatcherChain_push.

@Test
public void testCreateDispatcherChain_push() {
    setUpPmo();
    when(elementDescriptor.getModelPropertyName()).thenReturn(TestModelObject.PROPERTY_MODEL_PROP);
    when(elementDescriptor.getModelObjectName()).thenReturn(ModelObject.DEFAULT_NAME);
    when(elementDescriptor.getPmoPropertyName()).thenReturn("foo");
    PropertyDispatcher defaultDispatcher = propertyDispatcherFactory.createDispatcherChain(pmo, elementDescriptor, PropertyBehaviorProvider.NO_BEHAVIOR_PROVIDER);
    defaultDispatcher.push(Aspect.of("", "testSetValue"));
    assertThat(modelObject.getModelProp(), is("testSetValue"));
}
Also used : PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) Test(org.junit.Test)

Aggregations

PropertyDispatcher (org.linkki.core.binding.dispatcher.PropertyDispatcher)14 Test (org.junit.Test)13 TestModelObject (org.linkki.core.binding.BindingContextTest.TestModelObject)4 ReflectionPropertyDispatcher (org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher)4 LabelComponentWrapper (org.linkki.core.ui.components.LabelComponentWrapper)4 ElementBinding (org.linkki.core.binding.ElementBinding)3 Bind (org.linkki.core.binding.annotations.Bind)3 ModelObject (org.linkki.core.ui.section.annotations.ModelObject)3 BindAnnotationDescriptor (org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor)3 Button (com.vaadin.ui.Button)2 Label (com.vaadin.ui.Label)2 ButtonPmo (org.linkki.core.ButtonPmo)2 TextField (com.vaadin.ui.TextField)1 ArrayList (java.util.ArrayList)1 BindingContext (org.linkki.core.binding.BindingContext)1 ComponentBinding (org.linkki.core.binding.ComponentBinding)1 BehaviorDependentDispatcher (org.linkki.core.binding.dispatcher.BehaviorDependentDispatcher)1 ExceptionPropertyDispatcher (org.linkki.core.binding.dispatcher.ExceptionPropertyDispatcher)1 StaticValueDispatcher (org.linkki.core.binding.dispatcher.StaticValueDispatcher)1 MessageList (org.linkki.core.message.MessageList)1