com.google.gwt.user.client.Element.hasClassName()方法的使用及代码示例

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

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

Element.hasClassName介绍

暂无

代码示例

代码示例来源:origin: GwtMaterialDesign/gwt-material

protected void fireCollapsibleHandler() {
  if (getElement().hasClassName(CssName.ACTIVE)) {
    parent.fireEvent(new CollapseEvent<>(this));
  } else {
    parent.fireEvent(new ExpandEvent<>(this));
  }
}

代码示例来源:origin: com.github.gwtmaterialdesign/gwt-material

protected void fireCollapsibleHandler() {
  if (getElement().hasClassName(CssName.ACTIVE)) {
    parent.fireEvent(new CollapseEvent<>(this));
  } else {
    parent.fireEvent(new ExpandEvent<>(this));
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testType() {
  MaterialCollectionItem item = new MaterialCollectionItem();
  item.setType(CollectionType.CHECKBOX);
  assertTrue(item.getElement().hasClassName(CollectionType.CHECKBOX.getCssName()));
  item.setType(CollectionType.AVATAR);
  assertFalse(item.getElement().hasClassName(CollectionType.CHECKBOX.getCssName()));
  assertTrue(item.getElement().hasClassName(CollectionType.AVATAR.getCssName()));
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testPositions() {
  // given
  MaterialNavSection navSection = getWidget();
  // when / then
  navSection.setPosition(Position.LEFT);
  assertTrue(navSection.getElement().hasClassName(Position.LEFT.getCssName()));
  navSection.setPosition(Position.RIGHT);
  assertTrue(navSection.getElement().hasClassName(Position.RIGHT.getCssName()));
  assertFalse(navSection.getElement().hasClassName(Position.LEFT.getCssName()));
}

代码示例来源:origin: com.github.gwtmaterialdesign/gwt-material

public void testPositions() {
  // given
  MaterialNavSection navSection = getWidget();
  // when / then
  navSection.setPosition(Position.LEFT);
  assertTrue(navSection.getElement().hasClassName(Position.LEFT.getCssName()));
  navSection.setPosition(Position.RIGHT);
  assertTrue(navSection.getElement().hasClassName(Position.RIGHT.getCssName()));
  assertFalse(navSection.getElement().hasClassName(Position.LEFT.getCssName()));
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testPositions() {
    // given
    MaterialNavBrand navBrand = getWidget();

    // when / then
    navBrand.setPosition(Position.RIGHT);
    assertTrue(navBrand.getElement().hasClassName(Position.RIGHT.getCssName()));
    navBrand.setPosition(Position.LEFT);
    assertTrue(navBrand.getElement().hasClassName(Position.LEFT.getCssName()));
  }
}

代码示例来源:origin: com.github.gwtmaterialdesign/gwt-material

public void testPositions() {
    // given
    MaterialNavBrand navBrand = getWidget();

    // when / then
    navBrand.setPosition(Position.RIGHT);
    assertTrue(navBrand.getElement().hasClassName(Position.RIGHT.getCssName()));
    navBrand.setPosition(Position.LEFT);
    assertTrue(navBrand.getElement().hasClassName(Position.LEFT.getCssName()));
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

protected void checkClear(MaterialDatePicker picker) {
  picker.setValue(DATE);
  picker.setErrorText("error");
  picker.clear();
  assertEquals("", picker.getDateInput().getElement().getInnerText());
  assertFalse(picker.getLabel().getElement().hasClassName(CssName.ACTIVE));
  assertFalse(picker.getDateInput().getElement().hasClassName(CssName.VALID));
  assertFalse(picker.getDateInput().getElement().hasClassName(CssName.INVALID));
  assertFalse(picker.getErrorLabel().getElement().hasClassName(CssName.FIELD_ERROR_LABEL));
  assertFalse(picker.getDateInput().getElement().hasClassName(CssName.FIELD_ERROR));
  assertNull(picker.getValue());
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testContainer() {
    // given
    MaterialPanel panel = getWidget();

    // when / then
    panel.setContainerEnabled(true);
    assertTrue(panel.isContainerEnabed());
    assertTrue(panel.getElement().hasClassName(CssName.CONTAINER));

    panel.setContainerEnabled(false);
    assertFalse(panel.isContainerEnabed());
    assertFalse(panel.getElement().hasClassName(CssName.CONTAINER));
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testDismissible() {
  MaterialCollectionItem item = new MaterialCollectionItem();
  item.setDismissible(true);
  assertTrue(item.isDismissible());
  assertTrue(item.getElement().hasClassName(CssName.DISMISSABLE));
  item.setDismissible(false);
  assertFalse(item.isDismissible());
  assertFalse(item.getElement().hasClassName(CssName.DISMISSABLE));
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

protected void checkSpinner(MaterialSpinner spinner) {
    spinner.setColor(SpinnerColor.YELLOW_ONLY);
    assertEquals(SpinnerColor.YELLOW_ONLY, spinner.getColor());
    assertTrue(spinner.getElement().hasClassName(SpinnerColor.YELLOW_ONLY.getCssName()));
    spinner.setColor(SpinnerColor.YELLOW);
    assertEquals(SpinnerColor.YELLOW, spinner.getColor());
    assertTrue(spinner.getElement().hasClassName(SpinnerColor.YELLOW.getCssName()));
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testStructure() {
  // given
  MaterialTextArea textArea = getWidget();
  // when / then
  assertTrue(textArea.getValueBoxBase().getElement().hasClassName(CssName.MATERIALIZE_TEXTAREA));
  assertEquals(InputType.TEXT, textArea.getType());
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

protected void checkInitialClasses(String... initialClasses) {
  // given
  MaterialWidget widget = getWidget();
  // when / then
  if (widget.getInitialClasses() != null) {
    for (int i = 0; i < initialClasses.length; i++) {
      assertTrue(widget.getElement().hasClassName(initialClasses[i]));
    }
    assertNotNull(widget.getInitialClasses());
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

protected void checkBrowserDefault(MaterialListValueBox listValueBox, boolean checkElement) {
  listValueBox.setOld(true);
  assertTrue(listValueBox.isOld());
  if (checkElement) {
    assertTrue(listValueBox.getListBox().getElement().hasClassName("browser-default"));
  }
  listValueBox.setOld(false);
  assertFalse(listValueBox.isOld());
  if (checkElement) {
    assertFalse(listValueBox.getListBox().getElement().hasClassName("browser-default"));
  }
}

代码示例来源:origin: com.github.gwtmaterialdesign/gwt-material

protected void checkSpinner(MaterialSpinner spinner) {
    spinner.setColor(SpinnerColor.YELLOW_ONLY);
    assertEquals(SpinnerColor.YELLOW_ONLY, spinner.getColor());
    assertTrue(spinner.getElement().hasClassName(SpinnerColor.YELLOW_ONLY.getCssName()));
    spinner.setColor(SpinnerColor.YELLOW);
    assertEquals(SpinnerColor.YELLOW, spinner.getColor());
    assertTrue(spinner.getElement().hasClassName(SpinnerColor.YELLOW.getCssName()));
  }
}

代码示例来源:origin: com.github.gwtmaterialdesign/gwt-material-addins

public void testTypes() {
  // given
  MaterialCarousel carousel = getWidget();
  // when / then
  carousel.setType(CarouselType.IMAGE);
  assertEquals(CarouselType.IMAGE, carousel.getType());
  assertTrue(carousel.getElement().hasClassName(CarouselType.IMAGE.getCssName()));
  // when / then
  carousel.setType(CarouselType.ONBOARD);
  assertEquals(CarouselType.ONBOARD, carousel.getType());
  assertTrue(carousel.getElement().hasClassName(CarouselType.ONBOARD.getCssName()));
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testWithHeader() {
    MaterialSideNavPush sideNavPush = getWidget();

    sideNavPush.setWithHeader(true);
    sideNavPush.reload();
    assertTrue(sideNavPush.isWithHeader());
    assertTrue(sideNavPush.getElement().hasClassName(SideNavType.PUSH_WITH_HEADER.getCssName()));

    sideNavPush.setWithHeader(false);
    sideNavPush.reload();
    assertFalse(sideNavPush.isWithHeader());
    assertFalse(sideNavPush.getElement().hasClassName(SideNavType.PUSH_WITH_HEADER.getCssName()));
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testWithHeader() {
    MaterialSideNavDrawer sideNavPush = getWidget();

    sideNavPush.setWithHeader(true);
    sideNavPush.reload();
    assertTrue(sideNavPush.isWithHeader());
    assertTrue(sideNavPush.getElement().hasClassName(SideNavType.DRAWER_WITH_HEADER.getCssName()));

    sideNavPush.setWithHeader(false);
    sideNavPush.reload();
    assertFalse(sideNavPush.isWithHeader());
    assertFalse(sideNavPush.getElement().hasClassName(SideNavType.DRAWER_WITH_HEADER.getCssName()));
  }
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testTypes() {
  // given
  MaterialFAB fab = getWidget();
  // when / then
  fab.setType(FABType.CLICK_ONLY);
  assertEquals(FABType.CLICK_ONLY, fab.getType());
  assertTrue(fab.getElement().hasClassName(FABType.CLICK_ONLY.getCssName()));
  fab.setType(FABType.HOVER);
  assertEquals(FABType.HOVER, fab.getType());
  // Because Hover is empty by default
  assertTrue(fab.getType().getCssName().isEmpty());
}

代码示例来源:origin: GwtMaterialDesign/gwt-material

public void testTypes() {
  // given
  MaterialTab tab = getWidget();
  // when / then
  tab.setType(TabType.DEFAULT);
  assertEquals(TabType.DEFAULT, tab.getType());
  assertTrue(tab.getElement().getClassName().contains(TabType.DEFAULT.getCssName()));
  tab.setType(TabType.ICON);
  assertEquals(TabType.ICON, tab.getType());
  assertTrue(tab.getElement().hasClassName(TabType.ICON.getCssName()));
}

相关文章

Element类方法