Module io.github.mmm.ui.tvm.core
Class TvmInput<V,W extends org.teavm.jso.dom.html.HTMLElement>
- java.lang.Object
-
- io.github.mmm.ui.api.widget.AbstractUiWidget
-
- io.github.mmm.ui.spi.widget.AbstractUiNativeWidget
-
- io.github.mmm.ui.spi.widget.AbstractUiNativeWidgetWrapper<W>
-
- io.github.mmm.ui.tvm.widget.TvmWidget<W>
-
- io.github.mmm.ui.tvm.widget.TvmWidgetHtmlElement<W>
-
- io.github.mmm.ui.tvm.widget.TvmActiveWidget<W>
-
- io.github.mmm.ui.tvm.widget.input.TvmInput<V,W>
-
- Type Parameters:
W
- type ofTeaVM widget
.V
- type ofvalue
.
- All Implemented Interfaces:
EventSource<UiEvent,UiEventListener>
,AttributeReadEnabled
,AttributeReadId
,AttributeReadValid
,AttributeReadValue<V>
,AttributeReadVisible
,AttributeWriteAutocomplete
,AttributeWriteEnabled
,AttributeWriteId
,AttributeWritePrefix
,AttributeWriteReadOnly
,AttributeWriteSuffix
,AttributeWriteTooltip
,AttributeWriteValidationFailure
,AttributeWriteValue<V>
,AttributeWriteValueForUser<V>
,AttributeWriteVisible
,UiAbstractInput<V>
,UiInput<V>
,UiActiveWidget
,UiNativeWidget
,UiRegularWidget
,UiWidget
,UiValidatableWidget<V>
,UiValuedWidget<V>
,UiNativeWidgetWrapper<W>
- Direct Known Subclasses:
TvmAbstractTextArea
,TvmHtmlInput
,TvmHtmlSelect
,TvmRadioChoice
public abstract class TvmInput<V,W extends org.teavm.jso.dom.html.HTMLElement> extends TvmActiveWidget<W> implements UiInput<V>, AttributeWriteAutocomplete
Implementation ofUiInput
using TeaVM.- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from class io.github.mmm.ui.tvm.widget.TvmWidget
ATR_ARIA_HIDDEN, ATR_ARIA_LABEL, ATR_ARIA_SELECTED, ATR_COLSPAN, ATR_FOR, ATR_ID, ATR_LIST, ATR_MAX, ATR_MIN, ATR_REQUIRED, ATR_ROLE, ATR_ROWSPAN, ATR_STYLE, ATR_TABINDEX, CLASS_COLLAPSE, CLASS_ERROR, CLASS_EXPAND, CLASS_INFO, CLASS_QUESTION, CLASS_WARNING, DOC, EVENT_TYPE_BLUR, EVENT_TYPE_CHANGE, EVENT_TYPE_CLICK, EVENT_TYPE_FOCUS, EVENT_TYPE_INPUT, EVENT_TYPE_KEYDOWN, EVENT_TYPE_POINTERDOWN, EVENT_TYPE_POINTERMOVE, EVENT_TYPE_POINTERUP, ROLE_PRESENTATION, STYLE_COLLAPSED, STYLE_COLLAPSIBLE, STYLE_DISABLED, STYLE_RESIZABLE, TAG_NAME_UI_ICON, widget
-
Fields inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteAutocomplete
AUTOCOMPLETE_BIRTHDAY, AUTOCOMPLETE_CC_CSC, AUTOCOMPLETE_CC_EXPIRY, AUTOCOMPLETE_CC_NUMBER, AUTOCOMPLETE_CC_TYPE, AUTOCOMPLETE_COUNTRY_CODE, AUTOCOMPLETE_COUNTRY_NAME, AUTOCOMPLETE_CURRENT_PASSWORD, AUTOCOMPLETE_EMAIL, AUTOCOMPLETE_FAMILY_NAME, AUTOCOMPLETE_GIVEN_NAME, AUTOCOMPLETE_HONORIFIC_PREFIX, AUTOCOMPLETE_IMPP, AUTOCOMPLETE_JOB_TITLE, AUTOCOMPLETE_LANGUAGE_CODE, AUTOCOMPLETE_NEW_PASSWORD, AUTOCOMPLETE_NICKNAME, AUTOCOMPLETE_OFF, AUTOCOMPLETE_ORGANIZATION, AUTOCOMPLETE_POSTAL_CODE, AUTOCOMPLETE_SEX, AUTOCOMPLETE_STREET, AUTOCOMPLETE_TELEPHONE, AUTOCOMPLETE_TX_AMOUNT, AUTOCOMPLETE_TX_CURRENCY, AUTOCOMPLETE_URL, AUTOCOMPLETE_USERNAME
-
Fields inherited from interface io.github.mmm.ui.api.attribute.AttributeWritePrefix
STYLE_PREFIX, STYLE_WITH_PREFIX
-
Fields inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteSuffix
STYLE_SUFFIX, STYLE_WITH_SUFFIX
-
Fields inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteValidationFailure
STYLE_INVALID
-
Fields inherited from interface io.github.mmm.ui.api.widget.UiActiveWidget
ACCESS_KEY_NONE
-
Fields inherited from interface io.github.mmm.ui.api.widget.input.UiInput
STYLE_INPUT
-
Fields inherited from interface io.github.mmm.ui.api.widget.value.UiValidatableWidget
STYLE_MANDATORY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getAutocomplete()
UiRegularWidget
getContainerWidget()
org.teavm.jso.dom.html.HTMLElement
getHPanel()
long
getModificationTimestamp()
String
getName()
TvmLabel
getNameWidget()
V
getOriginalValue()
String
getPrefix()
protected org.teavm.jso.dom.html.HTMLElement
getPrefixLabel()
String
getSuffix()
protected org.teavm.jso.dom.html.HTMLElement
getSuffixLabel()
org.teavm.jso.dom.html.HTMLElement
getTopWidget()
Validator<? super V>
getValidator()
boolean
hasContainerWidget()
boolean
hasNameWidget()
protected void
initHPanel(org.teavm.jso.dom.html.HTMLElement panel)
protected void
onChange(org.teavm.jso.dom.events.Event event)
protected void
onFocusLoss(org.teavm.jso.dom.events.Event event)
protected void
registerHandlers()
Registers the according handlers to the underlying native widget.void
setAutocomplete(String autocomplete)
protected void
setIdNative(String id)
protected void
setMandatory(boolean mandatory)
void
setName(String name)
void
setOriginalValue(V originalValue)
void
setPrefix(String prefix)
void
setSuffix(String suffix)
void
setValidator(Validator<? super V> validator)
void
setValue(V value, boolean forUser)
protected abstract void
setValueNative(V value)
void
setVisible(boolean visible, BitMask flagMode)
-
Methods inherited from class io.github.mmm.ui.tvm.widget.TvmActiveWidget
getAccessKey, isFocused, onFocusGain, setAccessKey, setEnabledNative, setFocused, setParent
-
Methods inherited from class io.github.mmm.ui.tvm.widget.TvmWidgetHtmlElement
getElement, onStylesChanged, setTooltipNative, setVisibleNative
-
Methods inherited from class io.github.mmm.ui.tvm.widget.TvmWidget
getTopNode, getWidget, insertAt, insertFirst, newAnchor, newASide, newAudio, newButton, newCanvas, newDatalist, newDiv, newElement, newFieldSet, newFooter, newForm, newHeader, newHr, newIcon, newImage, newInput, newInput, newLabel, newLegend, newLi, newMain, newNav, newOption, newOption, newOutput, newSection, newSelect, newSpan, newTable, newTableBody, newTableDataCell, newTableFoot, newTableHead, newTableHeaderCell, newTableRow, newTextArea, newUl, newVideo, onClick, removeAllChildren, setReadOnlyNative, setWidget
-
Methods inherited from class io.github.mmm.ui.spi.widget.AbstractUiNativeWidgetWrapper
createDefaultStyles, createStyles, getId, getStyles, getTooltip, setId, setTooltip
-
Methods inherited from class io.github.mmm.ui.spi.widget.AbstractUiNativeWidget
addListener, dispose, doDispose, doGetEnabledState, doGetVisibleState, doSetEnabledState, doSetEnabledState, doSetValidationFailure, doSetVisibleState, doSetVisibleState, ensureHandlers, fireEvent, getEventAdapter, getParent, getProgrammaticEventType, getReadOnlyFixed, getValidationFailure, hasListeners, isDisposed, isEnabled, isInitiallyVisible, isReadOnly, isValid, isVisible, isVisibleWithoutRoot, removeListener, requireNotDisposed, setEnabled, setProgrammaticEventType, setReadOnly, setReadOnlyFixed, setValidationFailure, unwrap, validateDown
-
Methods inherited from class io.github.mmm.ui.api.widget.AbstractUiWidget
isEmpty, setParent, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeReadId
getId
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteAutocomplete
setAutocompleteOff
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteId
setId
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteTooltip
getTooltip, setTooltip
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteValidationFailure
getValidationFailure, setValidationFailure, setValidationFailure
-
Methods inherited from interface io.github.mmm.event.EventSource
addListener, addListener, addWeakListener, removeListener
-
Methods inherited from interface io.github.mmm.ui.api.widget.value.UiValidatableWidget
getValue, getValueOrThrow, isValid, reset, setValue, setValueForUser
-
Methods inherited from interface io.github.mmm.ui.api.widget.UiWidget
cast, dispose, getParent, getReadOnlyFixed, getStyles, isDisposed, isEnabled, isEnabled, isFocused, isModified, isReadOnly, isVisible, isVisible, setEnabled, setEnabled, setFocused, setReadOnly, setReadOnlyFixed, setVisible, validate, validate, validate, validateDown, validateUp
-
-
-
-
Constructor Detail
-
TvmInput
public TvmInput(W widget)
The constructor.- Parameters:
widget
- theTeaVM widget
.
-
-
Method Detail
-
registerHandlers
protected void registerHandlers()
Description copied from class:AbstractUiNativeWidget
Registers the according handlers to the underlying native widget. Never call manually, only viaAbstractUiNativeWidget.ensureHandlers()
.- Overrides:
registerHandlers
in classTvmActiveWidget<W extends org.teavm.jso.dom.html.HTMLElement>
-
onChange
protected void onChange(org.teavm.jso.dom.events.Event event)
- Parameters:
event
- the inputEvent
.
-
getTopWidget
public org.teavm.jso.dom.html.HTMLElement getTopWidget()
- Specified by:
getTopWidget
in interfaceUiNativeWidgetWrapper<V>
- Overrides:
getTopWidget
in classTvmWidgetHtmlElement<W extends org.teavm.jso.dom.html.HTMLElement>
- Returns:
- the top-level native widget of this wrapper. In many cases this is the same as
UiNativeWidgetWrapper.getWidget()
but in some cases this may be some kind of internal composite containing themain widget
.
-
getHPanel
public org.teavm.jso.dom.html.HTMLElement getHPanel()
- Returns:
- the
HTMLElement
used astop widget
. Will be lazily initialized on the first call of this method.
-
initHPanel
protected void initHPanel(org.teavm.jso.dom.html.HTMLElement panel)
- Parameters:
panel
- theHTMLElement
used astop widget
.
-
getName
public String getName()
- Specified by:
getName
in interfaceUiAbstractInput<V>
- Returns:
- the
label text
for thename widget
or the title of the form group.
-
setName
public void setName(String name)
- Specified by:
setName
in interfaceUiAbstractInput<V>
- Parameters:
name
- the newname
. Prevents lazy initialization of thename widget
.
-
setIdNative
protected void setIdNative(String id)
- Overrides:
setIdNative
in classTvmWidget<W extends org.teavm.jso.dom.html.HTMLElement>
- Parameters:
id
- the newID
.
-
hasNameWidget
public boolean hasNameWidget()
- Specified by:
hasNameWidget
in interfaceUiInput<V>
- Returns:
true
if thename widget
has already been created,false
otherwise. Helpful to avoid unintended lazy initialization.
-
getNameWidget
public TvmLabel getNameWidget()
- Specified by:
getNameWidget
in interfaceUiInput<V>
- Returns:
- the
UiLabel
of this input. May be lazily created on the first call of this method to avoid unnecessary overhead (e.g. if aUiInput
is used for inline editing).
-
hasContainerWidget
public boolean hasContainerWidget()
- Specified by:
hasContainerWidget
in interfaceUiInput<V>
- Returns:
true
if thecontainer widget
has already been created,false
otherwise. Helpful to avoid unintended lazy initialization.
-
getContainerWidget
public UiRegularWidget getContainerWidget()
- Specified by:
getContainerWidget
in interfaceUiInput<V>
- Returns:
- the
UiRegularWidget
containing both thename widget
and the actual input widget. Will be lazily created on the first call of this method.
-
getPrefix
public String getPrefix()
- Specified by:
getPrefix
in interfaceAttributeWritePrefix
- Returns:
- the optional prefix text shown in front of the actual input (e.g. for a currency like $ or £). Will be
null
if not set.
-
setPrefix
public void setPrefix(String prefix)
- Specified by:
setPrefix
in interfaceAttributeWritePrefix
- Parameters:
prefix
- the newprefix
.
-
getPrefixLabel
protected org.teavm.jso.dom.html.HTMLElement getPrefixLabel()
- Returns:
- the
HTMLElement
for theprefix
.
-
getSuffix
public String getSuffix()
- Specified by:
getSuffix
in interfaceAttributeWriteSuffix
- Returns:
- the optional suffix text shown after of the actual input (e.g. for a unit, currencies like €, etc.). Will
be
null
if not set.
-
setSuffix
public void setSuffix(String suffix)
- Specified by:
setSuffix
in interfaceAttributeWriteSuffix
- Parameters:
suffix
- the newsuffix
.
-
getSuffixLabel
protected org.teavm.jso.dom.html.HTMLElement getSuffixLabel()
- Returns:
- the
HTMLElement
for thesuffix
.
-
setVisible
public void setVisible(boolean visible, BitMask flagMode)
- Specified by:
setVisible
in interfaceUiWidget
- Overrides:
setVisible
in classAbstractUiNativeWidget
- Parameters:
visible
-true
to show this widget (in case its parent is also visible),false
to hide this widget.flagMode
- theBitMask
to apply. SeeUiVisibleFlags
for available options.- See Also:
UiWidget.isVisible()
-
getOriginalValue
public V getOriginalValue()
- Specified by:
getOriginalValue
in interfaceUiValidatableWidget<V>
- Returns:
- the original value since it was last set via
UiValidatableWidget.setOriginalValue(Object)
or most probably indirectly viaUiValidatableWidget.setValue(Object)
. If this widget ismodified
,UiValidatableWidget.getValue()
will return the current value as entered by the end-user while this method will still return the original value.
ATTENTION: The original value shall never be modified to avoid undesired side effects. Various features such asUiValidatableWidget.reset()
rely on this fact. - See Also:
UiValidatableWidget.reset()
-
setOriginalValue
public void setOriginalValue(V originalValue)
- Specified by:
setOriginalValue
in interfaceUiValidatableWidget<V>
- Parameters:
originalValue
- the new value ofUiValidatableWidget.getOriginalValue()
.
-
getValidator
public Validator<? super V> getValidator()
- Specified by:
getValidator
in interfaceUiValidatableWidget<V>
- Returns:
- the
Validator
to validate thevalue
of this input.
-
setValidator
public void setValidator(Validator<? super V> validator)
- Specified by:
setValidator
in interfaceUiValidatableWidget<V>
- Parameters:
validator
- the newvalidator
. To add multiple validators, simply useComposedValidator
orValidator.append(Validator...)
.
-
setMandatory
protected void setMandatory(boolean mandatory)
- Parameters:
mandatory
- the new mandatory (required) flag.
-
getModificationTimestamp
public long getModificationTimestamp()
- Specified by:
getModificationTimestamp
in interfaceUiWidget
- Returns:
- the timestamp of the last change to this widget. Will be
-1
if it notmodified
.
-
setValue
public void setValue(V value, boolean forUser)
- Specified by:
setValue
in interfaceAttributeWriteValueForUser<V>
- Specified by:
setValue
in interfaceUiValidatableWidget<V>
- Parameters:
value
- the newvalue
.forUser
- -true
forUiValidatableWidget.setValueForUser(Object)
andfalse
forUiValidatableWidget.setValue(Object)
.
-
setValueNative
protected abstract void setValueNative(V value)
- Parameters:
value
- the newvalue
to set in the native widget.
-
onFocusLoss
protected void onFocusLoss(org.teavm.jso.dom.events.Event event)
- Overrides:
onFocusLoss
in classTvmActiveWidget<W extends org.teavm.jso.dom.html.HTMLElement>
- Parameters:
event
- the blurEvent
.
-
getAutocomplete
public String getAutocomplete()
- Specified by:
getAutocomplete
in interfaceAttributeWriteAutocomplete
- Returns:
- the autocompletion configuration of this object (e.g.
UiTextualInput
).
-
setAutocomplete
public void setAutocomplete(String autocomplete)
- Specified by:
setAutocomplete
in interfaceAttributeWriteAutocomplete
- Parameters:
autocomplete
- is the new value ofAttributeWriteAutocomplete.getAutocomplete()
.
-
-