Search in sources :

Example 1 with CaptionPosition

use of com.vaadin.client.ui.orderedlayout.CaptionPosition in project cuba by cuba-platform.

the class CubaOrderedActionsLayoutConnector method updateCaptionInternal.

@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;
    }
    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());
        }
    }
}
Also used : URLReference(com.vaadin.shared.communication.URLReference) AbstractFieldState(com.vaadin.shared.AbstractFieldState) AbstractFieldConnector(com.vaadin.client.ui.AbstractFieldConnector) Icon(com.vaadin.client.ui.Icon) CaptionPosition(com.vaadin.client.ui.orderedlayout.CaptionPosition)

Aggregations

AbstractFieldConnector (com.vaadin.client.ui.AbstractFieldConnector)1 Icon (com.vaadin.client.ui.Icon)1 CaptionPosition (com.vaadin.client.ui.orderedlayout.CaptionPosition)1 AbstractFieldState (com.vaadin.shared.AbstractFieldState)1 URLReference (com.vaadin.shared.communication.URLReference)1