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

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

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

Element.hasClassName介绍

[英]Checks if this element's class property contains specified class name.
[中]检查此元素的类属性是否包含指定的类名。

代码示例

代码示例来源:origin: org.uberfire/uberfire-preferences-ui-client

  1. @Override
  2. public void select() {
  3. if (!label.hasClassName("selected")) {
  4. presenter.select();
  5. }
  6. }

代码示例来源:origin: org.uberfire/uberfire-preferences-ui-client

  1. @Override
  2. public void select() {
  3. if (!label.hasClassName("selected")) {
  4. presenter.select();
  5. }
  6. }

代码示例来源:origin: kiegroup/appformer

  1. @Override
  2. public void select() {
  3. if (!label.hasClassName("selected")) {
  4. presenter.select();
  5. }
  6. }

代码示例来源:origin: kiegroup/appformer

  1. @Override
  2. public void select() {
  3. if (!label.hasClassName("selected")) {
  4. presenter.select();
  5. }
  6. }

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

  1. private void clearThumbnail(Element thumbnail) {
  2. if (!thumbnail.hasClassName(THUMBNAIL_PLACEHOLDER_STYLE_NAME)) {
  3. flyweight.clear(thumbnail);
  4. floatingThumbnails.push(thumbnail);
  5. }
  6. thumbnail.removeFromParent();
  7. }

代码示例来源:origin: com.haulmont.cuba/cuba-web-toolkit

  1. protected boolean isCubaTableClickableCell(Event event) {
  2. Element eventTarget = event.getEventTarget().cast();
  3. Element elementTdOrTr = getElementTdOrTr(eventTarget);
  4. if (elementTdOrTr != null
  5. && "td".equalsIgnoreCase(elementTdOrTr.getTagName())
  6. && !elementTdOrTr.hasClassName(CUBA_TABLE_CLICKABLE_TEXT_STYLE)) {
  7. // found <td>
  8. if ("span".equalsIgnoreCase(eventTarget.getTagName())
  9. && eventTarget.hasClassName(CUBA_TABLE_CLICKABLE_CELL_STYLE)) {
  10. // found <span class="c-table-clickable-cell">
  11. return true;
  12. }
  13. }
  14. return false;
  15. }

