Example usage for com.vaadin.client VCaption setCaptionText

List of usage examples for com.vaadin.client VCaption setCaptionText

Introduction

In this page you can find the example usage for com.vaadin.client VCaption setCaptionText.

Prototype

public static void setCaptionText(HasHTML widget, AbstractComponentState state) 

Source Link

Document

Sets the text of the given widget to the caption found in the state.

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadConnector.java

License:Apache License

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("caption")
            || stateChangeEvent.hasPropertyChanged("captionAsHtml")) {
        VCaption.setCaptionText(getWidget().submitButton.captionElement, getState());

        if ("".equals(getState().caption) || getState().caption == null) {
            getWidget().submitButton.addStyleDependentName("empty-caption");
        } else {//from w  ww .ja  v a 2  s. c  o  m
            getWidget().submitButton.removeStyleDependentName("empty-caption");
        }
    }

    if (stateChangeEvent.hasPropertyChanged("resources")) {
        if (getWidget().submitButton.icon != null) {
            getWidget().submitButton.wrapper.removeChild(getWidget().submitButton.icon.getElement());
            getWidget().submitButton.icon = null;
        }
        Icon icon = getIcon();
        if (icon != null) {
            getWidget().submitButton.icon = icon;
            if (getState().iconAltText != null) {
                icon.setAlternateText(getState().iconAltText);
            } else {
                icon.setAlternateText("");
            }

            getWidget().submitButton.wrapper.insertBefore(icon.getElement(),
                    getWidget().submitButton.captionElement);
        }
    }

    if (stateChangeEvent.hasPropertyChanged("multiSelect")) {
        getWidget().setMultiSelect(getState().multiSelect);
    }

    if (stateChangeEvent.hasPropertyChanged("iconAltText")) {
        if (getWidget().submitButton.icon != null) {
            Icon icon = getWidget().submitButton.icon;
            if (getState().iconAltText != null) {
                icon.setAlternateText(getState().iconAltText);
            } else {
                icon.setAlternateText("");
            }
        }
    }

    if (stateChangeEvent.hasPropertyChanged("progressWindowCaption")) {
        getWidget().progressWindowCaption = getState().progressWindowCaption;
    }

    if (stateChangeEvent.hasPropertyChanged("cancelButtonCaption")) {
        getWidget().cancelButtonCaption = getState().cancelButtonCaption;
    }

    if (stateChangeEvent.hasPropertyChanged("unableToUploadFileMessage")) {
        getWidget().unableToUploadFileMessage = getState().unableToUploadFileMessage;
    }

    if (stateChangeEvent.hasPropertyChanged("accept")) {
        getWidget().setAccept(getState().accept);
    }

    if (stateChangeEvent.hasPropertyChanged("fileSizeLimit")) {
        getWidget().fileSizeLimit = getState().fileSizeLimit;
    }

    if (stateChangeEvent.hasPropertyChanged("permittedExtensions")) {
        getWidget().permittedExtensions = getState().permittedExtensions;
    }

    if (stateChangeEvent.hasPropertyChanged("dropZone")) {
        ComponentConnector dropZone = (ComponentConnector) getState().dropZone;

        getWidget().setDropZone(dropZone != null ? dropZone.getWidget() : null, getState().dropZonePrompt);
    }

    if (stateChangeEvent.hasPropertyChanged("pasteZone")) {
        ComponentConnector pasteZone = (ComponentConnector) getState().pasteZone;

        getWidget().setPasteZone(pasteZone != null ? pasteZone.getWidget() : null);
    }

    if (!isEnabled() || isReadOnly()) {
        getWidget().disableUpload();
    } else {
        getWidget().enableUpload();
    }
}

From source file:com.haulmont.cuba.web.widgets.client.jqueryfileupload.CubaFileUploadConnector.java

License:Apache License

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("caption")
            || stateChangeEvent.hasPropertyChanged("captionAsHtml")) {
        VCaption.setCaptionText(getWidget().submitButton.captionElement, getState());

        if ("".equals(getState().caption) || getState().caption == null) {
            getWidget().submitButton.addStyleDependentName("empty-caption");
        } else {//from   w ww . jav  a  2 s . com
            getWidget().submitButton.removeStyleDependentName("empty-caption");
        }
    }

    if (stateChangeEvent.hasPropertyChanged("resources")) {
        if (getWidget().submitButton.icon != null) {
            getWidget().submitButton.wrapper.removeChild(getWidget().submitButton.icon.getElement());
            getWidget().submitButton.icon = null;
        }
        Icon icon = getIcon();
        if (icon != null) {
            getWidget().submitButton.icon = icon;
            if (getState().iconAltText != null) {
                icon.setAlternateText(getState().iconAltText);
            } else {
                icon.setAlternateText("");
            }

            getWidget().submitButton.wrapper.insertBefore(icon.getElement(),
                    getWidget().submitButton.captionElement);
        }
    }

    if (stateChangeEvent.hasPropertyChanged("multiSelect")) {
        getWidget().setMultiSelect(getState().multiSelect);
    }

    if (stateChangeEvent.hasPropertyChanged("iconAltText")) {
        if (getWidget().submitButton.icon != null) {
            Icon icon = getWidget().submitButton.icon;
            if (getState().iconAltText != null) {
                icon.setAlternateText(getState().iconAltText);
            } else {
                icon.setAlternateText("");
            }
        }
    }

    if (stateChangeEvent.hasPropertyChanged("progressWindowCaption")) {
        getWidget().progressWindowCaption = getState().progressWindowCaption;
    }

    if (stateChangeEvent.hasPropertyChanged("cancelButtonCaption")) {
        getWidget().cancelButtonCaption = getState().cancelButtonCaption;
    }

    if (stateChangeEvent.hasPropertyChanged("unableToUploadFileMessage")) {
        getWidget().unableToUploadFileMessage = getState().unableToUploadFileMessage;
    }

    if (stateChangeEvent.hasPropertyChanged("accept")) {
        getWidget().setAccept(getState().accept);
    }

    if (stateChangeEvent.hasPropertyChanged("fileSizeLimit")) {
        getWidget().fileSizeLimit = getState().fileSizeLimit;
    }

    if (stateChangeEvent.hasPropertyChanged("permittedExtensions")) {
        getWidget().permittedExtensions = getState().permittedExtensions;
    }

    if (stateChangeEvent.hasPropertyChanged("dropZone")) {
        ComponentConnector dropZone = (ComponentConnector) getState().dropZone;

        getWidget().setDropZone(dropZone != null ? dropZone.getWidget() : null, getState().dropZonePrompt);
    }

    if (stateChangeEvent.hasPropertyChanged("pasteZone")) {
        ComponentConnector pasteZone = (ComponentConnector) getState().pasteZone;

        getWidget().setPasteZone(pasteZone != null ? pasteZone.getWidget() : null);
    }

    if (!isEnabled()) {
        getWidget().disableUpload();
    } else {
        getWidget().enableUpload();
    }
}