com.vaadin.flow.dom.Element.removeChild()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(368)

本文整理了Java中com.vaadin.flow.dom.Element.removeChild()方法的一些代码示例,展示了Element.removeChild()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeChild()方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:removeChild

Element.removeChild介绍

暂无

代码示例

代码示例来源:origin: com.vaadin/vaadin-accordion-flow

  1. /**
  2. * Removes a panel.
  3. *
  4. * @param panel the non-null panel to be removed
  5. */
  6. public void remove(AccordionPanel panel) {
  7. Objects.requireNonNull(panel, "The panel to be removed cannot be null");
  8. getElement().removeChild(panel.getElement());
  9. }

代码示例来源:origin: com.vaadin/vaadin-crud-flow

  1. /**
  2. * Sets the content of the toolbar.
  3. * Any content with the attribute `new-button` triggers a new item creation.
  4. *
  5. * @param components the content to be set
  6. */
  7. public void setToolbar(Component... components) {
  8. final Element[] existingToolbarElements = getElement().getChildren()
  9. .filter(e -> TOOLBAR_SLOT_NAME.equals(e.getAttribute(SLOT_KEY)))
  10. .toArray(Element[]::new);
  11. getElement().removeChild(existingToolbarElements);
  12. final Element[] newToolbarElements = Arrays.stream(components)
  13. .map(Component::getElement)
  14. .map(e -> e.setAttribute(SLOT_KEY, TOOLBAR_SLOT_NAME))
  15. .toArray(Element[]::new);
  16. getElement().appendChild(newToolbarElements);
  17. }

代码示例来源:origin: com.vaadin/vaadin-notification-flow

  1. /**
  2. * Remove the given components from this notification.
  3. *
  4. * @param components
  5. * the components to remove
  6. */
  7. @Override
  8. public void remove(Component... components) {
  9. for (Component component : components) {
  10. Objects.requireNonNull(component,
  11. "Component to remove cannot be null");
  12. if (container.equals(component.getElement().getParent())) {
  13. container.removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * the components to remove
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component
  8. */
  9. default void remove(Component... components) {
  10. Objects.requireNonNull(components, "Components should not be null");
  11. for (Component component : components) {
  12. Objects.requireNonNull(component,
  13. "Component to remove cannot be null");
  14. Element parent = component.getElement().getParent();
  15. if (parent == null) {
  16. LoggerFactory.getLogger(HasComponents.class).debug(
  17. "Remove of a component with no parent does nothing.");
  18. return;
  19. }
  20. if (getElement().equals(parent)) {
  21. getElement().removeChild(component.getElement());
  22. } else {
  23. throw new IllegalArgumentException("The given component ("
  24. + component + ") is not a child of this component");
  25. }
  26. }
  27. }

代码示例来源:origin: alejandro-du/crudui

  1. @Override
  2. public void hideForm() {
  3. formComponentLayout.removeAll();
  4. if (formCaptionLayout.getElement().getParent() != null) {
  5. secondComponent.getElement().removeChild(formCaptionLayout.getElement());
  6. }
  7. }

代码示例来源:origin: com.vaadin/vaadin-select-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-button-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-upload-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-split-layout-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-form-layout-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-date-picker-flow

  1. /**
  2. * Removes the given child components from this component.
  3. *
  4. * @param components
  5. * The components to remove.
  6. * @throws IllegalArgumentException
  7. * if any of the components is not a child of this component.
  8. */
  9. protected void remove(Component... components) {
  10. for (Component component : components) {
  11. if (getElement().equals(component.getElement().getParent())) {
  12. component.getElement().removeAttribute("slot");
  13. getElement().removeChild(component.getElement());
  14. } else {
  15. throw new IllegalArgumentException("The given component ("
  16. + component + ") is not a child of this component");
  17. }
  18. }
  19. }

代码示例来源:origin: com.vaadin/vaadin-button-flow

  1. private void wrapTextInSpan() {
  2. String text = getText();
  3. getElement().removeChild(getTextNodes());
  4. span = ElementFactory.createSpan(text);
  5. if (iconAfterText) {
  6. getElement().insertChild(0, span);
  7. } else {
  8. getElement().appendChild(span);
  9. }
  10. }

代码示例来源:origin: com.vaadin/flow-data

  1. @Override
  2. public void refreshData(T item) {
  3. String itemKey = getItemKey(item);
  4. Component oldComponent = getRenderedComponent(itemKey);
  5. if (oldComponent != null) {
  6. Component recreatedComponent = updateComponent(oldComponent, item);
  7. int oldId = oldComponent.getElement().getNode().getId();
  8. int newId = recreatedComponent.getElement().getNode().getId();
  9. if (oldId != newId && !oldComponent.equals(recreatedComponent)) {
  10. getContainer().removeChild(oldComponent.getElement());
  11. registerRenderedComponent(itemKey, recreatedComponent);
  12. }
  13. }
  14. }

代码示例来源:origin: alejandro-du/crudui

  1. @Override
  2. public void showForm(CrudOperation operation, Component form) {
  3. String caption = formCaptions.get(operation);
  4. if (caption != null) {
  5. Div label = new Div(new Text(caption));
  6. label.getStyle().set("color", "var(--lumo-primary-text-color)");
  7. formCaptionLayout.removeAll();
  8. formCaptionLayout.add(label);
  9. secondComponent.getElement().insertChild(secondComponent.getComponentCount() - 1, formCaptionLayout.getElement());
  10. } else if (formCaptionLayout.getElement().getParent() != null) {
  11. secondComponent.getElement().removeChild(formCaptionLayout.getElement());
  12. }
  13. formComponentLayout.removeAll();
  14. formComponentLayout.add(form);
  15. }

代码示例来源:origin: com.vaadin/vaadin-button-flow

  1. getElement().removeChild(span);
  2. span = null;

相关文章