Example usage for com.vaadin.client ComponentConnector isRelativeHeight

List of usage examples for com.vaadin.client ComponentConnector isRelativeHeight

Introduction

In this page you can find the example usage for com.vaadin.client ComponentConnector isRelativeHeight.

Prototype

public boolean isRelativeHeight();

Source Link

Document

Returns true if the height of this paintable is currently relative.

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.orderedactionslayout.CubaOrderedActionsLayoutConnector.java

License:Apache License

@Override
protected void updateCaptionInternal(ComponentConnector child) {
    // CAUTION copied from superclass
    CubaOrderedLayoutSlot slot = (CubaOrderedLayoutSlot) getWidget().getSlot(child.getWidget());

    String caption = child.getState().caption;
    URLReference iconUrl = child.getState().resources.get(ComponentConstants.ICON_RESOURCE);
    String iconUrlString = iconUrl != null ? iconUrl.getURL() : null;
    Icon icon = child.getConnection().getIcon(iconUrlString);

    List<String> styles = child.getState().styles;
    String error = child.getState().errorMessage;
    boolean showError = error != null;
    if (child.getState() instanceof AbstractFieldState) {
        AbstractFieldState abstractFieldState = (AbstractFieldState) child.getState();
        showError = showError && !abstractFieldState.hideErrors;
    }// ww w. j av a2  s  .  c o m
    boolean required = false;
    if (child instanceof AbstractFieldConnector) {
        required = ((AbstractFieldConnector) child).isRequired();
    }
    boolean enabled = child.isEnabled();

    if (slot.hasCaption() && null == caption) {
        slot.setCaptionResizeListener(null);
    }

    // Haulmont API
    boolean contextHelpIconEnabled = isContextHelpIconEnabled(child.getState());

    // Haulmont API
    slot.setCaption(caption, contextHelpIconEnabled, icon, styles, error, showError, required, enabled,
            child.getState().captionAsHtml);

    AriaHelper.handleInputRequired(child.getWidget(), required);
    AriaHelper.handleInputInvalid(child.getWidget(), showError);
    AriaHelper.bindCaption(child.getWidget(), slot.getCaptionElement());

    if (slot.hasCaption()) {
        CaptionPosition pos = slot.getCaptionPosition();
        slot.setCaptionResizeListener(slotCaptionResizeListener);
        if (child.isRelativeHeight() && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
            getWidget().updateCaptionOffset(slot.getCaptionElement());
        } else if (child.isRelativeWidth() && (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT)) {
            getWidget().updateCaptionOffset(slot.getCaptionElement());
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.client.orderedactionslayout.CubaOrderedActionsLayoutConnector.java

License:Apache License

@Override
protected void updateCaptionInternal(ComponentConnector child) {
    // CAUTION copied from superclass
    CubaOrderedLayoutSlot slot = (CubaOrderedLayoutSlot) getWidget().getSlot(child.getWidget());

    String caption = child.getState().caption;
    URLReference iconUrl = child.getState().resources.get(ComponentConstants.ICON_RESOURCE);
    String iconUrlString = iconUrl != null ? iconUrl.getURL() : null;
    Icon icon = child.getConnection().getIcon(iconUrlString);

    List<String> styles = child.getState().styles;
    String error = child.getState().errorMessage;
    boolean showError = error != null;
    if (child.getState() instanceof AbstractFieldState) {
        AbstractFieldState abstractFieldState = (AbstractFieldState) child.getState();
        // vaadin8 rework
        //            showError = showError && !abstractFieldState.hideErrors;
    }/*from   w  ww  . j a va2 s  . com*/
    boolean required = false;
    if (child instanceof AbstractFieldConnector) {
        required = ((AbstractFieldConnector) child).isRequiredIndicatorVisible();
    }
    boolean enabled = child.isEnabled();

    if (slot.hasCaption() && null == caption) {
        slot.setCaptionResizeListener(null);
    }

    // Haulmont API
    boolean contextHelpIconEnabled = isContextHelpIconEnabled(child.getState());

    // Haulmont API
    slot.setCaption(caption, contextHelpIconEnabled, icon, styles, error, showError, required, enabled,
            child.getState().captionAsHtml);

    AriaHelper.handleInputRequired(child.getWidget(), required);
    AriaHelper.handleInputInvalid(child.getWidget(), showError);
    AriaHelper.bindCaption(child.getWidget(), slot.getCaptionElement());

    if (slot.hasCaption()) {
        CaptionPosition pos = slot.getCaptionPosition();
        slot.setCaptionResizeListener(slotCaptionResizeListener);
        if (child.isRelativeHeight() && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
            getWidget().updateCaptionOffset(slot.getCaptionElement());
        } else if (child.isRelativeWidth() && (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT)) {
            getWidget().updateCaptionOffset(slot.getCaptionElement());
        }
    }
}