Example usage for com.google.gwt.dom.client Style clearVisibility

List of usage examples for com.google.gwt.dom.client Style clearVisibility

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style clearVisibility.

Prototype

public void clearVisibility() 

Source Link

Usage

From source file:com.smartgwt.mobile.client.widgets.BaseButton.java

License:Open Source License

private void doSetIcon(boolean fireContentChangedEvent) {
    assert icon != null && iconImage != null;
    final Element img = iconImage.getElement();
    final Style imgStyle = img.getStyle();
    if (masked) {
        iconImage.setResource(IconResources.INSTANCE.blank());
        if ("IMG".equals(img.getTagName())) {
            final ImageElement iconImageImgElem = ImageElement.as(img);
            iconImageImgElem.removeAttribute("width");
            iconImageImgElem.removeAttribute("height");
        }//from w w w  . j a va 2  s . c  om
        imgStyle.clearWidth();
        imgStyle.clearHeight();
        img.setClassName(_CSS.maskedButtonIconClass());
        imgStyle.clearBackgroundColor();
        imgStyle.clearBackgroundImage();
        // Note: Mobile WebKit automatically scales down the mask image to fit the element
        // to which the mask image is applied.
        imgStyle.setProperty("WebkitMaskBoxImage", "url(" + icon.getSafeUri().asString() + ")");
    } else {
        if ("IMG".equals(img.getTagName())) {
            final ImageElement iconImageImgElem = ImageElement.as(img);
            iconImageImgElem.removeAttribute("width");
            iconImageImgElem.removeAttribute("height");
        }
        imgStyle.clearWidth();
        imgStyle.clearHeight();
        imgStyle.clearProperty("MozBackgroundSize");
        imgStyle.clearProperty("OBackgroundSize");
        imgStyle.clearProperty("WebkitBackgroundSize");
        imgStyle.clearProperty("backgroundSize");
        img.removeClassName(_CSS.maskedButtonIconClass());
    }

    setIconAlign(iconAlign);
    if (iconColor != null) {
        setIconColor(iconColor);
    }

    imgStyle.clearVisibility();
    if (fireContentChangedEvent)
        _fireContentChangedEvent();
}

From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java

License:Apache License

/**
 * Assigns relative sizes to the children that should expand based on their
 * expand ratios.//from  ww  w  .  ja  v a2  s  . c  om
 */
public void updateExpandedSizes() {
    // Ensure the expand wrapper is in place
    if (expandWrapper == null) {
        expandWrapper = DOM.createDiv();
        expandWrapper.setClassName("v-expand");

        // Detach all widgets before modifying DOM
        for (Widget widget : getChildren()) {
            orphan(widget);
        }

        while (getElement().getChildCount() > 0) {
            Node el = getElement().getChild(0);
            expandWrapper.appendChild(el);
        }
        getElement().appendChild(expandWrapper);

        // Attach all widgets again
        for (Widget widget : getChildren()) {
            adopt(widget);
        }
    }

    // Sum up expand ratios to get the denominator
    double total = 0;
    for (Slot slot : widgetToSlot.values()) {
        // FIXME expandRatio might be <0
        total += slot.getExpandRatio();
    }

    // Give each expanded child its own share
    for (Slot slot : widgetToSlot.values()) {

        Element slotElement = slot.getElement();
        slotElement.removeAttribute("aria-hidden");

        Style slotStyle = slotElement.getStyle();
        slotStyle.clearVisibility();
        slotStyle.clearMarginLeft();
        slotStyle.clearMarginTop();

        if (slot.getExpandRatio() != 0) {
            // FIXME expandRatio might be <0
            double size = 100 * (slot.getExpandRatio() / total);

            if (vertical) {
                slot.setHeight(size + "%");
                if (slot.hasRelativeHeight()) {
                    Util.notifyParentOfSizeChange(this, true);
                }
            } else {
                slot.setWidth(size + "%");
                if (slot.hasRelativeWidth()) {
                    Util.notifyParentOfSizeChange(this, true);
                }
            }

        } else if (slot.isRelativeInDirection(vertical)) {
            // Relative child without expansion gets no space at all
            if (vertical) {
                slot.setHeight("0");
            } else {
                slot.setWidth("0");
            }
            slotStyle.setVisibility(Visibility.HIDDEN);
            slotElement.setAttribute("aria-hidden", "true");

        } else {
            // Non-relative child without expansion should be unconstrained
            if (BrowserInfo.get().isIE8()) {
                // unconstrained in IE8 is auto
                if (vertical) {
                    slot.setHeight("auto");
                } else {
                    slot.setWidth("auto");
                }
            } else {
                if (vertical) {
                    slotStyle.clearHeight();
                } else {
                    slotStyle.clearWidth();
                }
            }
        }
    }
}

From source file:org.jboss.errai.ui.test.stylebinding.client.res.CompositeStyleBoundTemplate.java

License:Apache License

@TestBinding
private void testBindingStyleUpdate(Style style) {
    if ("0".equals(getTestModel().getTestB())) {
        style.setVisibility(Style.Visibility.HIDDEN);
    } else {/*from  w w  w .ja v a 2  s.  c  o m*/
        style.clearVisibility();
    }
}

From source file:org.jboss.errai.ui.test.stylebinding.client.res.CompositeStyleBoundTemplate.java

License:Apache License

@ComponentBinding
private void testCustomComponentBindingStyleUpdate(Style style) {
    if ("0".equals(getTestModel().getTestC())) {
        style.setVisibility(Style.Visibility.HIDDEN);
    } else {/*w  w w .j  a  va 2 s.  c  om*/
        style.clearVisibility();
    }
}