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

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

Introduction

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

Prototype

public void clearMarginTop() 

Source Link

Usage

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

License:Apache License

/**
 * Update the offset off the caption relative to the slot
 * <p>//from  www .  ja v  a2 s  .c  o m
 * For internal use only. May be removed or replaced in the future.
 * 
 * @param caption
 *            The caption element
 * @deprecated As of 7.2, call or override
 *             {@link #updateCaptionOffset(Element)} instead
 */
@Deprecated
public void updateCaptionOffset(com.google.gwt.user.client.Element caption) {

    Element captionWrap = caption.getParentElement();

    Style captionWrapStyle = captionWrap.getStyle();
    captionWrapStyle.clearPaddingTop();
    captionWrapStyle.clearPaddingRight();
    captionWrapStyle.clearPaddingBottom();
    captionWrapStyle.clearPaddingLeft();

    Style captionStyle = caption.getStyle();
    captionStyle.clearMarginTop();
    captionStyle.clearMarginRight();
    captionStyle.clearMarginBottom();
    captionStyle.clearMarginLeft();

    // Get caption position from the classname
    CaptionPosition captionPosition = getCaptionPositionFromElement(captionWrap);

    if (captionPosition == CaptionPosition.LEFT || captionPosition == CaptionPosition.RIGHT) {
        int captionWidth;
        if (layoutManager != null) {
            captionWidth = layoutManager.getOuterWidth(caption) - layoutManager.getMarginWidth(caption);
        } else {
            captionWidth = caption.getOffsetWidth();
        }
        if (captionWidth > 0) {
            if (captionPosition == CaptionPosition.LEFT) {
                captionWrapStyle.setPaddingLeft(captionWidth, Unit.PX);
                captionStyle.setMarginLeft(-captionWidth, Unit.PX);
            } else {
                captionWrapStyle.setPaddingRight(captionWidth, Unit.PX);
                captionStyle.setMarginRight(-captionWidth, Unit.PX);
            }
        }
    }
    if (captionPosition == CaptionPosition.TOP || captionPosition == CaptionPosition.BOTTOM) {
        int captionHeight;
        if (layoutManager != null) {
            captionHeight = layoutManager.getOuterHeight(caption) - layoutManager.getMarginHeight(caption);
        } else {
            captionHeight = caption.getOffsetHeight();
        }
        if (captionHeight > 0) {
            if (captionPosition == CaptionPosition.TOP) {
                captionWrapStyle.setPaddingTop(captionHeight, Unit.PX);
                captionStyle.setMarginTop(-captionHeight, Unit.PX);
            } else {
                captionWrapStyle.setPaddingBottom(captionHeight, Unit.PX);
                captionStyle.setMarginBottom(-captionHeight, Unit.PX);
            }
        }
    }
}

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 www .j  a v  a2s .  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.kie.dockerui.client.widgets.container.navigator.item.view.NavigationItemView.java

License:Apache License

private void show(final String id, final String _title, final String _text, final SafeUri imageUri,
        final int containersRunningCount) {
    showTitle(_title);//www .  jav a 2s.c  o m
    showRunningContainers(id, containersRunningCount);

    // Show the navigation item image.
    final boolean isImage = imageUri != null;
    if (isImage) {
        image.setUrl(imageUri);
        image.setSize(getSizeInPx(), getSizeInPx());
    }
    image.setVisible(isImage);

    // Show the navigation item text.
    final boolean isText = _text != null;
    if (isText) {
        text.setText(new SafeHtmlBuilder().appendEscaped(_text).toSafeHtml().asString());
    }

    // Styles for placing the text over the image.
    final Style textStyle = text.getElement().getStyle();
    if (isImage && isText) {
        textStyle.setPosition(Style.Position.ABSOLUTE);
        textStyle.setMarginTop(size / 2, Style.Unit.PX);
        final int tSize = (int) (_text.length() * 5);
        textStyle.setMarginLeft((size / 2) - tSize, Style.Unit.PX);
    } else if (isText) {
        textStyle.setPosition(Style.Position.RELATIVE);
        textStyle.clearMarginTop();
        textStyle.clearMarginLeft();
    }
    text.setVisible(isText);

    // Add the click handler.
    addItemDetailClickHandler(id);
}