Search in sources :

Example 1 with ReflectionPropertyDispatcher

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

the class PropertyDispatcherFactory method newReflectionDispatcher.

private ReflectionPropertyDispatcher newReflectionDispatcher(Object pmo, String pmoPropertyName, String modelObjectName, String modelObjectProperty, PropertyDispatcher wrappedDispatcher) {
    if (UIAnnotationReader.hasModelObjectAnnotatedMethod(pmo, modelObjectName)) {
        Supplier<?> modelObject = UIAnnotationReader.getModelObjectSupplier(pmo, modelObjectName);
        ReflectionPropertyDispatcher modelObjectDispatcher = new ReflectionPropertyDispatcher(modelObject, modelObjectProperty, wrappedDispatcher);
        return new ReflectionPropertyDispatcher(() -> pmo, pmoPropertyName, modelObjectDispatcher);
    } else {
        return new ReflectionPropertyDispatcher(() -> pmo, pmoPropertyName, wrappedDispatcher);
    }
}
Also used : ReflectionPropertyDispatcher(org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher)

Example 2 with ReflectionPropertyDispatcher

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

the class PropertyDispatcherFactory method createDispatcherChain.

public PropertyDispatcher createDispatcherChain(Object pmo, BindingDescriptor bindingDescriptor, PropertyBehaviorProvider behaviorProvider) {
    requireNonNull(pmo, "pmo must not be null");
    requireNonNull(bindingDescriptor, "bindingDescriptor must not be null");
    requireNonNull(behaviorProvider, "behaviorProvider must not be null");
    // @formatter:off
    String modelPropertyName = bindingDescriptor.getModelPropertyName();
    String modelObjectName = bindingDescriptor.getModelObjectName();
    String pmoPropertyName = bindingDescriptor.getPmoPropertyName();
    ExceptionPropertyDispatcher exceptionDispatcher = newExceptionDispatcher(pmo, modelObjectName, pmoPropertyName);
    ReflectionPropertyDispatcher reflectionDispatcher = newReflectionDispatcher(pmo, pmoPropertyName, modelObjectName, modelPropertyName, exceptionDispatcher);
    StaticValueDispatcher bindingAnnotationDispatcher = new StaticValueDispatcher(reflectionDispatcher);
    PropertyDispatcher customDispatchers = createCustomDispatchers(pmo, bindingDescriptor, bindingAnnotationDispatcher);
    return new BehaviorDependentDispatcher(customDispatchers, behaviorProvider);
// @formatter:on
}
Also used : BehaviorDependentDispatcher(org.linkki.core.binding.dispatcher.BehaviorDependentDispatcher) ReflectionPropertyDispatcher(org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher) ExceptionPropertyDispatcher(org.linkki.core.binding.dispatcher.ExceptionPropertyDispatcher) ReflectionPropertyDispatcher(org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher) PropertyDispatcher(org.linkki.core.binding.dispatcher.PropertyDispatcher) ExceptionPropertyDispatcher(org.linkki.core.binding.dispatcher.ExceptionPropertyDispatcher) StaticValueDispatcher(org.linkki.core.binding.dispatcher.StaticValueDispatcher)

Example 3 with ReflectionPropertyDispatcher

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

the class ButtonPmoBindingTest method testButtonClickIsForwaredToPmo.

@Test
public void testButtonClickIsForwaredToPmo() {
    ButtonPmo pmo = mock(ButtonPmo.class);
    PropertyDispatcher propertyDispatcher = new org.linkki.core.binding.dispatcher.ButtonPmoDispatcher(new ReflectionPropertyDispatcher(() -> pmo, StringUtils.EMPTY, wrappedDispatcher));
    ButtonPmoBinding buttonPmoBinding = new ButtonPmoBinding(button, propertyDispatcher, bindingContext::updateUI);
    bindingContext.add(buttonPmoBinding);
    button.click();
    verify(pmo).onClick();
}
Also used : ButtonPmo(org.linkki.core.ButtonPmo) 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 4 with ReflectionPropertyDispatcher

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

the class ButtonPmoBindingTest method testUpdateFromPmo_LambdaPmo.

@Test
public void testUpdateFromPmo_LambdaPmo() {
    ButtonPmo lambdaPmo = () -> System.out.println("click");
    PropertyDispatcher propertyDispatcher = new org.linkki.core.binding.dispatcher.ButtonPmoDispatcher(new ReflectionPropertyDispatcher(() -> lambdaPmo, StringUtils.EMPTY, wrappedDispatcher));
    ButtonPmoBinding binding = new ButtonPmoBinding(button, propertyDispatcher, bindingContext::updateUI);
    bindingContext.add(binding);
    binding.updateFromPmo();
    assertThat(button.isVisible(), is(true));
    assertThat(button.isEnabled(), is(true));
}
Also used : ButtonPmo(org.linkki.core.ButtonPmo) 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 5 with ReflectionPropertyDispatcher

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

the class PropertyDispatcherFactory method createDispatcherChain.

public PropertyDispatcher createDispatcherChain(ButtonPmo buttonPmo, PropertyBehaviorProvider behaviorProvider) {
    requireNonNull(buttonPmo, "buttonPmo must not be null");
    requireNonNull(behaviorProvider, "behaviorProvider must not be null");
    // @formatter:off
    String modelObjectName = ModelObject.DEFAULT_NAME;
    ExceptionPropertyDispatcher exceptionDispatcher = newExceptionDispatcher(buttonPmo, modelObjectName, StringUtils.EMPTY);
    ReflectionPropertyDispatcher reflectionDispatcher = newReflectionDispatcher(buttonPmo, StringUtils.EMPTY, modelObjectName, StringUtils.EMPTY, exceptionDispatcher);
    @SuppressWarnings("deprecation") org.linkki.core.binding.dispatcher.ButtonPmoDispatcher buttonPmoDispatcher = new org.linkki.core.binding.dispatcher.ButtonPmoDispatcher(reflectionDispatcher);
    return new BehaviorDependentDispatcher(buttonPmoDispatcher, behaviorProvider);
// @formatter:on
}
Also used : BehaviorDependentDispatcher(org.linkki.core.binding.dispatcher.BehaviorDependentDispatcher) ReflectionPropertyDispatcher(org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher) ExceptionPropertyDispatcher(org.linkki.core.binding.dispatcher.ExceptionPropertyDispatcher)

Aggregations

ReflectionPropertyDispatcher (org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher)6 PropertyDispatcher (org.linkki.core.binding.dispatcher.PropertyDispatcher)4 Test (org.junit.Test)3 ButtonPmo (org.linkki.core.ButtonPmo)2 BehaviorDependentDispatcher (org.linkki.core.binding.dispatcher.BehaviorDependentDispatcher)2 ExceptionPropertyDispatcher (org.linkki.core.binding.dispatcher.ExceptionPropertyDispatcher)2 StaticValueDispatcher (org.linkki.core.binding.dispatcher.StaticValueDispatcher)1