代码示例来源:origin: fr.putnami.pwt/pwt

  1. public static void cleanEnumStyle(Element e, Class<?> enumClass) {
  2. if (enumClass == null) {
  3. return;
  4. }
  5. for (Object enumValue : enumClass.getEnumConstants()) {
  6. if (enumValue instanceof CssStyle) {
  7. String currentClassName = e.getClassName();
  8. String styleName = ((CssStyle) enumValue).get();
  9. if (styleName != null && currentClassName != null && e.hasClassName(styleName)) {
  10. e.removeClassName(styleName);
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: Putnami/putnami-web-toolkit

  1. public static void cleanEnumStyle(Element e, Class<?> enumClass) {
  2. if (enumClass == null) {
  3. return;
  4. }
  5. for (Object enumValue : enumClass.getEnumConstants()) {
  6. if (enumValue instanceof CssStyle) {
  7. String currentClassName = e.getClassName();
  8. String styleName = ((CssStyle) enumValue).get();
  9. if (styleName != null && currentClassName != null && e.hasClassName(styleName)) {
  10. e.removeClassName(styleName);
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: fr.putnami.pwt/pwt

  1. public static <S extends CssStyle> void removeStyle(Element e, S style) {
  2. if (e == null) {
  3. return;
  4. }
  5. if (style instanceof Enum) {
  6. StyleUtils.cleanEnumStyle(e, style.getClass());
  7. }
  8. String styleName = StyleUtils.getStyle(style);
  9. String currentClassName = e.getClassName();
  10. if (styleName != null && currentClassName != null && e.hasClassName(styleName)) {
  11. e.removeClassName(styleName);
  12. }
  13. }

代码示例来源:origin: Putnami/putnami-web-toolkit

  1. public static <S extends CssStyle> void removeStyle(Element e, S style) {
  2. if (e == null) {
  3. return;
  4. }
  5. if (style instanceof Enum) {
  6. StyleUtils.cleanEnumStyle(e, style.getClass());
  7. }
  8. String styleName = StyleUtils.getStyle(style);
  9. String currentClassName = e.getClassName();
  10. if (styleName != null && currentClassName != null && e.hasClassName(styleName)) {
  11. e.removeClassName(styleName);
  12. }
  13. }

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

  1. public void testShowHide() {
  2. Alert alert = getWidget();
  3. Element element = alert.getElement();
  4. alert.open();
  5. assertTrue(element.hasClassName(CssName.OPEN));
  6. alert.close();
  7. assertFalse(element.hasClassName(CssName.OPEN));
  8. }

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

  1. public static <H extends UIObject & HasColors> void checkColor(H hasColors) {
  2. final Element element = hasColors.getElement();
  3. hasColors.setTextColor(Color.WHITE);
  4. assertTrue(element.hasClassName(Color.WHITE.getCssName() + "-text"));
  5. hasColors.setBackgroundColor(Color.BLACK);
  6. assertTrue(element.hasClassName(Color.BLACK.getCssName()));
  7. }

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

  1. public static <H extends UIObject & HasColors> void checkColor(H hasColors) {
  2. final Element element = hasColors.getElement();
  3. hasColors.setTextColor(Color.WHITE);
  4. assertTrue(element.hasClassName(Color.WHITE.getCssName() + "-text"));
  5. hasColors.setBackgroundColor(Color.BLACK);
  6. assertTrue(element.hasClassName(Color.BLACK.getCssName()));
  7. }

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

  1. public void testShadow() {
  2. // UiBinder
  3. // given
  4. T widget = getWidget(false);
  5. // when / then
  6. widget.setShadow(1);
  7. assertEquals(1, widget.getShadow());
  8. // Standard
  9. // given
  10. attachWidget();
  11. // when / then
  12. final Element element = widget.getElement();
  13. widget.setShadow(1);
  14. assertTrue(element.hasClassName(CssName.Z_DEPTH_1));
  15. }

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

  1. public void testShadow() {
  2. // UiBinder
  3. // given
  4. T widget = getWidget(false);
  5. // when / then
  6. widget.setShadow(1);
  7. assertEquals(1, widget.getShadow());
  8. // Standard
  9. // given
  10. attachWidget();
  11. // when / then
  12. final Element element = widget.getElement();
  13. widget.setShadow(1);
  14. assertTrue(element.hasClassName(CssName.Z_DEPTH_1));
  15. }

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

  1. public void testCenterOn() {
  2. // UiBinder
  3. // given
  4. T widget = getWidget(false);
  5. // when / then
  6. widget.setCenterOn(CenterOn.CENTER_ON_SMALL);
  7. assertEquals(CenterOn.CENTER_ON_SMALL, widget.getCenterOn());
  8. // Standard
  9. // given
  10. attachWidget();
  11. // when / then
  12. final Element element = widget.getElement();
  13. widget.setCenterOn(CenterOn.CENTER_ON_SMALL);
  14. assertTrue(element.hasClassName(CenterOn.CENTER_ON_SMALL.getCssName()));
  15. }

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

  1. public void testCenterOn() {
  2. // UiBinder
  3. // given
  4. T widget = getWidget(false);
  5. // when / then
  6. widget.setCenterOn(CenterOn.CENTER_ON_SMALL);
  7. assertEquals(CenterOn.CENTER_ON_SMALL, widget.getCenterOn());
  8. // Standard
  9. // given
  10. attachWidget();
  11. // when / then
  12. final Element element = widget.getElement();
  13. widget.setCenterOn(CenterOn.CENTER_ON_SMALL);
  14. assertTrue(element.hasClassName(CenterOn.CENTER_ON_SMALL.getCssName()));
  15. }

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

  1. public void testScrollspy() {
  2. // UiBinder
  3. // given
  4. T widget = getWidget(false);
  5. // when / then
  6. widget.setScrollspy("scrollspy-1");
  7. assertEquals("scrollspy-1", widget.getId());
  8. assertEquals("scrollspy-1", widget.getScrollspy());
  9. // Standard
  10. // given
  11. attachWidget();
  12. // when / then
  13. final Element element = widget.getElement();
  14. widget.setScrollspy("scrollspy-1");
  15. assertTrue(element.hasClassName(CssName.SECTION + " " + CssName.SCROLLSPY));
  16. }

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

  1. public void testToastWithStyling() {
  2. MaterialToast.fireToast("test", "rounded");
  3. Element toastContainer = $("body").find("#toast-container").asElement();
  4. assertNotNull(toastContainer);
  5. assertEquals(toastContainer.getChildCount(), 1);
  6. assertNotNull(toastContainer.getChild(0));
  7. assertTrue(toastContainer.getChild(0) instanceof Element);
  8. Element toastElement = (Element) toastContainer.getChild(0);
  9. assertTrue(toastElement.hasClassName("rounded"));
  10. toastContainer.setInnerHTML("");
  11. }

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

  1. public void testToastWithStyling() {
  2. MaterialToast.fireToast("test", "rounded");
  3. Element toastContainer = $("body").find("#toast-container").asElement();
  4. assertNotNull(toastContainer);
  5. assertEquals(toastContainer.getChildCount(), 1);
  6. assertNotNull(toastContainer.getChild(0));
  7. assertTrue(toastContainer.getChild(0) instanceof Element);
  8. Element toastElement = (Element) toastContainer.getChild(0);
  9. assertTrue(toastElement.hasClassName("rounded"));
  10. toastContainer.setInnerHTML("");
  11. }

相关文章

Element类方法