Class CmsCheckBox

java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
org.opencms.gwt.client.ui.input.CmsCheckBox
All Implemented Interfaces:
com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<Boolean>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasHorizontalAlignment, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget, I_CmsHasInit, I_CmsFormWidget

public class CmsCheckBox extends com.google.gwt.user.client.ui.Composite implements com.google.gwt.event.dom.client.HasClickHandlers, I_CmsFormWidget, I_CmsHasInit, com.google.gwt.user.client.ui.HasHorizontalAlignment, com.google.gwt.event.logical.shared.HasValueChangeHandlers<Boolean>
This class represents a labeled checkbox which is not represented as an INPUT element in the DOM, but is displayed as an image.

It can be checked/unchecked and enabled/disabled, which means 4 combinations in total. So you need to supply 4 images, one for each of the combinations.

Since:
8.0.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

    com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled

    Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

    com.google.gwt.user.client.ui.HasHorizontalAlignment.AutoHorizontalAlignmentConstant, com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant

    Nested classes/interfaces inherited from interface org.opencms.gwt.client.ui.input.I_CmsFormWidget

    I_CmsFormWidget.FieldType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Type string for this widget.

    Fields inherited from class com.google.gwt.user.client.ui.UIObject

    DEBUG_ID_PREFIX

    Fields inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

    ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor which creates a checkbox without a label.
    CmsCheckBox(String labelText)
    Public constructor for a checkbox.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.gwt.event.shared.HandlerRegistration
    addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
    Adds a click handler to the checkbox.
    com.google.gwt.event.shared.HandlerRegistration
    addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Boolean> handler)
     
    void
    disable(String disabledReason)
    Disables the checkbox and changes the checkbox title attribute to the disabled reason.
    void
    Enables the checkbox, switching the checkbox title attribute from the disabled reason to the original title.
    protected void
    Helper method for firing a 'value changed' event.
    Returns the "apparent value", i.e.
    Gets the toggle button used internally.
    Returns the type of data this widget produces.
    Gets the selected/entered value from the widget.
    Gets the current value of the widget as a string.
    com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant
    This is the alignment of the text in reference to the checkbox, possible values are left or right.
    Returns the internal value of this Checkbox.
    Returns the text.
    static void
    Initializes this class.
    boolean
    Returns true if the checkbox is checked.
    boolean
    Returns true if the checkbox is enabled.
    void
    Resets the widget to its default state.
    void
    Call this when auto hiding parents are shown.
    void
    setChecked(boolean checked)
    Checks or unchecks the checkbox.
    void
    setDisplayInline(boolean inline)
    Toggles between display:inline-block and display:block.
    void
    setEnabled(boolean enabled)
    Enables or disables the checkbox.
    void
    setErrorMessage(String errorMessage)
    Sets the error message for this widget.
    void
    Sets the value of the widget.
    void
    Sets the current value of the widget as a string.
    void
    setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
    This is the alignment of the text in reference to the checkbox, possible values are left or right.
    void
    Sets the internal value of this Checkbox.
    void
    Sets the text.

    Methods inherited from class com.google.gwt.user.client.ui.Composite

    claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget

    Methods inherited from class com.google.gwt.user.client.ui.Widget

    addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents

    Methods inherited from class com.google.gwt.user.client.ui.UIObject

    addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.google.gwt.event.shared.HasHandlers

    fireEvent
  • Field Details

  • Constructor Details

    • CmsCheckBox

      public CmsCheckBox()
      Default constructor which creates a checkbox without a label.

    • CmsCheckBox

      public CmsCheckBox(String labelText)
      Public constructor for a checkbox.

      The label text passed will be displayed to the right of the checkbox. If it is null, no label is displayed.

      Parameters:
      labelText - the label text
  • Method Details

    • initClass

      public static void initClass()
      Initializes this class.

    • addClickHandler

      public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
      Adds a click handler to the checkbox.

      Specified by:
      addClickHandler in interface com.google.gwt.event.dom.client.HasClickHandlers
      See Also:
      • HasClickHandlers.addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
    • addValueChangeHandler

      public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Boolean> handler)
      Specified by:
      addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<Boolean>
      See Also:
      • HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
    • disable

      public void disable(String disabledReason)
      Disables the checkbox and changes the checkbox title attribute to the disabled reason.

      Parameters:
      disabledReason - the disabled reason
    • enable

      public void enable()
      Enables the checkbox, switching the checkbox title attribute from the disabled reason to the original title.

    • getApparentValue

      Description copied from interface: I_CmsFormWidget
      Returns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.

      Specified by:
      getApparentValue in interface I_CmsFormWidget
      Returns:
      the apparent value
      See Also:
    • getButton

      Gets the toggle button used internally.

      Returns:
      the toggle button
    • getFieldType

      Description copied from interface: I_CmsFormWidget
      Returns the type of data this widget produces.
      Specified by:
      getFieldType in interface I_CmsFormWidget
      Returns:
      the data type
      See Also:
    • getFormValue

      Description copied from interface: I_CmsFormWidget
      Gets the selected/entered value from the widget.

      Specified by:
      getFormValue in interface I_CmsFormWidget
      Returns:
      the value
      See Also:
    • getFormValueAsString

      Description copied from interface: I_CmsFormWidget
      Gets the current value of the widget as a string.

      Specified by:
      getFormValueAsString in interface I_CmsFormWidget
      Returns:
      the current value of the widget
      See Also:
    • getHorizontalAlignment

      public com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant getHorizontalAlignment()
      This is the alignment of the text in reference to the checkbox, possible values are left or right.

      Specified by:
      getHorizontalAlignment in interface com.google.gwt.user.client.ui.HasHorizontalAlignment
      See Also:
      • HasHorizontalAlignment.getHorizontalAlignment()
    • getInternalValue

      Returns the internal value of this Checkbox.

      Returns:
      the internal value of this Checkbox
    • getText

      public String getText()
      Returns the text.

      Returns:
      the text as String
    • isChecked

      public boolean isChecked()
      Returns true if the checkbox is checked.

      Returns:
      true if the checkbox is checked
    • isEnabled

      public boolean isEnabled()
      Returns true if the checkbox is enabled.

      Specified by:
      isEnabled in interface I_CmsFormWidget
      Returns:
      true if the checkbox is enabled
    • reset

      public void reset()
      Description copied from interface: I_CmsFormWidget
      Resets the widget to its default state.
      Specified by:
      reset in interface I_CmsFormWidget
      See Also:
    • setAutoHideParent

      public void setAutoHideParent(I_CmsAutoHider autoHideParent)
      Description copied from interface: I_CmsFormWidget
      Call this when auto hiding parents are shown.

      Specified by:
      setAutoHideParent in interface I_CmsFormWidget
      Parameters:
      autoHideParent - the auto hide parent
      See Also:
    • setChecked

      public void setChecked(boolean checked)
      Checks or unchecks the checkbox.

      Parameters:
      checked - if true, check the checkbox else uncheck it
    • setDisplayInline

      public void setDisplayInline(boolean inline)
      Toggles between display:inline-block and display:block.

      Parameters:
      inline - true to display inline-block
    • setEnabled

      public void setEnabled(boolean enabled)
      Enables or disables the checkbox.

      Specified by:
      setEnabled in interface I_CmsFormWidget
      Parameters:
      enabled - if true, enable the checkbox, else disable it
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Description copied from interface: I_CmsFormWidget
      Sets the error message for this widget.

      If the error message is null, no error message will be displayed.

      Specified by:
      setErrorMessage in interface I_CmsFormWidget
      Parameters:
      errorMessage - an error message or null
      See Also:
    • setFormValue

      public void setFormValue(Object value)
      Sets the value of the widget.

      Parameters:
      value - the new value
    • setFormValueAsString

      public void setFormValueAsString(String value)
      Description copied from interface: I_CmsFormWidget
      Sets the current value of the widget as a string.

      Specified by:
      setFormValueAsString in interface I_CmsFormWidget
      Parameters:
      value - the new value of the widget
      See Also:
    • setHorizontalAlignment

      public void setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
      This is the alignment of the text in reference to the checkbox, possible values are left or right.

      Specified by:
      setHorizontalAlignment in interface com.google.gwt.user.client.ui.HasHorizontalAlignment
      See Also:
      • HasHorizontalAlignment.setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant)
    • setInternalValue

      public void setInternalValue(String value)
      Sets the internal value of this Checkbox.

      Parameters:
      value - the new internal value
    • setText

      public void setText(String text)
      Sets the text.

      Parameters:
      text - the text to set
    • fireValueChangedEvent

      protected void fireValueChangedEvent()
      Helper method for firing a 'value changed' event.