本文整理了Java中com.vaadin.flow.dom.Element.removeFromParent()
方法的一些代码示例,展示了Element.removeFromParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeFromParent()
方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:removeFromParent
[英]Removes this element from its parent.
Has no effect if the element does not have a parent
[中]从其父元素中删除此元素。
如果元素没有父元素,则无效
代码示例来源:origin: com.vaadin/vaadin-app-layout-flow
private void remove(Element element) {
if (element != null) {
element.removeFromParent();
}
}
代码示例来源:origin: com.vaadin/flow-data
@Override
public void destroyAllData() {
renderedComponents.values().forEach(
component -> component.getElement().removeFromParent());
renderedComponents.clear();
}
代码示例来源:origin: com.vaadin/flow-server
private void removeFromParent(HasElement component) {
if (component != null) {
component.getElement().removeFromParent();
}
}
代码示例来源:origin: com.vaadin/flow-data
@Override
public void destroyData(T item) {
String itemKey = getItemKey(item);
Component renderedComponent = renderedComponents.remove(itemKey);
if (renderedComponent != null) {
renderedComponent.getElement().removeFromParent();
}
}
代码示例来源:origin: com.vaadin/vaadin-confirm-dialog-flow
/**
* Creates an empty dialog with a Confirm button
*/
public ConfirmDialog() {
getElement().addEventListener("opened-changed", event -> {
if (autoAddedToTheUi && !isOpened()) {
getElement().removeFromParent();
autoAddedToTheUi = false;
}
});
}
代码示例来源:origin: com.vaadin/flow-server
oldRoot.getElement().removeFromParent();
rootElement.removeFromParent();
uiElement.appendChild(rootElement);
代码示例来源:origin: com.vaadin/flow-server
child.removeFromParent();
getStateProvider().insertChild(node, insertIndex, child);
ensureChildHasParent(child, true);
代码示例来源:origin: com.vaadin/vaadin-notification-flow
private void initBaseElementsAndListeners() {
getElement().appendChild(templateElement);
getElement().appendVirtualChild(container);
getElement().addEventListener("opened-changed", event -> {
if (autoAddedToTheUi && !isOpened()) {
getElement().removeFromParent();
autoAddedToTheUi = false;
}
});
}
代码示例来源:origin: com.vaadin/vaadin-crud-flow
/**
* Sets the grid
*
* @param grid the grid
*/
public void setGrid(Grid<E> grid) {
Objects.requireNonNull(grid, "Grid cannot be null");
if (this.grid != null && this.grid.getElement().getParent() == getElement()) {
this.grid.getElement().removeFromParent();
}
this.grid = grid;
grid.getElement().setAttribute(SLOT_KEY, GRID_SLOT_NAME);
// It might already have a parent e.g when injected from a template
if (grid.getElement().getParent() == null) {
getElement().appendChild(grid.getElement());
}
}
代码示例来源:origin: com.vaadin/vaadin-crud-flow
/**
* Sets the editor.
* When injecting a {@link Crud} with {@literal @}Id this method must be called
* before the crud is put into use.
*
* @param editor the editor
*/
public void setEditor(CrudEditor<E> editor) {
Objects.requireNonNull(editor, "Editor cannot be null");
if (this.editor != null
&& this.editor.getView() != null
&& this.editor.getView().getElement().getParent() == getElement()) {
this.editor.getView().getElement().removeFromParent();
}
this.editor = editor;
// It might already have a parent e.g when injected from a template
if (editor.getView() != null && editor.getView().getElement().getParent() == null) {
editor.getView().getElement().setAttribute(SLOT_KEY, FORM_SLOT_NAME);
getElement().appendChild(editor.getView().getElement());
}
}
代码示例来源:origin: com.vaadin/vaadin-context-menu-flow
/**
* Creates an empty context menu.
*/
public ContextMenuBase() {
container = new Element("div");
getElement().appendVirtualChild(container);
// Workaround for: https://github.com/vaadin/flow/issues/3496
getElement().setProperty("opened", false);
// Don't open the overlay immediately with any event, let
// contextMenuConnector.js make a server round-trip first.
setOpenOn("none");
getElement().addEventListener("opened-changed", event -> {
if (autoAddedToTheUi && !isOpened()) {
getElement().removeFromParent();
autoAddedToTheUi = false;
}
});
addAttachListener(event -> resetContent());
}
代码示例来源:origin: com.vaadin/incubator-tooltip-flow
/**
* Assigns the tooltip to a specific component.
* <p>
* The tooltip is removed from the parent after the component that the tooltip is
* attached is detached.
*
* @param component the tooltip is attached to this component
* @param appended <code>true</code> the tooltip is automatically appended
* to the component's father.<code>false</code>,
* it is not appended. It should be added to a layout manually.
*/
public void attachToComponent(Component component, boolean appended) {
Objects.requireNonNull(component);
getElement().getNode().runWhenAttached(ui -> {
ui.getPage().executeJavaScript("$0.targetElement = $1;",
getElement(), component.getElement()
);
});
if ( appended ){
component.getElement().getNode().runWhenAttached(ui -> {
component.getElement().getParentNode().appendChild(getElement());
});
}
if ( detachedRegistration != null ){
detachedRegistration.remove();
}
detachedRegistration = component.addDetachListener(event -> {
this.getElement().removeFromParent();
});
}
内容来源于网络,如有侵权,请联系作者删除!