T
- the flavor to be appliedpublic class CheckboxBase<T extends Enum<T>> extends com.google.gwt.user.client.ui.ButtonBase implements HasRipple, com.google.gwt.user.client.ui.HasName, com.google.gwt.user.client.ui.HasValue<Boolean>, com.google.gwt.user.client.ui.HasWordWrap, com.google.gwt.user.client.ui.HasDirectionalSafeHtml, com.google.gwt.i18n.shared.HasDirectionEstimator, com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.client.LeafValueEditor<Boolean>>, IUpgrade
The material toggle is the material design alternative for check boxes and
radio buttons. The material toggle is as capable as the GWT CheckBox
.
It is important that the material toggle offers at least all the available
feature in the standard GWT Widget. To avoid re-inventing the wheel the
material toggle should ideally inherit or embed the original Widget.
Unfortunately, due to severe divergence in the DOM structure between the
material toggle and the GWT check box, this is not technically possible. As a
result, this class is a copy of the original CheckBox
Widget with
additional material related features.
CheckboxBase
re-implements the DOM structure needed to fit the mdl
structure and adds the material layer on top of it.
Modifier | Constructor and Description |
---|---|
protected |
CheckboxBase(com.google.gwt.dom.client.Element elem,
ToggleStyleOperator<T> paramToggle) |
|
CheckboxBase(com.google.gwt.safehtml.shared.SafeHtml label,
com.google.gwt.i18n.shared.DirectionEstimator directionEstimator,
ToggleStyleOperator<T> paramToggle)
Creates a check box with the specified text label.
|
|
CheckboxBase(com.google.gwt.safehtml.shared.SafeHtml label,
com.google.gwt.i18n.client.HasDirection.Direction dir,
ToggleStyleOperator<T> paramToggle)
Creates a check box with the specified text label.
|
|
CheckboxBase(com.google.gwt.safehtml.shared.SafeHtml label,
ToggleStyleOperator<T> paramToggle)
Creates a check box with the specified text label.
|
|
CheckboxBase(String label,
boolean asHTML,
ToggleStyleOperator<T> paramToggle)
Creates a check box with the specified text label.
|
|
CheckboxBase(String label,
com.google.gwt.i18n.shared.DirectionEstimator directionEstimator,
ToggleStyleOperator<T> paramToggle)
Creates a label with the specified text and a default direction estimator.
|
|
CheckboxBase(String label,
com.google.gwt.i18n.client.HasDirection.Direction dir,
ToggleStyleOperator<T> paramToggle)
Creates a check box with the specified text label.
|
|
CheckboxBase(String label,
ToggleStyleOperator<T> paramToggle)
Creates a check box with the specified text label.
|
|
CheckboxBase(ToggleStyleOperator<T> paramToggle)
Creates a check box with no label.
|
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Boolean> handler) |
com.google.gwt.editor.client.LeafValueEditor<Boolean> |
asEditor() |
protected void |
ensureDomEventHandlers() |
protected com.google.gwt.dom.client.LabelElement |
getContainer() |
com.google.gwt.i18n.shared.DirectionEstimator |
getDirectionEstimator() |
String |
getFormValue()
Returns the value property of the input element that backs this widget.
|
String |
getHTML() |
protected com.google.gwt.dom.client.InputElement |
getInput() |
protected com.google.gwt.dom.client.SpanElement |
getLabel() |
String |
getName() |
Ripple |
getRipple()
Returns whether this component have a ripple.
|
int |
getTabIndex() |
String |
getText() |
com.google.gwt.i18n.client.HasDirection.Direction |
getTextDirection() |
protected ToggleStyleOperator<T> |
getToggle() |
Boolean |
getValue()
Determines whether this check box is currently checked.
|
boolean |
getWordWrap() |
boolean |
isChecked()
Deprecated.
Use
getValue() instead |
boolean |
isEnabled() |
boolean |
isUpgraded() |
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.
|
protected void |
replaceInputElement(com.google.gwt.dom.client.Element elem)
Replace the current input element with a new one.
|
protected void |
replaceInputElement(com.google.gwt.user.client.Element elem)
Deprecated.
Call and use
replaceInputElement(Element)
instead. |
void |
setAccessKey(char key) |
void |
setChecked(boolean checked)
Deprecated.
Use
setValue(Boolean) instead |
void |
setDirectionEstimator(boolean enabled) |
void |
setDirectionEstimator(com.google.gwt.i18n.shared.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 |
setHTML(com.google.gwt.safehtml.shared.SafeHtml html,
com.google.gwt.i18n.client.HasDirection.Direction dir) |
void |
setHTML(String html) |
void |
setName(String name) |
void |
setRipple(Ripple inputRipple)
indicate whether this component should have a ripple.
|
void |
setTabIndex(int index) |
void |
setText(String text) |
void |
setText(String text,
com.google.gwt.i18n.client.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 |
upgrade()
Causes the component to be upgraded.
|
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
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
public CheckboxBase(ToggleStyleOperator<T> paramToggle)
paramToggle
- the material design selectorpublic CheckboxBase(com.google.gwt.safehtml.shared.SafeHtml label, ToggleStyleOperator<T> paramToggle)
label
- the check box's labelparamToggle
- the material design selectorpublic CheckboxBase(com.google.gwt.safehtml.shared.SafeHtml label, com.google.gwt.i18n.client.HasDirection.Direction dir, ToggleStyleOperator<T> paramToggle)
label
- the check box's labeldir
- the text's direction. Note that DEFAULT
means direction
should be inherited from the widget's parent element.paramToggle
- the material design selectorpublic CheckboxBase(com.google.gwt.safehtml.shared.SafeHtml label, com.google.gwt.i18n.shared.DirectionEstimator directionEstimator, ToggleStyleOperator<T> paramToggle)
label
- the check box's labeldirectionEstimator
- A DirectionEstimator object used for automatic direction
adjustment.paramToggle
- the design flavor selectorpublic CheckboxBase(String label, ToggleStyleOperator<T> paramToggle)
label
- the check box's labelparamToggle
- the design flavor selectorpublic CheckboxBase(String label, com.google.gwt.i18n.client.HasDirection.Direction dir, ToggleStyleOperator<T> paramToggle)
label
- the check box's labeldir
- the text's direction. Note that DEFAULT
means direction
should be inherited from the widget's parent element.paramToggle
- the material design selectorpublic CheckboxBase(String label, com.google.gwt.i18n.shared.DirectionEstimator directionEstimator, ToggleStyleOperator<T> paramToggle)
label
- the check box's labeldirectionEstimator
- A DirectionEstimator object used for automatic direction
adjustment.paramToggle
- the material design selectorpublic CheckboxBase(String label, boolean asHTML, ToggleStyleOperator<T> paramToggle)
label
- the check box's labelasHTML
- true
to treat the specified label as htmlparamToggle
- the material design selectorprotected CheckboxBase(com.google.gwt.dom.client.Element elem, ToggleStyleOperator<T> paramToggle)
elem
- the input elementparamToggle
- the material design selectorpublic final void setRipple(Ripple inputRipple)
HasRipple
public final Ripple getRipple()
HasRipple
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Boolean> handler)
addValueChangeHandler
in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<Boolean>
public com.google.gwt.editor.client.LeafValueEditor<Boolean> asEditor()
asEditor
in interface com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.client.LeafValueEditor<Boolean>>
public com.google.gwt.i18n.shared.DirectionEstimator getDirectionEstimator()
getDirectionEstimator
in interface com.google.gwt.i18n.shared.HasDirectionEstimator
public String getFormValue()
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.
public String getHTML()
getHTML
in interface com.google.gwt.user.client.ui.HasHTML
getHTML
in class com.google.gwt.user.client.ui.ButtonBase
public String getName()
getName
in interface com.google.gwt.user.client.ui.HasName
public int getTabIndex()
getTabIndex
in interface com.google.gwt.user.client.ui.Focusable
getTabIndex
in class com.google.gwt.user.client.ui.FocusWidget
public String getText()
getText
in interface com.google.gwt.user.client.ui.HasText
getText
in class com.google.gwt.user.client.ui.ButtonBase
public com.google.gwt.i18n.client.HasDirection.Direction getTextDirection()
getTextDirection
in interface com.google.gwt.user.client.ui.HasDirectionalText
public Boolean getValue()
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()
public boolean getWordWrap()
getWordWrap
in interface com.google.gwt.user.client.ui.HasWordWrap
@Deprecated public boolean isChecked()
getValue()
insteadtrue
if the check box is checkedpublic boolean isEnabled()
isEnabled
in interface com.google.gwt.user.client.ui.HasEnabled
isEnabled
in class com.google.gwt.user.client.ui.FocusWidget
public void setAccessKey(char key)
setAccessKey
in interface com.google.gwt.user.client.ui.Focusable
setAccessKey
in class com.google.gwt.user.client.ui.FocusWidget
@Deprecated public void setChecked(boolean checked)
setValue(Boolean)
insteadValueChangeEvent
.
(If you want the event to fire, use setValue(Boolean, boolean)
)checked
- true
to check the check box.public void setDirectionEstimator(boolean enabled)
See note at setDirectionEstimator(DirectionEstimator)
.
setDirectionEstimator
in interface com.google.gwt.i18n.shared.HasDirectionEstimator
public void setDirectionEstimator(com.google.gwt.i18n.shared.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.
setDirectionEstimator
in interface com.google.gwt.i18n.shared.HasDirectionEstimator
public void setEnabled(boolean enabled)
setEnabled
in interface com.google.gwt.user.client.ui.HasEnabled
setEnabled
in class com.google.gwt.user.client.ui.FocusWidget
public void setFocus(boolean focused)
setFocus
in interface com.google.gwt.user.client.ui.Focusable
setFocus
in class com.google.gwt.user.client.ui.FocusWidget
public void setFormValue(String value)
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.
value
- the value transmitted to the serverpublic void setHTML(com.google.gwt.safehtml.shared.SafeHtml html, com.google.gwt.i18n.client.HasDirection.Direction dir)
setHTML
in interface com.google.gwt.user.client.ui.HasDirectionalSafeHtml
public void setHTML(String html)
setHTML
in interface com.google.gwt.user.client.ui.HasHTML
setHTML
in class com.google.gwt.user.client.ui.ButtonBase
public void setName(String name)
setName
in interface com.google.gwt.user.client.ui.HasName
public void setTabIndex(int index)
setTabIndex
in interface com.google.gwt.user.client.ui.Focusable
setTabIndex
in class com.google.gwt.user.client.ui.FocusWidget
public void setText(String text)
setText
in interface com.google.gwt.user.client.ui.HasText
setText
in class com.google.gwt.user.client.ui.ButtonBase
public void setText(String text, com.google.gwt.i18n.client.HasDirection.Direction dir)
setText
in interface com.google.gwt.user.client.ui.HasDirectionalText
public void setValue(Boolean value)
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)
public void setValue(Boolean value, boolean fireEvents)
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)
setValue
in interface com.google.gwt.user.client.ui.HasValue<Boolean>
value
- true to check, false to uncheck; null value implies falsefireEvents
- If true, and value has changed, fire a ValueChangeEvent
public void setWordWrap(boolean wrap)
setWordWrap
in interface com.google.gwt.user.client.ui.HasWordWrap
public void upgrade()
IUpgrade
public boolean isUpgraded()
isUpgraded
in interface IUpgrade
protected void ensureDomEventHandlers()
protected void onEnsureDebugId(String baseID)
onEnsureDebugId
in class com.google.gwt.user.client.ui.UIObject
UIObject.onEnsureDebugId(String)
protected void onLoad()
Widget.onAttach()
to preserve the onAttach
contract.onLoad
in class com.google.gwt.user.client.ui.Widget
protected void onUnload()
inputElem
.onUnload
in class com.google.gwt.user.client.ui.Widget
protected void replaceInputElement(com.google.gwt.dom.client.Element elem)
RadioButton.setName(java.lang.String)
.)elem
- the new input element@Deprecated protected void replaceInputElement(com.google.gwt.user.client.Element elem)
replaceInputElement(Element)
instead.elem
- the new element that will replace the current elementprotected ToggleStyleOperator<T> getToggle()
protected com.google.gwt.dom.client.LabelElement getContainer()
protected com.google.gwt.dom.client.InputElement getInput()
protected com.google.gwt.dom.client.SpanElement getLabel()
Copyright © 2016 com.github.ilyes4j. All rights reserved.