com.github.gwtbootstrap.client.ui
Class CheckBox

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.FocusWidget
              extended by com.google.gwt.user.client.ui.ButtonBase
                  extended by com.github.gwtbootstrap.client.ui.CheckBox
All Implemented Interfaces:
HasId, HasStyle, IsResponsive, IsSearchQuery, IsEditor<LeafValueEditor<Boolean>>, HasAllDragAndDropHandlers, HasAllFocusHandlers, HasAllGestureHandlers, HasAllKeyHandlers, HasAllMouseHandlers, HasAllTouchHandlers, HasBlurHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragEndHandlers, HasDragEnterHandlers, HasDragHandlers, HasDragLeaveHandlers, HasDragOverHandlers, HasDragStartHandlers, HasDropHandlers, HasFocusHandlers, HasGestureChangeHandlers, HasGestureEndHandlers, HasGestureStartHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasTouchCancelHandlers, HasTouchEndHandlers, HasTouchMoveHandlers, HasTouchStartHandlers, HasAttachHandlers, HasValueChangeHandlers<Boolean>, HasHandlers, HasDirectionEstimator, HasSafeHtml, EventListener, TakesValue<Boolean>, Focusable, HasDirectionalSafeHtml, HasDirectionalText, HasEnabled, HasFocus, HasHTML, HasName, HasText, HasValue<Boolean>, HasVisibility, HasWordWrap, IsWidget, SourcesClickEvents, SourcesFocusEvents, SourcesKeyboardEvents, SourcesMouseEvents
Direct Known Subclasses:
RadioButton

public class CheckBox
extends ButtonBase
implements HasName, HasValue<Boolean>, HasWordWrap, HasDirectionalSafeHtml, HasDirectionEstimator, IsEditor<LeafValueEditor<Boolean>>, IsSearchQuery, HasId, IsResponsive, HasStyle

CheckBox widgets.

Re-design for Bootstrap.

Since:
2.0.4.0
Author:
ohashi keisuke

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
static DirectionEstimator DEFAULT_DIRECTION_ESTIMATOR
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
  CheckBox()
          Creates a check box with no label.
protected CheckBox(Element elem)
           
  CheckBox(SafeHtml label)
          Creates a check box with the specified text label.
  CheckBox(SafeHtml label, DirectionEstimator directionEstimator)
          Creates a check box with the specified text label.
  CheckBox(SafeHtml label, HasDirection.Direction dir)
          Creates a check box with the specified text label.
  CheckBox(String label)
          Creates a check box with the specified text label.
  CheckBox(String label, boolean asHTML)
          Creates a check box with the specified text label.
  CheckBox(String label, DirectionEstimator directionEstimator)
          Creates a label with the specified text and a default direction estimator.
  CheckBox(String label, HasDirection.Direction dir)
          Creates a check box with the specified text label.
 
Method Summary
 void addStyle(Style style)
          Adds the provided style to the widget.
 HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
           
 LeafValueEditor<Boolean> asEditor()
           
protected  LabelElement asLabel()
           
protected  void ensureDomEventHandlers()
           
 DirectionEstimator getDirectionEstimator()
           
 String getFormValue()
          Returns the value property of the input element that backs this widget.
 String getHTML()
           
 String getId()
          Get ID
 String getName()
           
 int getTabIndex()
           
 String getText()
           
 HasDirection.Direction getTextDirection()
           
 Boolean getValue()
          Determines whether this check box is currently checked.
 boolean getWordWrap()
           
 boolean isChecked()
          Deprecated. Use getValue() instead
 boolean isEnabled()
           
 boolean isSearchQuery()
          is the element search-query style?
protected  void onEnsureDebugId(String baseID)
          Affected Elements: -label = label next to checkbox.
protected  void onLoad()
          This method is called when a widget is attached to the browser's document.
protected  void onUnload()
          This method is called when a widget is detached from the browser's document.
 void removeStyle(Style style)
          Removes the provided style from the widget.
protected  void replaceInputElement(Element elem)
          Replace the current input element with a new one.
 void setAccessKey(char key)
           
 void setChecked(boolean checked)
          Deprecated. Use setValue(Boolean) instead
 void setDirectionEstimator(boolean enabled)
          
 void setDirectionEstimator(DirectionEstimator directionEstimator)
          
 void setEnabled(boolean enabled)
           
 void setFocus(boolean focused)
           
 void setFormValue(String value)
          Set the value property on the input element that backs this widget.
 void setHideOn(Device device)
          Sets the kind of device, this widget is hidden on.
 void setHTML(SafeHtml html, HasDirection.Direction dir)
           
 void setHTML(String html)
           
 void setId(String id)
          Set ID
 void setInline(boolean inline)
           
 void setName(String name)
           
 void setSearchQuery(boolean searchQuery)
          Set search-query style to the element.
 void setShowOn(Device device)
          Sets the kind of device, this widget is shown on.
 void setStyle(Style style)
          Replaces the widet's style with the provided one.
 void setTabIndex(int index)
           
 void setText(String text)
           
 void setText(String text, HasDirection.Direction dir)
           
 void setValue(Boolean value)
          Checks or unchecks the check box.
 void setValue(Boolean value, boolean fireEvents)
          Checks or unchecks the check box, firing ValueChangeEvent if appropriate.
 void setWordWrap(boolean wrap)
           
 void sinkEvents(int eventBitsToAdd)
           
 
