use of com.vaadin.flow.component.Component in project flow by vaadin.
the class GeneratedVaadinTextArea method addToSuffix.
/**
* Adds the given components as children of this component at the slot
* 'suffix'.
*
* @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 addToSuffix(Component... components) {
for (Component component : components) {
component.getElement().setAttribute("slot", "suffix");
getElement().appendChild(component.getElement());
}
}
use of com.vaadin.flow.component.Component in project flow by vaadin.
the class GeneratedVaadinUpload method addToDropLabel.
/**
* Adds the given components as children of this component at the slot
* 'drop-label'.
*
* @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 addToDropLabel(Component... components) {
for (Component component : components) {
component.getElement().setAttribute("slot", "drop-label");
getElement().appendChild(component.getElement());
}
}
use of com.vaadin.flow.component.Component in project flow by vaadin.
the class GeneratedVaadinUpload method remove.
/**
* Removes the given child components from this component.
*
* @param components
* The components to remove.
* @throws IllegalArgumentException
* if any of the components is not a child of this component.
*/
protected void remove(Component... components) {
for (Component component : components) {
if (getElement().equals(component.getElement().getParent())) {
component.getElement().removeAttribute("slot");
getElement().removeChild(component.getElement());
} else {
throw new IllegalArgumentException("The given component (" + component + ") is not a child of this component");
}
}
}
use of com.vaadin.flow.component.Component in project flow by vaadin.
the class AbstractComponentDataGenerator method refreshData.
@Override
public void refreshData(T item) {
String itemKey = getItemKey(item);
Component oldComponent = getRenderedComponent(itemKey);
if (oldComponent != null) {
Component recreatedComponent = createComponent(item);
int oldId = oldComponent.getElement().getNode().getId();
int newId = recreatedComponent.getElement().getNode().getId();
if (oldId != newId && !oldComponent.equals(recreatedComponent)) {
getContainer().removeChild(oldComponent.getElement());
registerRenderedComponent(itemKey, recreatedComponent);
}
}
}
use of com.vaadin.flow.component.Component in project flow by vaadin.
the class ComponentDataGenerator method generateData.
@Override
public void generateData(T item, JsonObject jsonObject) {
// if no nodeIdProperty set do nothing.
if (nodeIdPropertyName == null) {
return;
}
String itemKey = getItemKey(item);
Component oldRenderedComponent = getRenderedComponent(itemKey);
int nodeId;
// component and register it.
if (oldRenderedComponent != null) {
nodeId = oldRenderedComponent.getElement().getNode().getId();
} else {
Component renderedComponent = createComponent(item);
registerRenderedComponent(itemKey, renderedComponent);
nodeId = renderedComponent.getElement().getNode().getId();
}
jsonObject.put(nodeIdPropertyName, nodeId);
}
Aggregations