Search in sources :

Example 56 with Component

use of com.vaadin.flow.component.Component in project flow by vaadin.

the class GeneratedVaadinUpload method addToDropLabelIcon.

/**
 * Adds the given components as children of this component at the slot
 * 'drop-label-icon'.
 *
 * @param components
 *            The components to add.
 * @see <a
 *      href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot">MDN
 *      page about slots</a>
 * @see <a
 *      href="https://html.spec.whatwg.org/multipage/scripting.html#the-slot-element">Spec
 *      website about slots</a>
 */
protected void addToDropLabelIcon(Component... components) {
    for (Component component : components) {
        component.getElement().setAttribute("slot", "drop-label-icon");
        getElement().appendChild(component.getElement());
    }
}
Also used : Component(com.vaadin.flow.component.Component)

Example 57 with Component

use of com.vaadin.flow.component.Component in project flow by vaadin.

the class HasItemsAndComponents method addComponents.

/**
 * Adds the components after the given item.
 *
 * @param afterItem
 *            item to add components after
 * @param components
 *            components to add after item
 * @throws IllegalArgumentException
 *             if this component doesn't contain the item
 */
default void addComponents(T afterItem, Component... components) {
    int insertPosition = getItemPosition(afterItem);
    if (insertPosition == -1) {
        throw new IllegalArgumentException("Could not locate the item after which to insert components.");
    }
    for (Component component : components) {
        insertPosition++;
        getElement().insertChild(insertPosition, component.getElement());
    }
}
Also used : Component(com.vaadin.flow.component.Component)

Example 58 with Component

use of com.vaadin.flow.component.Component in project flow by vaadin.

the class HasItemsAndComponents method prependComponents.

/**
 * Adds the components before the given item.
 *
 * @param beforeItem
 *            item to add components in front of
 * @param components
 *            components to add before item
 * @throws IllegalArgumentException
 *             if this component doesn't contain the item
 */
default void prependComponents(T beforeItem, Component... components) {
    int insertPosition = getItemPosition(beforeItem);
    if (insertPosition == -1) {
        throw new IllegalArgumentException("Could not locate the item before which to insert components.");
    }
    for (Component component : components) {
        getElement().insertChild(insertPosition, component.getElement());
        insertPosition++;
    }
}
Also used : Component(com.vaadin.flow.component.Component)

Example 59 with Component

use of com.vaadin.flow.component.Component in project flow by vaadin.

the class AbstractComponentDataGenerator method destroyData.

@Override
public void destroyData(T item) {
    String itemKey = getItemKey(item);
    Component renderedComponent = renderedComponents.remove(itemKey);
    if (renderedComponent != null) {
        renderedComponent.getElement().removeFromParent();
    }
}
Also used : Component(com.vaadin.flow.component.Component)

Example 60 with Component

use of com.vaadin.flow.component.Component in project flow by vaadin.

the class SerializationTest method testViewsSerializable.

@Test
public void testViewsSerializable() throws Exception {
    UI ui = new UI();
    UI.setCurrent(ui);
    try {
        Collection<Class<? extends Component>> viewClasses = new ViewClassLocator(getClass().getClassLoader()).getAllViewClasses();
        for (Class<? extends Component> viewClass : viewClasses) {
            Component view = viewClass.newInstance();
            // Collections.emptyList(), Collections.emptyMap()));
            try {
                Assert.assertNotNull(serializeDeserialize(view));
            } catch (Exception e) {
                throw new AssertionError("Can't serialize view " + viewClass.getName(), e);
            }
        }
    } finally {
        UI.setCurrent(null);
    }
}
Also used : UI(com.vaadin.flow.component.UI) Component(com.vaadin.flow.component.Component) ViewClassLocator(com.vaadin.flow.uitest.servlet.ViewClassLocator) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Component (com.vaadin.flow.component.Component)66 Test (org.junit.Test)9 Element (com.vaadin.flow.dom.Element)7 UI (com.vaadin.flow.component.UI)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 HasElement (com.vaadin.flow.component.HasElement)2 NativeButton (com.vaadin.flow.component.html.NativeButton)2 VirtualChildrenList (com.vaadin.flow.internal.nodefeature.VirtualChildrenList)2 AfterNavigationEvent (com.vaadin.flow.router.AfterNavigationEvent)2 BeforeEnterEvent (com.vaadin.flow.router.BeforeEnterEvent)2 BeforeLeaveEvent (com.vaadin.flow.router.BeforeLeaveEvent)2 ContinueNavigationAction (com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction)2 Location (com.vaadin.flow.router.Location)2 LocationChangeEvent (com.vaadin.flow.router.LocationChangeEvent)2 NavigationEvent (com.vaadin.flow.router.NavigationEvent)2 RouterLayout (com.vaadin.flow.router.RouterLayout)2 ErrorStateRenderer (com.vaadin.flow.router.internal.ErrorStateRenderer)2 ViewClassLocator (com.vaadin.flow.uitest.servlet.ViewClassLocator)2 Optional (java.util.Optional)2