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());
}
}
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());
}
}
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++;
}
}
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();
}
}
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);
}
}
Aggregations