com.vaadin.shared.communication.URLReference Java Examples

The following examples show how to use com.vaadin.shared.communication.URLReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CubaIconRendererConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Icon decode(JsonValue value) {
    URLReference reference = (URLReference) JsonDecoder.decodeValue(
            TypeDataStore.getType(URLReference.class), value, null,
            getConnection());

    return reference != null
            ? getConnection().getIcon(reference.getURL())
            : null;
}
 
Example #2
Source File: CubaOrderedActionsLayoutConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
@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 instanceof HasErrorIndicator) {
        showError = ((HasErrorIndicator) child).isErrorIndicatorVisible();
    }
    boolean required = false;
    if (child instanceof HasRequiredIndicator) {
        required = ((HasRequiredIndicator) child)
                .isRequiredIndicatorVisible();
    }
    // For compatibility components
    if (child instanceof com.vaadin.v7.client.ui.AbstractFieldConnector) {
        required = ((com.vaadin.v7.client.ui.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());
        }
    }
}
 
Example #3
Source File: CubaIconRenderer.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public JsonValue encode(Resource value) {
    ResourceReference resourceReference = ResourceReference.create(value, this, ComponentConstants.ICON_RESOURCE);
    return super.encode(resourceReference, URLReference.class);
}