Methods inherited from class com.google.gwt.user.client.ui.ButtonBase
setHTML
 
Methods inherited from class com.google.gwt.user.client.ui.FocusWidget
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener
 
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, isAttached, isOrWasAttached, onBrowserEvent, onDetach, removeFromParent, setLayoutData
 
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, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
 
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
 
Methods inherited from interface com.google.gwt.safehtml.client.HasSafeHtml
setHTML
 

Field Detail

DEFAULT_DIRECTION_ESTIMATOR

public static final DirectionEstimator DEFAULT_DIRECTION_ESTIMATOR
Constructor Detail

CheckBox

public CheckBox()
Creates a check box with no label.


CheckBox

public CheckBox(SafeHtml label)
Creates a check box with the specified text label.

Parameters:
label - the check box's label

CheckBox

public CheckBox(SafeHtml label,
                HasDirection.Direction dir)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
dir - the text's direction. Note that DEFAULT means direction should be inherited from the widget's parent element.

CheckBox

public CheckBox(SafeHtml label,
                DirectionEstimator directionEstimator)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.

CheckBox

public CheckBox(String label)
Creates a check box with the specified text label.

Parameters:
label - the check box's label

CheckBox

public CheckBox(String label,
                HasDirection.Direction dir)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
dir - the text's direction. Note that DEFAULT means direction should be inherited from the widget's parent element.

CheckBox

public CheckBox(String label,
                DirectionEstimator directionEstimator)
Creates a label with the specified text and a default direction estimator.

Parameters:
label - the check box's label
directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.

CheckBox

public CheckBox(String label,
                boolean asHTML)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
asHTML - true to treat the specified label as html

CheckBox

protected CheckBox(Element elem)
Method Detail

addValueChangeHandler

public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
Specified by:
addValueChangeHandler in interface HasValueChangeHandlers<Boolean>

asEditor

public LeafValueEditor<Boolean> asEditor()
Specified by:
asEditor in interface IsEditor<LeafValueEditor<Boolean>>

getDirectionEstimator

public DirectionEstimator getDirectionEstimator()
Specified by:
getDirectionEstimator in interface HasDirectionEstimator

getFormValue

public String getFormValue()
Returns the value property of the input element that backs this widget. This is the value that will be associated with the CheckBox name and submitted to the server if a FormPanel that holds it is submitted and the box is checked.

Don't confuse this with getValue(), which returns true or false if the widget is checked.


getHTML

public String getHTML()
Specified by:
getHTML in interface HasHTML
Overrides:
getHTML in class ButtonBase

getName

public String getName()
Specified by:
getName in interface HasName

getTabIndex

public int getTabIndex()
Specified by:
getTabIndex in interface Focusable
Overrides:
getTabIndex in class FocusWidget

getText

public String getText()
Specified by:
getText in interface HasText
Overrides:
getText in class ButtonBase

getTextDirection

public HasDirection.Direction getTextDirection()
Specified by:
getTextDirection in interface HasDirectionalText

getValue

public Boolean getValue()
Determines whether this check box is currently checked.

Note that this does not return the value property of the checkbox input element wrapped by this widget. For access to that property, see getFormValue()

Specified by:
getValue in interface TakesValue<Boolean>
Specified by:
getValue in interface HasValue<Boolean>
Returns:
true if the check box is checked, false otherwise. Will not return null

getWordWrap

public boolean getWordWrap()
Specified by:
getWordWrap in interface HasWordWrap

isChecked

@Deprecated
public boolean isChecked()
Deprecated. Use getValue() instead

Determines whether this check box is currently checked.

Returns:
true if the check box is checked

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface HasEnabled
Overrides:
isEnabled in class FocusWidget

setAccessKey

public void setAccessKey(char key)
Specified by:
setAccessKey in interface Focusable
Overrides:
setAccessKey in class FocusWidget

setChecked

@Deprecated
public void setChecked(boolean checked)
Deprecated. Use setValue(Boolean) instead

Checks or unchecks this check box. Does not fire ValueChangeEvent . (If you want the event to fire, use setValue(Boolean, boolean) )

Parameters:
checked - true to check the check box.

setDirectionEstimator

public void setDirectionEstimator(boolean enabled)

See note at setDirectionEstimator(DirectionEstimator).

Specified by:
setDirectionEstimator in interface HasDirectionEstimator

setDirectionEstimator

public void setDirectionEstimator(DirectionEstimator directionEstimator)

Note: DirectionEstimator should be set before the label has any content; it's highly recommended to set it using a constructor. Reason: if the label already has non-empty content, this will update its direction according to the new estimator's result. This may cause flicker, and thus should be avoided.

Specified by:
setDirectionEstimator in interface HasDirectionEstimator

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface HasEnabled
Overrides:
setEnabled in class FocusWidget

setFocus

