T
- the face options to choose frompublic abstract class ToggleStyleOperator<T extends Enum<T>> extends Object implements HasRipple, IToggleFace<T>, IUpgrade
This class encapsulates the material side of toggle-based components. It only
handles the material design styling of the toggle. Unfortunately, the
standard GWT CheckBox
internal structure is not flexible enough to
accept the material styling. To build a fully functional material toggle, a
Widget
component must be implemented that provides the same features
found in CheckBox
while being structurally ready to support the
material design. This widget would be responsible for building the DOM
structure and wiring the events while ToggleStyleOperator
adds the
material look and feel by applying the appropriate CSS classes and behaviors
to that component.
To easily switch between faces. ToggleStyleOperator
is a generic
class using an enumeration as a parameter. The parameter represents the face
options that the toggle can choose from.
Under the hood, a set of CssSwitcher
s manages the switching between
faces. Each CssSwitcher
is responsible for the state of an element in
the toggle. When the user sets a face for the toggle, the call is delegated
to setFace(Enum)
which in itself calls the
CssSwitcher.setValue(Enum)
for each part of the toggle.
Constructor and Description |
---|
ToggleStyleOperator(CssSwitcher<T> switchCtnr,
CssSwitcher<T> switchInput,
CssSwitcher<T> switchlabel)
Make an instance of the style operator by providing the
CssSwitcher
set to be used to manage the CSS of the component. |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
defaultFlavor()
The sub-type must indicate the default class pack (= face) to enable the
component to be initialized correctly by applying at least the default face
for the first time.
|
T |
getFace() |
Ripple |
getRipple()
Returns whether this component have a ripple.
|
boolean |
isUpgraded() |
void |
setEnabled(boolean enable)
Sets whether the toggle is enabled.
|
void |
setFace(T flavor)
Setting a face for the toggle implies assigning a set of classes to the top
level element, the input element and the label element.
|
void |
setRipple(Ripple inputRipple)
indicate whether this component should have a ripple.
|
void |
setTarget(com.google.gwt.dom.client.Element eltCtnr,
com.google.gwt.dom.client.Element eltInput,
com.google.gwt.dom.client.Element eltLabel)
Set the elements of the toggle on which the CSS classes will be applied to
set the material look.
|
void |
setValue(boolean check)
Sets whether the toggle is checked.
|
void |
upgrade()
Causes the component to be upgraded.
|
public ToggleStyleOperator(CssSwitcher<T> switchCtnr, CssSwitcher<T> switchInput, CssSwitcher<T> switchlabel)
CssSwitcher
set to be used to manage the CSS of the component.switchCtnr
- the container CSS managerswitchInput
- the input CSS managerswitchlabel
- the label CSS managerpublic final void setTarget(com.google.gwt.dom.client.Element eltCtnr, com.google.gwt.dom.client.Element eltInput, com.google.gwt.dom.client.Element eltLabel)
eltCtnr
- the upper level elementeltInput
- the input elementeltLabel
- the label elementpublic void setEnabled(boolean enable)
enable
- the new state of the togglepublic void setValue(boolean check)
check
- the new state of the toggle checkprotected abstract T defaultFlavor()
public void setFace(T flavor)
setFace
in interface IToggleFace<T extends Enum<T>>
flavor
- the toggle flavor to be applied.public T getFace()
getFace
in interface IToggleFace<T extends Enum<T>>
public final void setRipple(Ripple inputRipple)
HasRipple
public final Ripple getRipple()
HasRipple
public void upgrade()
IUpgrade
public boolean isUpgraded()
isUpgraded
in interface IUpgrade
Copyright © 2016 com.github.ilyes4j. All rights reserved.