List of usage examples for com.vaadin.client StyleConstants DISABLED
String DISABLED
To view the source code for com.vaadin.client StyleConstants DISABLED.
Click Source Link
From source file:com.haulmont.cuba.web.toolkit.ui.client.caption.CubaCaptionWidget.java
License:Apache License
@Override public boolean updateCaption() { ComponentConnector owner = getOwner(); /* CAUTION copied from super class with small changes */ boolean wasPlacedAfterComponent = placedAfterComponent; // Caption is placed after component unless there is some part which // moves it above. placedAfterComponent = captionPlacedAfterComponentByDefault; String style = CLASSNAME;//from www. j av a2 s . c om if (ComponentStateUtil.hasStyles(owner.getState())) { for (String customStyle : owner.getState().styles) { style += " " + CLASSNAME + "-" + customStyle; } } if (!owner.isEnabled()) { style += " " + StyleConstants.DISABLED; } setStyleName(style); boolean hasIcon = owner.getState().resources.containsKey(ComponentConstants.ICON_RESOURCE); boolean showRequired = false; boolean showError = owner.getState().errorMessage != null; if (owner.getState() instanceof AbstractFieldState) { AbstractFieldState abstractFieldState = (AbstractFieldState) owner.getState(); showError = showError && !abstractFieldState.hideErrors; } if (owner instanceof AbstractFieldConnector) { showRequired = ((AbstractFieldConnector) owner).isRequired(); } if (icon != null) { getElement().removeChild(icon.getElement()); icon = null; } if (hasIcon) { String uri = owner.getState().resources.get(ComponentConstants.ICON_RESOURCE).getURL(); icon = getOwner().getConnection().getIcon(uri); if (icon instanceof ImageIcon) { // onload will set appropriate size later icon.setWidth("0"); icon.setHeight("0"); } DOM.insertChild(getElement(), icon.getElement(), getInsertPosition(InsertPosition.ICON)); // Icon forces the caption to be above the component placedAfterComponent = false; } if (owner.getState().caption != null) { // A caption text should be shown if the attribute is set // If the caption is null the ATTRIBUTE_CAPTION should not be set to // avoid ending up here. if (captionText == null) { captionText = DOM.createDiv(); captionText.setClassName("v-captiontext"); DOM.insertChild(getElement(), captionText, getInsertPosition(InsertPosition.CAPTION)); } // Update caption text String c = owner.getState().caption; // A text forces the caption to be above the component. placedAfterComponent = false; if (c == null || c.trim().equals("")) { // Not sure if c even can be null. Should not. // This is required to ensure that the caption uses space in all // browsers when it is set to the empty string. If there is an // icon, error indicator or required indicator they will ensure // that space is reserved. if (!hasIcon && !showRequired && !showError) { captionText.setInnerHTML(" "); } } else { setCaptionText(captionText, owner.getState()); } } else if (captionText != null) { // Remove existing getElement().removeChild(captionText); captionText = null; } if (ComponentStateUtil.hasDescription(owner.getState()) && captionText != null) { addStyleDependentName("hasdescription"); } else { removeStyleDependentName("hasdescription"); } AriaHelper.handleInputRequired(owner.getWidget(), showRequired); if (showRequired) { if (requiredFieldIndicator == null) { requiredFieldIndicator = DOM.createDiv(); requiredFieldIndicator.setClassName("v-required-field-indicator"); requiredFieldIndicator.setInnerText("*"); DOM.insertChild(getElement(), requiredFieldIndicator, getInsertPosition(InsertPosition.REQUIRED)); // Hide the required indicator from assistive device Roles.getTextboxRole().setAriaHiddenState(requiredFieldIndicator, true); } } else if (requiredFieldIndicator != null) { // Remove existing requiredFieldIndicator.removeFromParent(); requiredFieldIndicator = null; } if (isContextHelpIconEnabled(owner.getState())) { if (contextHelpIndicatorElement == null) { contextHelpIndicatorElement = DOM.createDiv(); contextHelpIndicatorElement.setClassName(CONTEXT_HELP_CLASSNAME); DOM.insertChild(getElement(), contextHelpIndicatorElement, getContextHelpInsertPosition()); if (clickHandlerRegistration == null) { clickHandlerRegistration = addClickHandler(this); } } } else { if (contextHelpIndicatorElement != null) { contextHelpIndicatorElement.removeFromParent(); contextHelpIndicatorElement = null; } if (clickHandlerRegistration != null) { clickHandlerRegistration.removeHandler(); clickHandlerRegistration = null; } } AriaHelper.handleInputInvalid(owner.getWidget(), showError); if (showError) { if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); errorIndicatorElement.setInnerHTML(" "); errorIndicatorElement.setClassName("v-errorindicator"); DOM.insertChild(getElement(), errorIndicatorElement, getInsertPosition(InsertPosition.ERROR)); // Hide error indicator from assistive devices Roles.getTextboxRole().setAriaHiddenState(errorIndicatorElement, true); } } else if (errorIndicatorElement != null) { // Remove existing errorIndicatorElement.removeFromParent(); errorIndicatorElement = null; } addStyleName(CLASSNAME); if (captionHolder != null) { captionHolder.captionUpdated(this); } return (wasPlacedAfterComponent != placedAfterComponent); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget.java
License:Apache License
protected void setEnabledForSubmitButton(boolean enabled) { submitButton.setEnabled(enabled); submitButton.setStyleName(StyleConstants.DISABLED, !enabled); }
From source file:com.haulmont.cuba.web.widgets.client.caption.CubaCaptionWidget.java
License:Apache License
@Override public boolean updateCaption() { ComponentConnector owner = getOwner(); // CAUTION copied from super class with small changes boolean wasPlacedAfterComponent = placedAfterComponent; // Caption is placed after component unless there is some part which // moves it above. placedAfterComponent = captionPlacedAfterComponentByDefault; String style = CLASSNAME;// ww w . j a va2 s. c om if (ComponentStateUtil.hasStyles(owner.getState())) { for (String customStyle : owner.getState().styles) { style += " " + CLASSNAME + "-" + customStyle; } } if (!owner.isEnabled()) { style += " " + StyleConstants.DISABLED; } setStyleName(style); boolean hasIcon = owner.getState().resources.containsKey(ComponentConstants.ICON_RESOURCE); boolean showRequired = false; boolean showError = owner.getState().errorMessage != null; if (owner.getState() instanceof AbstractFieldState) { AbstractFieldState abstractFieldState = (AbstractFieldState) owner.getState(); showError = showError && !abstractFieldState.hideErrors; } if (owner instanceof AbstractFieldConnector) { showRequired = ((AbstractFieldConnector) owner).isRequired(); } if (icon != null) { getElement().removeChild(icon.getElement()); icon = null; } if (hasIcon) { String uri = owner.getState().resources.get(ComponentConstants.ICON_RESOURCE).getURL(); icon = getOwner().getConnection().getIcon(uri); if (icon instanceof ImageIcon) { // onload will set appropriate size later icon.setWidth("0"); icon.setHeight("0"); } DOM.insertChild(getElement(), icon.getElement(), getInsertPosition(InsertPosition.ICON)); // Icon forces the caption to be above the component placedAfterComponent = false; } if (owner.getState().caption != null) { // A caption text should be shown if the attribute is set // If the caption is null the ATTRIBUTE_CAPTION should not be set to // avoid ending up here. if (captionText == null) { captionText = DOM.createDiv(); captionText.setClassName("v-captiontext"); DOM.insertChild(getElement(), captionText, getInsertPosition(InsertPosition.CAPTION)); } // Update caption text String c = owner.getState().caption; // A text forces the caption to be above the component. placedAfterComponent = false; if (c == null || c.trim().equals("")) { // Not sure if c even can be null. Should not. // This is required to ensure that the caption uses space in all // browsers when it is set to the empty string. If there is an // icon, error indicator or required indicator they will ensure // that space is reserved. if (!hasIcon && !showRequired && !showError) { captionText.setInnerHTML(" "); } } else { setCaptionText(captionText, owner.getState()); } } else if (captionText != null) { // Remove existing getElement().removeChild(captionText); captionText = null; } if (ComponentStateUtil.hasDescription(owner.getState()) && captionText != null) { addStyleDependentName("hasdescription"); } else { removeStyleDependentName("hasdescription"); } AriaHelper.handleInputRequired(owner.getWidget(), showRequired); if (showRequired) { if (requiredFieldIndicator == null) { requiredFieldIndicator = DOM.createDiv(); requiredFieldIndicator.setClassName("v-required-field-indicator"); requiredFieldIndicator.setInnerText("*"); DOM.insertChild(getElement(), requiredFieldIndicator, getInsertPosition(InsertPosition.REQUIRED)); // Hide the required indicator from assistive device Roles.getTextboxRole().setAriaHiddenState(requiredFieldIndicator, true); } } else if (requiredFieldIndicator != null) { // Remove existing requiredFieldIndicator.removeFromParent(); requiredFieldIndicator = null; } if (isContextHelpIconEnabled(owner.getState())) { if (contextHelpIndicatorElement == null) { contextHelpIndicatorElement = DOM.createDiv(); contextHelpIndicatorElement.setClassName(CONTEXT_HELP_CLASSNAME); if (hasContextHelpIconListeners(owner.getState())) { contextHelpIndicatorElement.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME); } DOM.insertChild(getElement(), contextHelpIndicatorElement, getContextHelpInsertPosition()); if (clickHandlerRegistration == null) { clickHandlerRegistration = addClickHandler(this); } } } else { if (contextHelpIndicatorElement != null) { contextHelpIndicatorElement.removeFromParent(); contextHelpIndicatorElement = null; } if (clickHandlerRegistration != null) { clickHandlerRegistration.removeHandler(); clickHandlerRegistration = null; } } AriaHelper.handleInputInvalid(owner.getWidget(), showError); if (showError) { if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); errorIndicatorElement.setInnerHTML(" "); errorIndicatorElement.setClassName("v-errorindicator"); DOM.insertChild(getElement(), errorIndicatorElement, getInsertPosition(InsertPosition.ERROR)); // Hide error indicator from assistive devices Roles.getTextboxRole().setAriaHiddenState(errorIndicatorElement, true); } } else if (errorIndicatorElement != null) { // Remove existing errorIndicatorElement.removeFromParent(); errorIndicatorElement = null; } addStyleName(CLASSNAME); if (captionHolder != null) { captionHolder.captionUpdated(this); } return (wasPlacedAfterComponent != placedAfterComponent); }