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

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

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

Element.getClassList介绍

[英]Gets the set of CSS class names used for this element. The returned set can be modified to add or remove class names. The contents of the set is also reflected in the value of the class attribute.

Despite the name implying a list being returned, the return type is actually a Set since the in-browser return value behaves like a Set in Java.
[中]获取用于此元素的CSS类名集。可以修改返回的集合以添加或删除类名。集合的内容也反映在class属性的值中。
尽管名称暗示返回列表,但返回类型实际上是一个集合,因为浏览器中的返回值在Java中的行为类似于Set

代码示例

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

@Override
public String getAttribute(Element element) {
  Set<String> classList = element.getClassList();
  if (classList.isEmpty()) {
    return null;
  } else {
    return classList.stream().collect(Collectors.joining(" "));
  }
}

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

@Override
public void setAttribute(Element element, String value) {
  Set<String> classList = element.getClassList();
  classList.clear();
  if (value.isEmpty()) {
    return;
  }
  String[] parts = value.split("\\s+");
  classList.addAll(Arrays.asList(parts));
}

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

@Override
  public void removeAttribute(Element element) {
    element.getClassList().clear();
  }
}

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

@Override
public boolean hasAttribute(Element element) {
  return !element.getClassList().isEmpty();
}

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

/**
 * Gets the set of CSS class names used for this element. The returned set
 * can be modified to add or remove class names. The contents of the set is
 * also reflected in the value of the <code>class</code> attribute.
 * <p>
 * Despite the name implying a list being returned, the return type is
 * actually a {@link Set} since the in-browser return value behaves like a
 * <code>Set</code> in Java.
 *
 * @see Element#getClassList()
 *
 * @return a list of class names, never <code>null</code>
 */
default ClassList getClassNames() {
  return getElement().getClassList();
}

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

/**
 * Default constructor for the component.
 */
public SourceContent() {
  getElement().getClassList().add("sources");
}

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

@Override
public void setBackNavigation(boolean visible) {
  appBarElements.getElement().getClassList().set("show-back-arrow", visible);
  paperIconButton.getElement().getClassList().set("show-back-arrow", visible);
}

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

public LeftHybridSmall() {
  layout.getElement().getClassList().add("small");
  this.getElement().getClassList().add("small");
}

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

@Override
public void add(Component... components) {
  if (content == null) {
    content = new Div();
    content.getElement().getClassList().add("card-content");
    getElement().appendChild(content.getElement());
  }
  content.add(components);
}

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

public void addAction(Component... components) {
  if (actions == null) {
    actions = new Div();
    actions.getElement().getClassList().add("card-actions");
    getElement().appendChild(actions.getElement());
  }
  actions.add(components);
}

代码示例来源: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: 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.holon-platform.vaadin/holon-vaadin-flow

/**
 * Constructor.
 */
public DefaultDialog() {
  super();
  // default CSS style class name
  getElement().getClassList().add("h-dialog");
  this.message = new Div();
  this.message.addClassName("message");
  this.toolbar = new HorizontalLayout();
  this.toolbar.addClassName("toolbar");
  this.toolbar.setAlignItems(Alignment.END);
  this.content = new VerticalLayout();
  this.content.setPadding(false);
  this.content.setSpacing(true);
  this.content.add(message);
  this.content.add(this.toolbar);
  this.content.setAlignSelf(Alignment.CENTER, this.message);
  this.content.setAlignSelf(Alignment.END, this.toolbar);
  this.message.setVisible(false);
  this.toolbar.setVisible(false);
  add(content);
}

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

