本文整理了Java中com.vaadin.flow.dom.Element.removeChild()
方法的一些代码示例,展示了Element.removeChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeChild()
方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:removeChild
暂无
代码示例来源:origin: com.vaadin/vaadin-accordion-flow
/**
* Removes a panel.
*
* @param panel the non-null panel to be removed
*/
public void remove(AccordionPanel panel) {
Objects.requireNonNull(panel, "The panel to be removed cannot be null");
getElement().removeChild(panel.getElement());
}
代码示例来源:origin: com.vaadin/vaadin-crud-flow
/**
* Sets the content of the toolbar.
* Any content with the attribute `new-button` triggers a new item creation.
*
* @param components the content to be set
*/
public void setToolbar(Component... components) {
final Element[] existingToolbarElements = getElement().getChildren()
.filter(e -> TOOLBAR_SLOT_NAME.equals(e.getAttribute(SLOT_KEY)))
.toArray(Element[]::new);
getElement().removeChild(existingToolbarElements);
final Element[] newToolbarElements = Arrays.stream(components)
.map(Component::getElement)
.map(e -> e.setAttribute(SLOT_KEY, TOOLBAR_SLOT_NAME))
.toArray(Element[]::new);
getElement().appendChild(newToolbarElements);
}
代码示例来源:origin: com.vaadin/vaadin-notification-flow
/**
* Remove the given components from this notification.
*
* @param components
* the components to remove
*/
@Override
public void remove(Component... components) {
for (Component component : components) {
Objects.requireNonNull(component,
"Component to remove cannot be null");
if (container.equals(component.getElement().getParent())) {
container.removeChild(component.getElement());
} else {
throw new IllegalArgumentException("The given component ("
+ component + ") is not a child of this component");
}
}
}
代码示例来源:origin: com.vaadin/flow-server
/**
* 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
*/
default void remove(Component... components) {
Objects.requireNonNull(components, "Components should not be null");
for (Component component : components) {
Objects.requireNonNull(component,
"Component to remove cannot be null");
Element parent = component.getElement().getParent();
if (parent == null) {
LoggerFactory.getLogger(HasComponents.class).debug(
"Remove of a component with no parent does nothing.");
return;
}
if (getElement().equals(parent)) {
getElement().removeChild(component.getElement());
} else {
throw new IllegalArgumentException("The given component ("
+ component + ") is not a child of this component");
}
}
}
代码示例来源:origin: alejandro-du/crudui
@Override
public void hideForm() {
formComponentLayout.removeAll();
if (formCaptionLayout.getElement().getParent() != null) {
secondComponent.getElement().removeChild(formCaptionLayout.getElement());
}
}
代码示例来源:origin: com.vaadin/vaadin-select-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-button-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-text-field-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-upload-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-text-field-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-split-layout-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-form-layout-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-date-picker-flow
/**
* 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");
}
}
}
代码示例来源:origin: com.vaadin/vaadin-button-flow
private void wrapTextInSpan() {
String text = getText();
getElement().removeChild(getTextNodes());
span = ElementFactory.createSpan(text);
if (iconAfterText) {
getElement().insertChild(0, span);
} else {
getElement().appendChild(span);
}
}
代码示例来源:origin: com.vaadin/flow-data
@Override
public void refreshData(T item) {
String itemKey = getItemKey(item);
Component oldComponent = getRenderedComponent(itemKey);
if (oldComponent != null) {
Component recreatedComponent = updateComponent(oldComponent, 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);
}
}
}
代码示例来源:origin: alejandro-du/crudui
@Override
public void showForm(CrudOperation operation, Component form) {
String caption = formCaptions.get(operation);
if (caption != null) {
Div label = new Div(new Text(caption));
label.getStyle().set("color", "var(--lumo-primary-text-color)");
formCaptionLayout.removeAll();
formCaptionLayout.add(label);
secondComponent.getElement().insertChild(secondComponent.getComponentCount() - 1, formCaptionLayout.getElement());
} else if (formCaptionLayout.getElement().getParent() != null) {
secondComponent.getElement().removeChild(formCaptionLayout.getElement());
}
formComponentLayout.removeAll();
formComponentLayout.add(form);
}
代码示例来源:origin: com.vaadin/vaadin-button-flow
getElement().removeChild(span);
span = null;
内容来源于网络,如有侵权,请联系作者删除!