public void setFocus(boolean focused)
Specified by:
setFocus in interface Focusable
Overrides:
setFocus in class FocusWidget

setFormValue

public void setFormValue(String value)
Set the value property on the input element that backs this widget. This is the value that will be associated with the CheckBox's name and submitted to the server if a FormPanel that holds it is submitted and the box is checked.

Don't confuse this with setValue(java.lang.Boolean), which actually checks and unchecks the box.

Parameters:
value -

setHTML

public void setHTML(SafeHtml html,
                    HasDirection.Direction dir)
Specified by:
setHTML in interface HasDirectionalSafeHtml

setHTML

public void setHTML(String html)
Specified by:
setHTML in interface HasHTML
Overrides:
setHTML in class ButtonBase

setName

public void setName(String name)
Specified by:
setName in interface HasName

setTabIndex

public void setTabIndex(int index)
Specified by:
setTabIndex in interface Focusable
Overrides:
setTabIndex in class FocusWidget

setText

public void setText(String text)
Specified by:
setText in interface HasText
Overrides:
setText in class ButtonBase

setText

public void setText(String text,
                    HasDirection.Direction dir)
Specified by:
setText in interface HasDirectionalText

setValue

public void setValue(Boolean value)
Checks or unchecks the check box.

Note that this does not set the value property of the checkbox input element wrapped by this widget. For access to that property, see setFormValue(String)

Specified by:
setValue in interface TakesValue<Boolean>
Specified by:
setValue in interface HasValue<Boolean>
Parameters:
value - true to check, false to uncheck; null value implies false

setValue

public void setValue(Boolean value,
                     boolean fireEvents)
Checks or unchecks the check box, firing ValueChangeEvent if appropriate.

Note that this does not set the value property of the checkbox input element wrapped by this widget. For access to that property, see setFormValue(String)

Specified by:
setValue in interface HasValue<Boolean>
Parameters:
value - true to check, false to uncheck; null value implies false
fireEvents - If true, and value has changed, fire a ValueChangeEvent

setWordWrap

public void setWordWrap(boolean wrap)
Specified by:
setWordWrap in interface HasWordWrap

sinkEvents

public void sinkEvents(int eventBitsToAdd)
Overrides:
sinkEvents in class Widget

ensureDomEventHandlers

protected void ensureDomEventHandlers()

onEnsureDebugId

protected void onEnsureDebugId(String baseID)
Affected Elements:

Overrides:
onEnsureDebugId in class UIObject
See Also:
UIObject.onEnsureDebugId(String)

onLoad

protected void onLoad()
This method is called when a widget is attached to the browser's document. onAttach needs special handling for the CheckBox case. Must still call Widget.onAttach() to preserve the onAttach contract.

Overrides:
onLoad in class Widget

onUnload

protected void onUnload()
This method is called when a widget is detached from the browser's document. Overridden because of IE bug that throws away checked state and in order to clear the event listener off of the inputElem.

Overrides:
onUnload in class Widget

replaceInputElement

protected void replaceInputElement(Element elem)
Replace the current input element with a new one. Preserves all state except for the name property, for nasty reasons related to radio button grouping. (See implementation of RadioButton.setName(java.lang.String).)

Parameters:
elem - the new input element

asLabel

protected LabelElement asLabel()

setInline

public void setInline(boolean inline)

setSearchQuery

public void setSearchQuery(boolean searchQuery)
Set search-query style to the element.

Specified by:
setSearchQuery in interface IsSearchQuery
Parameters:
searchQuery - true:add search-query css-class/false:remove search-query css-class

isSearchQuery

public boolean isSearchQuery()
is the element search-query style?

Specified by:
isSearchQuery in interface IsSearchQuery
Returns:
true:has search-query css-class/false:has no search-query cass-class.

getId

public String getId()
Get ID

Specified by:
getId in interface HasId
Returns:
ID

setId

public void setId(String id)
Set ID

Specified by:
setId in interface HasId
Parameters:
id - set id

setShowOn

public void setShowOn(Device device)
Sets the kind of device, this widget is shown on.

The widget is not shown on any other device.

Only works if responsive design is turned on!

Specified by:
setShowOn in interface IsResponsive
See Also:
Configurator.hasResponsiveDesign(), IsResponsive.setHideOn(Device)

setHideOn

public void setHideOn(Device device)
Sets the kind of device, this widget is hidden on.

The widget is not hidden on any other device.

Only works if responsive design is turned on!

Specified by:
setHideOn in interface IsResponsive
See Also:
Configurator.hasResponsiveDesign(), IsResponsive.setShowOn(Device)

setStyle

public void setStyle(Style style)
Replaces the widet's style with the provided one.

Specified by:
setStyle in interface HasStyle
Parameters:
style - the style to be applied to the Widget.

addStyle

public void addStyle(Style style)
Adds the provided style to the widget.

Specified by:
addStyle in interface HasStyle
Parameters:
style - the style to be added to the Widget.

removeStyle

public void removeStyle(Style style)
Removes the provided style from the widget.

Specified by:
removeStyle in interface HasStyle
Parameters:
style - the style to be removed from the Widget.


Copyright © 2012 gwtbootstrap. All Rights Reserved.