ADAPTER - is the generic type of getWidgetAdapter().VALUE - is the generic type of the value. Use Void for no value.public abstract class AbstractUiWidgetNative<ADAPTER extends UiWidgetAdapter,VALUE> extends AbstractUiWidget<VALUE> implements UiWidgetAbstractComposite, AttributeWriteAriaRole
UiWidget or more precisely
UiWidgetNative. It is independent of any native toolkit via
UiWidgetAdapter that is lazily created. UiWidgets for a native UI toolkit, you are
strongly encouraged to extend from this class and its subclasses (all classes named
AbstractUiWidget*).| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractUiWidgetNative.SizeImpl
This class contains the size (
Length values) of this widget. |
private class |
AbstractUiWidgetNative.VisibleFlag
This inner class is the implementation of the visible flag.
|
AbstractUiWidget.AccessHelper, AbstractUiWidget.EventSender, AbstractUiWidget.HandlerContainer| Modifier and Type | Field and Description |
|---|---|
private AbstractRole |
ariaRole |
private boolean |
disposed |
private boolean |
enabled |
private String |
id |
private static int |
idCounter |
private static String |
idPrefix |
private static LengthProperty[] |
LENGTH_PROPERTIES
The number of
LengthProperty values. |
private UiMode |
mode |
private UiMode |
modeFixed |
private UiWidgetComposite<?> |
parent |
private AbstractUiWidgetNative.SizeImpl |
size |
private String |
styles |
private String |
tooltip |
private boolean |
visible |
private AbstractUiWidgetNative.VisibleFlag |
visibleFlag |
private ADAPTER |
widgetAdapter |
STYLE_HEADERHTML_ATTRIBUTE_ID, ID_SEPARATOR, PROPERTY_IDPROPERTY_STYLES, STYLE_PATTERN_MULTIPLE, STYLE_PATTERN_SINGLEWAI_ARIA| Constructor and Description |
|---|
AbstractUiWidgetNative(UiContext context,
ADAPTER widgetAdapter)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeHandler(UiHandlerEventValueChange<VALUE> handler)
This method adds the given
UiHandlerEventValueChange to this object. |
boolean |
addStyle(String style)
This method adds the given
style to the styles. |
void |
clearMessages()
This method is clearing all messages.
|
protected void |
clearValidity()
This method may clear potential state information from previous validations.
|
protected AbstractUiWidgetNative.SizeImpl |
createSize() |
protected String |
createUniqueId() |
protected abstract ADAPTER |
createWidgetAdapter()
This method creates the
widget adapter. |
void |
dispose()
This method disposes this object.
|
protected VALUE |
doGetValue(VALUE template,
ValidationState state)
This method is called from the
data-binding triggered by API methods such as
AbstractUiFeatureValueAndValidation.getValue(). |
protected void |
doSetMode(UiMode uiMode)
This method is called from
setMode(UiMode) if the UiMode actually changed. |
protected void |
doSetValue(VALUE value,
boolean forUser)
This method is called from the
data-binding triggered by API methods such as
AbstractUiWidget.setValue(Object, boolean). |
protected void |
doValidate(ValidationState state,
VALUE value)
This method is called from
AbstractUiFeatureValueAndValidation.validate(ValidationState) and performs the actual validation of this
object. |
Role |
getAriaRole()
This method gets the
Accessibility.WAI_ARIA role of this object. |
protected Class<? extends Role> |
getAriaRoleFixedType() |
UiWidget |
getChild(int index)
This method gets the child at the given index.
|
UiWidget |
getChild(String childId)
This method gets the child with the given
id. |
int |
getChildCount()
This method gets the number of children in this composite.
|
int |
getChildIndex(UiWidget child)
This method determines the index of the given
child in the list of children of this composite. |
String |
getId()
This method gets the unique identifier of this object.
|
private int |
getIndexOfStyle(String style) |
static int |
getIndexOfStyle(String allStyles,
String style) |
UiMode |
getMode()
This method gets the current
UiMode of this object. |
UiMode |
getModeFixed()
This method gets the fixed
UiMode of this object. |
UiWidgetComposite<?> |
getParent() |
String |
getPrimaryStyle()
This method gets the primary
style of this object. |
Size |
getSize() |
String |
getStyles()
This method gets the style(s) (also called style-name(s)) of this object.
|
String |
getTooltip()
This method gets the tooltip of this object.
|
AttributeWriteFlagAdvanced |
getVisibleFlag()
This method gets advanced visibility support.
|
protected ADAPTER |
getWidgetAdapter()
This method gets or creates the
UiWidgetAdapter. |
static <A extends UiWidgetAdapter> |
getWidgetAdapter(AbstractUiWidgetNative<A,?> widget)
This method gives access to
getWidgetAdapter(). |
boolean |
hasStyle(String style)
This method checks if the given
style is contained in the set of styles
of this object. |
boolean |
hasWidgetAdapter() |
protected void |
initializeWidgetAdapter(ADAPTER adapter)
This method is called from
getWidgetAdapter() to initialize the UiWidgetAdapter. |
boolean |
isDisposed()
This method tests if this object has been
disposed. |
boolean |
isEnabled()
This method determines if this object is enabled.
|
protected boolean |
isModifiedRecursive() |
boolean |
isVisible()
This method determines if this object is
set to
visible. |
boolean |
isVisibleRecursive()
This method determines if this object is actually visible for the end-user.
|
boolean |
removeChangeHandler(UiHandlerEventValueChange<VALUE> handler)
This method removes the given
UiHandlerEventValueChange from this object. |
protected void |
removeFromParent()
This method removes this widget from its
parent. |
boolean |
removeStyle(String style)
This method removes the given
style from the styles. |
<ROLE extends Role> |
setAriaRole(Class<ROLE> roleType)
This method sets the
ARIA role of this object. |
void |
setEnabled(boolean enabled)
This method sets the
enabled status of this object. |
boolean |
setFocused()
This method sets the
focus to this object. |
void |
setId(String newId)
This method set the
ID of this object. |
static void |
setIdPrefix(String idPrefix)
This method sets the static prefix used for generated IDs.
|
void |
setMode(UiMode mode)
This method sets the
mode of this object. |
protected void |
setMode(UiMode newMode,
boolean programmatic) |
void |
setModeFixed(UiMode modeFixed)
This method sets the
fixed mode of this object. |
(package private) void |
setModeRecursive(UiMode newMode,
boolean programmatic)
This method is called from
setMode(UiMode) to recursively change the UiMode. |
protected void |
setParent(UiWidgetComposite<?> parent)
This method sets the
parent. |
void |
setPrimaryStyle(String primaryStyle)
This method sets the
primary style. |
void |
setStyles(String styles)
This method clears all
styles and sets them to the given styles. |
void |
setTooltip(String tooltip)
This method sets the tooltip text of this object.
|
void |
setVisible(boolean visible)
This method shows or hides this object.
|
void |
setVisible(boolean visibility,
boolean programmatic)
This method shows or hides this object.
|
String |
toString() |
(package private) void |
validateRecursive(ValidationState state)
This method performs the recursive validation of potential children of this widget excluding the
validation of this widget itself.
|
protected void |
visibilityChanged(boolean visibility,
boolean programmatic)
Called from
setVisible(boolean) is the visibility has actually changed. |
addEventHandler, addValidator, clearMessagesLocal, clearValidationFailure, convertValueToString, fireEvent, fireValueChange, getBasicUtil, getContext, getDataBinding, getDataBinding, getDataBindingForWidget, getEventSender, getFactory, getLogger, getObserverSource, getOriginalValue, getRecentValue, getSource, getValueClass, getValueDirect, getValueOrException, getWidgetAdapter, hasEventSender, isMandatory, isModified, removeEventHandler, removeFromParent, removeValidator, setMandatory, setModified, setParent, setValueaddValidatorMandatory, createValidationFailure, getValue, getValueAndValidate, handleGetValueError, resetValue, setValue, setValueForUser, validateclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetContextaddEventHandler, removeEventHandlerisModifiedvalidateresetValue, setValue, setValueForUsergetValueprivate static final LengthProperty[] LENGTH_PROPERTIES
LengthProperty values.private static String idPrefix
setIdPrefix(String)private static int idCounter
createUniqueId()private ADAPTER extends UiWidgetAdapter widgetAdapter
getWidgetAdapter()private UiWidgetComposite<?> parent
getParent()private boolean visible
isVisible()private AbstractUiWidgetNative.VisibleFlag visibleFlag
getVisibleFlag()private boolean enabled
isEnabled()private boolean disposed
isDisposed()private String tooltip
getTooltip()private String styles
getStyles()private AbstractUiWidgetNative.SizeImpl size
getSize()private AbstractRole ariaRole
getAriaRole()private UiMode modeFixed
getModeFixed()public AbstractUiWidgetNative(UiContext context, ADAPTER widgetAdapter)
context - is the context.widgetAdapter - is the widget adapter. Typically null for
lazy initialization.public final boolean hasWidgetAdapter()
hasWidgetAdapter in class AbstractUiWidget<VALUE>true if the UiWidgetAdapter has already been created. Otherwise false (if AbstractUiWidget.getWidgetAdapter() has never been called
yet).protected final ADAPTER getWidgetAdapter()
UiWidgetAdapter. UiWidgetAdapter is created. For the purpose of lazy
instantiation this should happen as late as possible. Use AbstractUiWidget.hasWidgetAdapter() to prevent
unnecessary creation.getWidgetAdapter in class AbstractUiWidget<VALUE>UiWidgetAdapter.public static final <A extends UiWidgetAdapter> A getWidgetAdapter(AbstractUiWidgetNative<A,?> widget)
getWidgetAdapter(). UiWidgets. It shall never be used by
regular users (what also applies for all classes in this base packages).A - is the generic type of getWidgetAdapter().widget - is the widget.widget adapter of the given widget.protected void initializeWidgetAdapter(ADAPTER adapter)
getWidgetAdapter() to initialize the UiWidgetAdapter. All
attributes of this widget need to be set in the UiWidgetAdapter.adapter - is the UiWidgetAdapter to initialize.protected abstract ADAPTER createWidgetAdapter()
widget adapter. underlying widget.public void setId(String newId)
ID of this object. Use this method to give the object a meaningful
identifier after creation. AttributeReadHtmlId.getId() for the syntax constraints of IDs.setId in interface AttributeWriteHtmlIdsetId in interface AttributeWriteId<String>newId - is the new ID for the object.public String getId()
[a-zA-Z][a-zA-Z0-9_$]*.
Invalid IDs (e.g. containing colon, hash or period) are not accepted to prevent you from later having
problems with CSS selectors.getId in interface AttributeReadHtmlIdgetId in interface AttributeReadId<String>AttributeReadHtmlId.ID_SEPARATORpublic static void setIdPrefix(String idPrefix)
idPrefix - is the idPrefix to setpublic boolean setFocused()
focus to this object. setFocused in interface AttributeWriteOnlyFocusedtrue if the focus has been set successfully, false otherwise.public UiWidgetComposite<?> getParent()
getParent in interface UiWidgetnull if NOT attached to the UI or if this is a root
widget (e.g. UiWidgetMainWindow).protected void setParent(UiWidgetComposite<?> parent)
parent.setParent in class AbstractUiWidget<VALUE>parent - is the new parent.protected void removeFromParent()
parent. The parent is
set to null and the native widget is removed from its parent.removeFromParent in class AbstractUiWidget<VALUE>public void addChangeHandler(UiHandlerEventValueChange<VALUE> handler)
UiHandlerEventValueChange to this object.addChangeHandler in interface UiFeatureValue<VALUE>addChangeHandler in class AbstractUiWidget<VALUE>handler - is the UiHandlerEventValueChange to add.public boolean removeChangeHandler(UiHandlerEventValueChange<VALUE> handler)
UiHandlerEventValueChange from this object.removeChangeHandler in interface UiFeatureValue<VALUE>removeChangeHandler in class AbstractUiWidget<VALUE>handler - is the UiHandlerEventValueChange to remove.true if the handler has been removed successfully, false
if it was NOT registered and nothing has
changed.public final UiMode getMode()
UiMode of this object.getMode in interface AttributeReadModeUiMode.public final void setMode(UiMode mode)
mode of this object. It will change the object to view or edit mode. This is a recursive operation that will also apply to all
descendants of this object. If a fixed mode is set (not
null), this method will have no effect and recursive calls will stop at this object.setMode in interface AttributeWriteModesetMode in class AbstractUiWidget<VALUE>mode - is the new UiMode to set.protected void setMode(UiMode newMode, boolean programmatic)
setMode in class AbstractUiWidget<VALUE>newMode - is the new UiMode to set.programmatic - - see UiEvent.isProgrammatic().AbstractUiWidget.setMode(UiMode)protected void doSetMode(UiMode uiMode)
setMode(UiMode) if the UiMode actually changed.uiMode - is the new UiMode.void setModeRecursive(UiMode newMode, boolean programmatic)
setMode(UiMode) to recursively change the UiMode.newMode - is the new UiMode.programmatic - - see UiEvent.isProgrammatic().public UiMode getModeFixed()
UiMode of this object. While a fixed UiMode is
set (NOT null)
changing the mode will have no effect.getModeFixed in interface AttributeReadModeFixedUiMode or null if the UiMode may be
changed.public void setModeFixed(UiMode modeFixed)
fixed mode of this object. This will
set the mode to the given
mode (if not null, recursively) and then mark the mode as fixed so
AttributeWriteMode.setMode(UiMode) will have no effect anymore. The fixed
mode itself will NOT be set recursively. UiMode.VIEW in order to prevent a UI widget (a
field or even an entire sub-dialog) from switching to edit-mode (UiMode.EDIT) so the UI widget
will always remain read-only.setModeFixed in interface AttributeWriteModeFixedmodeFixed - is the new fixed UiMode to set. May be null to unset fixation.public boolean isDisposed()
disposed. A disposed object can
NOT be used anymore.isDisposed in interface AttributeReadDisposedtrue if this object has been disposed.AttributeWriteDisposed.dispose()public void dispose()
dispose in interface AttributeWriteDisposedpublic final void setVisible(boolean visible)
AttributeWriteVisibleAdvanced.isVisible(). It is an efficient shortcut for
AttributeWriteVisibleAdvanced.getVisibleFlag().setFlag(visible, null).setVisible in interface AttributeWriteVisiblesetVisible in interface AttributeWriteVisibleAdvancedvisible - is the new visibility status of this object. If true, the object will be
shown (and raised), if false the object will be hidden (iconified).AttributeWriteVisibleAdvanced.isVisible()public void setVisible(boolean visibility,
boolean programmatic)
AttributeWriteVisibleAdvancedsetVisible in interface AttributeWriteVisibleAdvancedvisibility - - see setVisible(boolean).programmatic - - see UiEvent.isProgrammatic().setVisible(boolean)protected void visibilityChanged(boolean visibility,
boolean programmatic)
setVisible(boolean) is the visibility has actually changed.visibility - is the new visibility.programmatic - - see UiEvent.isProgrammatic().public boolean isVisible()
set to
visible.
AttributeWriteVisibleAdvanced.getVisibleFlag().getFlag(). If you want
to read the value that has been set via AttributeWriteVisibleAdvanced.setVisible(boolean) you would need to do
AttributeWriteVisibleAdvanced.getVisibleFlag().getFlag(null)
instead. See AttributeWriteVisibleAdvanced.getVisibleFlag() for more information.isVisible in interface AttributeReadVisibleisVisible in interface AttributeWriteVisibleAdvancedtrue if programmatically set visible, false if directly
programmatically hidden.AttributeReadVisibleRecursive.isVisibleRecursive()public AttributeWriteFlagAdvanced getVisibleFlag()
boolean attribute or property.
However, this is leading to various problems if you have multiple aspects that influence the flag. E.g.
assume you have some dynamic effect that is showing or hiding a widget. Additionally the widget is in a
collapsable section, tab-panel, or the like that is also showing or hiding the widget. Further, there
might be an authorization in your application as a cross-cutting concern that hides widgets from the UI
according to the current roles and permissions of the user. If this is all based on a simple boolean flag
you will end up in a mess and with a buggy application. So the dynamic effect or even worse the
authorization will hide the widget but after the user collapses and then expands a panel it becomes
visible again. You do not want to deal with bugs like this. AttributeWriteVisibleAdvanced.isVisible() for reading visibility.getVisibleFlag in interface AttributeWriteVisibleAdvancedmutable flag for advanced visibility support.public final boolean isVisibleRecursive()
AttributeReadVisible.isVisible() it also takes its parent objects into account. So it only returns true
if the object is actually attached to the UI and physically in the current dialogue (it may still be
clipped from the screen or scrolled out of the visible panel).isVisibleRecursive in interface AttributeReadVisibleRecursivetrue if visible to the end-user, false otherwise.public void setTooltip(String tooltip)
setTooltip in interface AttributeWriteTooltiptooltip - is the new tooltip text or null to disable the tooltip.AttributeReadTooltip.getTooltip()public String getTooltip()
getTooltip in interface AttributeReadTooltippublic void setEnabled(boolean enabled)
enabled status of this object. If it is disabled, the user can
not interact with the object.setEnabled in interface AttributeWriteEnabledenabled - - if true the object will be enabled, else the object will be disabled.public boolean isEnabled()
isEnabled in interface AttributeReadEnabledtrue if this object is enabled, false if this object is disabled.public Size getSize()
protected AbstractUiWidgetNative.SizeImpl createSize()
public Role getAriaRole()
Accessibility.WAI_ARIA role of this object. UiWidget) is supposed to provide high-level
widgets and support setting the according Role and their attributes automatically. Therefore
users should only use this for special situations e.g. for setting aria-hidden intentionally for a visible object.getAriaRole in interface AttributeReadAriaRoleRole or null if NOT set.Accessibilitypublic <ROLE extends Role> ROLE setAriaRole(Class<ROLE> roleType)
ARIA role of this object. UiWidget) the roles are automatically set for according
widgets. There is no need to e.g. manually set RoleCombobox to
a UiWidgetComboBox. Therefore, you only need to set roles explicitly for specific custom
features. ATTENTION:Role is given.setAriaRole in interface AttributeWriteAriaRoleROLE - is the generic type of the new Role.roleType - is the interface of the new ARIA role. Must not be an
abstract Role interface.Role that is connected to this object.AttributeReadAriaRole.getAriaRole(),
Accessibilitypublic String getStyles()
class attribute of HTML
elements that are then configured via some cascading style sheet (CSS). AttributeReadStyles.STYLE_PATTERN_SINGLE. Any number of styles or in other words
the result of this has to match AttributeReadStyles.STYLE_PATTERN_MULTIPLE. The first style is called the
primary style.getStyles in interface AttributeReadStylespublic void setStyles(String styles)
styles and sets them to the given styles. This
will also update the primary style.setStyles in interface AttributeWriteStylesstyles - are the styles of this object. Either a single style or a list of styles separated by
whitespaces. Use the empty string to unset all styles.public String getPrimaryStyle()
style of this object.getPrimaryStyle in interface AttributeReadPrimaryStylenull if NOT defined.public void setPrimaryStyle(String primaryStyle)
primary style.setPrimaryStyle in interface AttributeWritePrimaryStyleprimaryStyle - is the new value for primary style.AttributeReadStyles.getStyles()public final boolean hasStyle(String style)
style is contained in the set of styles
of this object.hasStyle in interface AttributeReadStylesAdvancedstyle - is the style to check.style is active.private int getIndexOfStyle(String style)
style - is the style to check.style in styles or -1
if NOT present.hasStyle(String)public static int getIndexOfStyle(String allStyles, String style)
allStyles - is the String with all current styles separated with whitespaces.style - is the single style to check.style in allStyles or -1 if
NOT present.getIndexOfStyle(String)public final boolean addStyle(String style)
style to the styles.addStyle in interface AttributeWriteStylesAdvancedstyle - is the style to add. If this style is already contained in the styles,
this will have no effect.true if the styles has actually been added, false if it was already
present before.public final boolean removeStyle(String style)
style from the styles.removeStyle in interface AttributeWriteStylesAdvancedstyle - is the style to remove. If this style is NOT contained in the styles,
this will have no effect.true if the given style has actually been removed, false
otherwise (if it was NOT present).protected boolean isModifiedRecursive()
isModifiedRecursive in class AbstractUiWidget<VALUE>true if a child or descendant of this object is modified,
false otherwise.public final void clearMessages()
validation failures
as well as other messages such as infos, errors, or warnings
(e.g. in a message-panel). This is a recursive operation that is propagated to all potential children.clearMessages in interface UiFeatureMessagesclearMessages in class AbstractUiWidget<VALUE>protected final void clearValidity()
validity recursively.clearValidity in class AbstractUiWidget<VALUE>protected void doValidate(ValidationState state, VALUE value)
AbstractUiFeatureValueAndValidation.validate(ValidationState) and performs the actual validation of this
object. This method performs the recursive validation of potential children of this widget excluding the
validation of this widget itself. A legal implementation of a composite widget needs to call
AbstractUiFeatureValueAndValidation.validate(ValidationState) on all child widgets.
validation of this widget by delegating to
validateRecursive(ValidationState). It may be overridden to collect potential validation
failures and attach them to this widget. You should not forget the super-call in such case.doValidate in class AbstractUiWidget<VALUE>state - is the ValidationState. Never null.value - is the current value of this object that has already be determined.void validateRecursive(ValidationState state)
AbstractUiFeatureValueAndValidation.validate(ValidationState) on all child widgets.state - is the ValidationState.public UiWidget getChild(int index) throws IndexOutOfBoundsException
getChild in interface UiWidgetAbstractCompositeindex - is the index of the requested child. Has to be in the range from 0 to
UiWidgetAbstractComposite.getChildCount() - 1.IndexOutOfBoundsException - if the given index is out of bounds.List.get(int)public int getChildIndex(UiWidget child)
child in the list of children of this composite. getChildIndex in interface UiWidgetAbstractCompositechild - is the potential child.index of the given child or -1 if it is NOT
a child of this composite.List.indexOf(Object)public int getChildCount()
getChildCount in interface UiWidgetAbstractCompositeprotected void doSetValue(VALUE value, boolean forUser)
data-binding triggered by API methods such as
AbstractUiWidget.setValue(Object, boolean). In many cases the data-binding already
performs the required work to do. However, here is the place to implemented the custom logic to get the
value from the actual widget. For details see AbstractUiWidget.doGetValue(Object, ValidationState).doSetValue in class AbstractUiWidget<VALUE>value - is the value to set. Typically a composite object (e.g. java bean) so its attributes are set
to fields (see UiWidgetField).forUser - true if called from AbstractUiFeatureValueAndValidation.setValueForUser(Object), false if
set from AbstractUiFeatureValueAndValidation.setValue(Object).AbstractUiWidget.doGetValue(Object, ValidationState)protected VALUE doGetValue(VALUE template, ValidationState state) throws RuntimeException
data-binding triggered by API methods such as
AbstractUiFeatureValueAndValidation.getValue(). In many cases the data-binding already performs the
required work to do. However, here is the place to implemented the custom logic to get the value from the
actual widget. The following cases have to be distinguished:
native
fields this method has to get the actual
value from the underlying native widget (text-box, password-field, etc.).custom fields this
method will be responsible to convert from the delegates value (see
UiWidgetCustom.getDelegate()) to the proper value type. E.g. if you want to create a custom
widget to edit your own datatype such as CustomerNumber based on a
UiWidgetTextField you need to convert from String
to CustomerNumber.custom composite widgets
you should use AbstractUiWidget.getDataBinding().
UiDataBinding.createAndBind(net.sf.mmm.util.pojo.path.api.TypedProperty)
that gives you high-level support and makes your live easy. Then there is no need to override this
method.Void, there is nothing to do here.AbstractUiWidget.doSetValue(Object, boolean) .doGetValue in class AbstractUiWidget<VALUE>template - is the object where the data is filled in. May only be null if according to
data-binding (e.g. if <VALUE> is an (immutable)
Datatype).state - is the ValidationState. May be null (if the validation is omitted).
Should only be used to propagate to AbstractUiWidget.getValueDirect(Object, ValidationState) of children.null if empty. If <VALUE> is
String the empty String has to be returned if no value has been entered. In case
<VALUE> is a mutable object (java bean) the template is NOT
null and is to be returned by this method after the value(s) of this widget have
been assigned. For immutable datatypes
template will be null and this method has to create a new instance of
<VALUE> based on the end-users input in the widget.RuntimeExceptionAbstractUiWidget.doSetValue(Object, boolean)public String toString()
toString in class AbstractUiWidget<VALUE>Copyright © 2001–2016 mmm-Team. All rights reserved.