Search in sources :

Example 1 with BindingDefinition

use of org.linkki.core.ui.section.annotations.BindingDefinition in project linkki by linkki-framework.

the class BindingContextTest method testBind_BoundComponentsAreMadeImmediate.

@Test
public void testBind_BoundComponentsAreMadeImmediate() {
    setUpPmo();
    TextField field = new TextField();
    BindingDefinition fieldDefintion = mock(BindingDefinition.class);
    when(fieldDefintion.required()).thenReturn(RequiredType.REQUIRED);
    when(fieldDefintion.enabled()).thenReturn(EnabledType.ENABLED);
    when(fieldDefintion.visible()).thenReturn(VisibleType.VISIBLE);
    ElementDescriptor fieldDescriptor = new ElementDescriptor(fieldDefintion, "value", Void.class, new ArrayList<>());
    // Precondition
    assertThat(field.isImmediate(), is(false));
    context.bind(pmo, fieldDescriptor, new LabelComponentWrapper(field));
    assertThat(field.isImmediate(), is(true));
}
Also used : BindingDefinition(org.linkki.core.ui.section.annotations.BindingDefinition) TextField(com.vaadin.ui.TextField) UITextField(org.linkki.core.ui.section.annotations.UITextField) ElementDescriptor(org.linkki.core.ui.section.descriptor.ElementDescriptor) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Test(org.junit.Test)

Example 2 with BindingDefinition

use of org.linkki.core.ui.section.annotations.BindingDefinition in project linkki by linkki-framework.

the class UIAnnotationReader method createAndAddDescriptor.

private void createAndAddDescriptor(Annotation annotation, Method method) {
    List<LinkkiAspectDefinition> aspectDefs = AspectAnnotationReader.createAspectDefinitionsFrom(annotation);
    String pmoPropertyName = getPmoPropertyName(method);
    PropertyElementDescriptors elementDescriptors = descriptorsByProperty.computeIfAbsent(pmoPropertyName, PropertyElementDescriptors::new);
    if (BindingDefinition.isLinkkiBindingDefinition(annotation)) {
        BindingDefinition uiElement = BindingDefinition.from(annotation);
        addDescriptor(elementDescriptors, uiElement, pmoPropertyName, annotation, aspectDefs);
    } else {
        elementDescriptors.addAspect(aspectDefs);
        if (annotation instanceof UITableColumn) {
            columnDescriptors.put(elementDescriptors, new TableColumnDescriptor(annotatedClass, method, (UITableColumn) annotation));
        }
    }
}
Also used : UITableColumn(org.linkki.core.ui.section.annotations.UITableColumn) BindingDefinition(org.linkki.core.ui.section.annotations.BindingDefinition) LinkkiAspectDefinition(org.linkki.core.binding.aspect.definition.LinkkiAspectDefinition) TableColumnDescriptor(org.linkki.core.ui.section.annotations.TableColumnDescriptor)

Aggregations

BindingDefinition (org.linkki.core.ui.section.annotations.BindingDefinition)2 TextField (com.vaadin.ui.TextField)1 Test (org.junit.Test)1 LinkkiAspectDefinition (org.linkki.core.binding.aspect.definition.LinkkiAspectDefinition)1 LabelComponentWrapper (org.linkki.core.ui.components.LabelComponentWrapper)1 TableColumnDescriptor (org.linkki.core.ui.section.annotations.TableColumnDescriptor)1 UITableColumn (org.linkki.core.ui.section.annotations.UITableColumn)1 UITextField (org.linkki.core.ui.section.annotations.UITextField)1 ElementDescriptor (org.linkki.core.ui.section.descriptor.ElementDescriptor)1