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

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

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

Element.insertChild介绍

暂无

代码示例

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

/**
 * Adds the given component as child of this component at the specific
 * index.
 *
 * @param index
 *            the index, where the component will be added. The index must
 *            be non-negative and may not exceed the children count
 * @param component
 *            the component to add, value should not be null
 */
default void addComponentAtIndex(int index, Component component) {
  Objects.requireNonNull(component, "Component should not be null");
  if (index < 0) {
    throw new IllegalArgumentException(
        "Cannot add a component with a negative index");
  }
  // The case when the index is bigger than the children count is handled
  // inside the method below
  getElement().insertChild(index, component.getElement());
}

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

/**
 * Adds the given component into this notification at the given index.
 * <p>
 * The element in the DOM will not be child of the
 * {@code <vaadin-notification>} element, but will be inserted into an
 * overlay that is attached into the {@code <body>}.
 * <p>
 * NOTE: When mixing this method with {@link #Notification(String)},
 * {@link #Notification(String, int)} and
 * {@link #Notification(String, int, Position)} method will remove the text
 * content.
 *
 * @param index
 *            the index, where the component will be added.
 * @param component
 *            the component to add
 */
@Override
public void addComponentAtIndex(int index, Component component) {
  Objects.requireNonNull(component, "Component should not be null");
  if (index < 0) {
    throw new IllegalArgumentException(
        "Cannot add a component with a negative index");
  }
  // The case when the index is bigger than the children count is handled
  // inside the method below
  container.insertChild(index, component.getElement());
  attachComponentTemplate();
}

代码示例来源:origin: appreciated/vaadin-app-layout

public void setIconComponent(Component appBarIconComponent) {
  titleWrapper.getElement().insertChild(0, appBarIconComponent.getElement());
  titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
}

代码示例来源:origin: appreciated/vaadin-app-layout

public void setIconComponent(Component appBarIconComponent) {
  titleWrapper.getElement().insertChild(0, appBarIconComponent.getElement());
  titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
}

代码示例来源:origin: appreciated/vaadin-app-layout

public void setIconComponent(Component appBarIconComponent) {
  titleWrapper.getElement().insertChild(0, appBarIconComponent.getElement());
  titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
}

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

/**
 * Adds the components after the given item.
 *
 * @param afterItem
 *            item to add components after
 * @param components
 *            components to add after item
 * @throws IllegalArgumentException
 *             if this component doesn't contain the item
 */
default void addComponents(T afterItem, Component... components) {
  int insertPosition = getItemPosition(afterItem);
  if (insertPosition == -1) {
    throw new IllegalArgumentException(
        "Could not locate the item after which to insert components.");
  }
  for (Component component : components) {
    insertPosition++;
    getElement().insertChild(insertPosition, component.getElement());
  }
}

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

/**
 * Adds the components before the given item.
 *
 * @param beforeItem
 *            item to add components in front of
 * @param components
 *            components to add before item
 * @throws IllegalArgumentException
 *             if this component doesn't contain the item
 */
default void prependComponents(T beforeItem, Component... components) {
  int insertPosition = getItemPosition(beforeItem);
  if (insertPosition == -1) {
    throw new IllegalArgumentException(
        "Could not locate the item before which to insert components.");
  }
  for (Component component : components) {
    getElement().insertChild(insertPosition, component.getElement());
    insertPosition++;
  }
}

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

@Override
public void addToolbarComponent(Component component) {
  if (!firstComponentHeaderLayout.isVisible()) {
    firstComponentHeaderLayout.setVisible(true);
    firstComponent.getElement()
        .insertChild(firstComponent.getComponentCount() - 1, firstComponentHeaderLayout.getElement());
  }
  toolbarLayout.setVisible(true);
  toolbarLayout.add(component);
}

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

@Override
public void addToolbarComponent(Component component) {
  if (!secondComponentHeaderLayout.isVisible()) {
    secondComponentHeaderLayout.setVisible(true);
    secondComponent.getElement().insertChild(secondComponent.getComponentCount() - 1, secondComponentHeaderLayout.getElement());
  }
  toolbarLayout.setVisible(true);
  toolbarLayout.add(component);
}

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

@Override
public void addFilterComponent(Component component) {
  if (!firstComponentHeaderLayout.isVisible()) {
    firstComponentHeaderLayout.setVisible(true);
    firstComponent.getElement().insertChild(firstComponent.getComponentCount() - 1, firstComponentHeaderLayout.getElement());
  }
  filterLayout.setVisible(true);
  filterLayout.add(component);
}

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

@Override
public void addToolbarComponent(Component component) {
  if (!firstComponentHeaderLayout.isVisible()) {
    firstComponentHeaderLayout.setVisible(true);
    firstComponent.getElement().insertChild(firstComponent.getComponentCount() - 1, firstComponentHeaderLayout.getElement());
  }
  toolbarLayout.setVisible(true);
  toolbarLayout.add(component);
}

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

@Override
public void addFilterComponent(Component component) {
  if (!headerLayout.isVisible()) {
    headerLayout.setVisible(true);
    mainLayout.getElement().insertChild(mainLayout.getComponentCount() - 1, headerLayout.getElement());
  }
  filterLayout.setVisible(true);
  filterLayout.add(component);
}

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

@Override
public void addToolbarComponent(Component component) {
  if (!headerLayout.isVisible()) {
    headerLayout.setVisible(true);
    mainLayout.getElement().insertChild(mainLayout.getComponentCount() - 1, headerLayout.getElement());
  }
  toolbarLayout.setVisible(true);
  toolbarLayout.add(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/vaadin-button-flow

add(iconComponent);
} else {
  getElement().insertChild(0, iconComponent.getElement());

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

int newIndex = element.indexOfChild(newComponent.getElement());
if (oldIndex >= 0 && newIndex >= 0) {
  element.insertChild(oldIndex, newComponent.getElement());
  element.insertChild(newIndex, oldComponent.getElement());
} else if (oldIndex >= 0) {
  element.setChild(oldIndex, newComponent.getElement());

代码示例来源: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

span = ElementFactory.createSpan(text);
if (iconAfterText) {
  getElement().insertChild(0, span);
} else {
  getElement().appendChild(span);

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

add(iconComponent);
} else if (!iconAfterText && textIndex < iconIndex) {
  getElement().insertChild(0, iconComponent.getElement());

相关文章

微信公众号

最新文章

更多