com.vaadin.flow.dom.Element类的使用及代码示例

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

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

Element介绍

[英]A class representing an element in the DOM.

Contains methods for updating and querying various parts of the element, such as attributes.
[中]表示DOM中元素的类。
包含更新和查询元素各个部分(如属性)的方法。

代码示例

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

/**
 * Selects a tab based on its zero-based index.
 *
 * @param selectedIndex
 *            the zero-based index of the selected tab, -1 to unselect all
 */
public void setSelectedIndex(int selectedIndex) {
  getElement().setProperty(SELECTED, selectedIndex);
}

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

/**
 * Gets the value of the given property as a string.
 *
 * @param name
 *            the property name, not <code>null</code>
 * @return the property value, or <code>null</code> if no value is set
 */
public String getProperty(String name) {
  return getProperty(name, null);
}

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

private void setTextContent(String textContent) {
  Element child;
  if (getChildCount() == 1 && getChild(0).isTextNode()) {
    child = getChild(0).setText(textContent);
  } else {
    child = createText(textContent);
  }
  removeAllChildren();
  appendChild(child);
}

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

/**
 * Creates an {@code &lt;input>} element with the given type.
 *
 * @param type
 *            the type attribute for the element
 * @return an {@code &lt;input>} element
 */
static Element createInput(String type) {
  return new Element(Tag.INPUT).setAttribute("type", type);
}

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

private void appendTextContent(StringBuilder builder,
    Predicate<? super Element> childFilter) {
  if (isTextNode()) {
    builder.append(getText());
  } else {
    getChildren().filter(childFilter)
        .forEach(e -> e.appendTextContent(builder, childFilter));
  }
}

代码示例来源:origin: com.vaadin/flow-component-demo-helpers

private void addSourceCodeBlock(String text, String className) {
    Element pre = new Element("pre");
    Element code = new Element("code");
    pre.appendChild(code);
    code.setAttribute("spellcheck", "false");
    code.getClassList().add(className);
    code.setText(text);
    getElement().appendChild(pre);
  }
}

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

/**
   * Removes all contents from this component, this includes child components,
   * text content as well as child elements that have been added directly to
   * this component using the {@link Element} API.
   */
  protected void removeAll() {
    getElement().getChildren()
        .forEach(child -> child.removeAttribute("slot"));
    getElement().removeAllChildren();
  }
}

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

/**
 * <p>
 * Description copied from corresponding location in WebComponent:
 * </p>
 * <p>
 * Opens the dropdown.
 * </p>
 */
protected void open() {
  getElement().callFunction("open");
}

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

public AppMenuItem() {
  getElement().getClassList().add("app-menu-item");
  getElement().setAttribute("href", "javascript:void(0)");
  getElement().getStyle().set("position", "relative")
      .set("padding", "var(--app-layout-menu-button-padding)")
      .set("margin", "var(--app-layout-menu-button-margin)")
      .set("border-radius", "var(--app-layout-menu-button-border-radius)")
      .set("--lumo-primary-text-color", "var(--app-layout-app-color)")
      .set("text-decoration", "none");
  getElement().appendChild(new PaperRipple().getElement());
}

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

/**
 * Sets the element into branding area
 *
 * @param branding {@link Element} to set into branding area
 */
public void setBranding(Element branding) {
  Objects.requireNonNull(branding, "Branding cannot be null");
  removeBranding();
  this.branding = branding;
  branding.setAttribute("slot", "branding");
  getElement().appendChild(branding);
}

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

VaadinItem(String key, T item) {
  this.item = item;
  getElement().setProperty("value", key);
  getElement().setAttribute("value", key);
}

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

@Override
  public void accept(UI ui) {
    if (this == deferredJob) {
      String appId = ui.getInternals().getAppId();
      int nodeId = container.getNode().getId();
      String template = String.format(
          "<flow-component-renderer appid=\"%s\" nodeid=\"%s\"></flow-component-renderer>",
          appId, nodeId);
      templateElement.setProperty("innerHTML", template);
    }
  }
}

代码示例来源:origin: com.vaadin/flow-component-demo-helpers

/**
 * Default constructor. Creates an empty navigation bar.
 */
public DemoNavigationBar() {
  getElement().appendChild(list);
}

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

private void registerValidation() {
  if (validationRegistration != null) {
    validationRegistration.remove();
  }
  validationRegistration = getElement().addPropertyChangeListener(VALUE,
      validationListener);
}

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

/**
 * Creates a new empty router link.
 */
public RouterLink() {
  getElement()
      .setAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE, "");
}

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

@Override
public void removeChild(StateNode node, Element child) {
  ElementChildrenList childrenFeature = getChildrenFeature(node);
  int pos = childrenFeature.indexOf(child.getNode());
  if (pos == -1) {
    throw new IllegalArgumentException("Not in the list");
  }
  childrenFeature.remove(pos);
}

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

private void updateThemeAttribute() {
  if (themes.isEmpty()) {
    element.removeAttribute(THEME_ATTRIBUTE_NAME);
  } else {
    element.setAttribute(THEME_ATTRIBUTE_NAME, themes.stream()
        .collect(Collectors.joining(THEME_NAMES_DELIMITER)));
  }
}

相关文章

微信公众号

最新文章

更多