use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class Card method getSpacer.
private Element getSpacer() {
Element spacer = ElementFactory.createDiv();
spacer.getStyle().set("marginTop", "10px");
return spacer;
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class DataCommunicatorTest method init.
@Before
public void init() {
MockitoAnnotations.initMocks(this);
ui = new MockUI();
element = new Element("div");
ui.getElement().appendChild(element);
lastClear = null;
lastSet = null;
lastUpdateId = -1;
update = new ArrayUpdater.Update() {
@Override
public void clear(int start, int length) {
lastClear = Range.withLength(start, length);
}
@Override
public void set(int start, List<JsonValue> items) {
lastSet = Range.withLength(start, items.size());
}
@Override
public void commit(int updateId) {
lastUpdateId = updateId;
}
};
Mockito.when(arrayUpdater.startUpdate(Mockito.anyInt())).thenReturn(update);
dataCommunicator = new DataCommunicator<>(dataGenerator, arrayUpdater, data -> {
}, element.getNode());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class AbstractComponentDataGenerator method registerRenderedComponent.
/**
* Appends the component to the container and registers it for future use
* during the lifecycle of the generator.
*
* @param itemKey
* the key of the model item
* @param component
* the component to be attached to the container
*/
protected void registerRenderedComponent(String itemKey, Component component) {
Element element = component.getElement();
getContainer().appendChild(element);
renderedComponents.put(itemKey, component);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class BasicRenderer method getTemplatePropertyName.
/**
* Gets the name of the property to be transmitted and used inside the
* template. By default, it generates a unique name by using the class name
* of the renderer and the node id of the template element.
* <p>
* This method is only called when
* {@link #render(Element, DataKeyMapper, Element)} is invoked.
*
* @param context
* the rendering context
* @return the property name to be used in template data bindings
*
* @see Rendering#getTemplateElement()
*/
protected String getTemplatePropertyName(Rendering<SOURCE> context) {
Objects.requireNonNull(context, "The context should not be null");
Element templateElement = context.getTemplateElement();
if (templateElement == null) {
throw new IllegalArgumentException("The provided rendering doesn't contain a template element");
}
return "_" + getClass().getSimpleName() + "_" + templateElement.getNode().getId();
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class BasicRenderer method setupTemplateWhenAttached.
private void setupTemplateWhenAttached(Element owner, SimpleValueRendering rendering, DataKeyMapper<SOURCE> keyMapper) {
Element templateElement = rendering.getTemplateElement();
owner.appendChild(templateElement);
if (keyMapper != null) {
String propertyName = getTemplatePropertyName(rendering);
templateElement.setProperty("innerHTML", getTemplateForProperty("[[item." + propertyName + "]]", rendering));
rendering.setPropertyName(propertyName);
RendererUtil.registerEventHandlers(this, templateElement, owner, keyMapper::get);
} else {
String value = getFormattedValue(null);
templateElement.setProperty("innerHTML", getTemplateForProperty(value, rendering));
rendering.setContainer(owner);
}
}
Aggregations