Top() {
  contentPanel.setSizeFull();
  getElement().getClassList().addAll(Arrays.asList("app-layout-behaviour-" + getStyleName(), "app-layout"));
  appBar.add(titleWrapper, paperTabWrapper, appBarElementWrapper);
  paperTabWrapper.setFlexGrow(1.0, titleWrapper);
  paperTabWrapper.setWidth("100%");
  paperTabWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
  appBar.setWidth("100%");
  appBar.setHeight("100%");
  appBarElements = new Div();
  appBarElements.setHeight("100%");
  appBarElements.getElement().setAttribute("slot", "app-bar-content");
  content = new Div();
  content.setHeight("100%");
  content.setWidth("100%");
  content.getElement().setAttribute("slot", "application-content");
  appBarElements.add(appBar);
  appBarElementWrapper.setSpacing(false);
  appBarElementWrapper.add(appBarElementContainer);
  appBarElementContainer.setHeight("100%");
  appBarElementWrapper.setAlignItems(FlexComponent.Alignment.START);
  titleWrapper.setHeight("100%");
  titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
  getElement().appendChild(appBarElements.getElement(), content.getElement());
}

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

public void initView() {
 VerticalLayout content = getContent();
 content.removeAll();
 if (holder.getNotificationSize() > 0) {
  content.add(this.holder.getNotificationViews(showAll));
  getElement().getClassList().add(Styles.APP_BAR_NOTIFICATION_LIST);
  if (! showAll && this.holder.getNotificationSize() > 4) {
   showAllButton = new Button(showAllText);
   showAllButton.setWidth("100%");
   showAllButton.setHeight("28px");
   showAllButton.addClickListener(clickEvent -> showAllCommand.execute());
   content.add(showAllButton);
  }
 } else {
  noNotificationsLabel = new Label(noNotificationText);
  noNotificationsLabel.getStyle().set("color" , "var(--lumo-shade)")
            .set("font-size" , "var(--lumo-size-xxs)");
  HorizontalLayout wrapper = new HorizontalLayout(noNotificationsLabel);
  wrapper.setWidth("100%");
  wrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
  PaperCard card = new PaperCard(wrapper);
  card.setWidth("100%");
  card.getElement().getStyle().set("box-shadow" , "var(--app-layout-notification-shadow)");
  content.add(card);
 }
}

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

AbstractLeftAppLayoutBase() {
  getStyle().set("width", "100%")
      .set("height", "100%");
  getClassNames().addAll(asList("app-layout-behaviour-" + getStyleName(), Styles.APP_LAYOUT));
  HorizontalLayout appBarContentHolder = new HorizontalLayout(titleWrapper, appBarElementWrapper);
  appBarContentHolder.setSizeFull();
  appBarContentHolder.setSpacing(false);
  appBarContentHolder.getElement().setAttribute("slot", "app-bar-content");
  appBarElementWrapper.setSpacing(false);
  appBarElementWrapper.getStyle().set("flex", "1 1");
  appBarElementWrapper.add(appBarElementContainer);
  appBarElementContainer.setHeight("100%");
  appBarElementWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
  menuElements = new Div();
  menuElements.setHeight("100%");
  menuElements.getElement().setAttribute("slot", "drawer-content");
  content = new Div();
  content.setHeight("100%");
  content.setWidth("100%");
  content.getElement().setAttribute("slot", "application-content");
  titleWrapper.setHeight("100%");
  titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
  titleWrapper.setPadding(false);
  titleWrapper.setMargin(false);
  titleWrapper.getElement().getStyle().set("flex", "1 1 100px").set("overflow", "hidden");
  titleWrapper.setWidth("0px");
  getElement().getClassList().add("app-layout");
  getElement().appendChild(appBarContentHolder.getElement(), menuElements.getElement(), content.getElement());
}

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

paperTabWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
getElement().getClassList().addAll(Arrays.asList("app-layout-behaviour-" + getStyleName(), "app-layout"));
appBar.add(titleWrapper, appBarElementWrapper);
appBar.setFlexGrow(1.0, titleWrapper);

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

getElement().addEventListener("click", clickEvent);
getElement().getClassList().add(info.getStyle());
if (clickEvent != null) {
  add(new PaperRipple());

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

add(descriptionWrapper);
getContent().getStyle().set("background", "var(--app-layout-notification-background-color)");
getElement().getClassList().add(info.getStyle());
setNotificationListener(listener);

相关文章