Search in sources :

Example 1 with ButtonPmo

use of org.linkki.core.ButtonPmo 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 2 with ButtonPmo

use of org.linkki.core.ButtonPmo 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 3 with ButtonPmo

use of org.linkki.core.ButtonPmo in project linkki by linkki-framework.

the class AbstractSection method createOpenCloseButton.

private void createOpenCloseButton() {
    ButtonPmo buttonPmo = ButtonPmo.Builder.action(this::switchOpenStatus).icon(FontAwesome.ANGLE_DOWN).get();
    openCloseButton = ComponentFactory.newButton(buttonPmo.getButtonIcon(), buttonPmo.getStyleNames());
    openCloseButton.addClickListener(e -> buttonPmo.onClick());
    if (header != null) {
        header.addComponent(openCloseButton);
    }
}
Also used : ButtonPmo(org.linkki.core.ButtonPmo)

Example 4 with ButtonPmo

use of org.linkki.core.ButtonPmo in project linkki by linkki-framework.

the class PmoBasedTableSectionFactory method createSection.

/**
 * Creates a new section showing a table, table structure and content is defined by the
 * factory's {@link ContainerPmo}.
 */
public TableSection<T> createSection() {
    Table table = createTable();
    Optional<ButtonPmo> addItemPmo = containerPmo.getAddItemButtonPmo();
    TableSection<T> section = createEmptySection(addItemPmo);
    section.setTable(table);
    return section;
}
Also used : ButtonPmo(org.linkki.core.ButtonPmo) Table(com.vaadin.ui.Table)

Aggregations

ButtonPmo (org.linkki.core.ButtonPmo)4 Test (org.junit.Test)2 PropertyDispatcher (org.linkki.core.binding.dispatcher.PropertyDispatcher)2 ReflectionPropertyDispatcher (org.linkki.core.binding.dispatcher.ReflectionPropertyDispatcher)2 Table (com.vaadin.ui.Table)1