Package com.vaadin.client.ui
Class VDateField<R extends Enum<R>>
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Panel
-
- com.google.gwt.user.client.ui.ComplexPanel
-
- com.google.gwt.user.client.ui.FlowPanel
-
- com.vaadin.client.ui.VDateField<R>
-
- Type Parameters:
R- the resolution type which this field is based on (day, month, ...)
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.HasEnabled,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.HasWidgets,com.google.gwt.user.client.ui.HasWidgets.ForIsWidget,com.google.gwt.user.client.ui.IndexedPanel,com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget,com.google.gwt.user.client.ui.InsertPanel,com.google.gwt.user.client.ui.InsertPanel.ForIsWidget,com.google.gwt.user.client.ui.IsWidget,Field,Iterable<com.google.gwt.user.client.ui.Widget>
- Direct Known Subclasses:
VAbstractDateFieldCalendar,VAbstractTextualDate
public abstract class VDateField<R extends Enum<R>> extends com.google.gwt.user.client.ui.FlowPanel implements Field, com.google.gwt.user.client.ui.HasEnabled
A very base widget class for a date field.- Author:
- Vaadin Ltd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
-
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
-
-
Field Summary
Fields Modifier and Type Field Description protected StringbufferedDateStringA temporary holder of the date string, which would be sent to the server throughsendBufferedValues().protected Map<R,Integer>bufferedResolutionsA temporary holder of the time units (resolutions), which would be sent to the server throughsendBufferedValues().static StringCLASSNAMEDefault classname for this widget.ApplicationConnectionclientFor internal use only.AbstractDateFieldConnector<R>connectorFor internal use only.protected StringcurrentLocaleCurrently used locale string, e.g.DateTimeServicedtsFor internal use only.protected booleanenabledIs the widget enabled or not.protected booleanreadonlyIs the widget read-only or not.AbstractDateFieldServerRpcrpcThe RPC send calls to the server.protected booleanshowISOWeekNumbersShould ISO 8601 week numbers be shown in the date selector or not.
-
Constructor Summary
Constructors Constructor Description VDateField(R resolution)Constructs a widget for a date field.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract R[]doGetResolutions()Returns all available resolutions as an array.ApplicationConnectiongetClient()Returns the current application connection.DategetCurrentDate()Returns the current date value.StringgetCurrentLocale()Returns the current locale String.RgetCurrentResolution()Returns the current resolution.DategetDate()Returns a copy of the current date.protected abstract DategetDate(Map<R,Integer> dateValues)Returns a date based on the provided date values map.DateTimeServicegetDateTimeService()Returns the date time service for this widget.DategetDefaultDate()Sets the default date when no date is selected.StringgetId()Deprecated.This method is not used by the framework code anymore.Stream<R>getResolutions()Returns all available resolutions for the field in the ascending order (which is the same as order of enumeration ordinals).StringgetResolutionVariable(R resolution)Returns a resolution variable name for the givenresolution.booleanisEnabled()booleanisReadonly()Returns whether this widget is read-only or not.booleanisShowISOWeekNumbers()Returns whether ISO 8601 week numbers should be shown in the date selector or not.abstract booleanisYear(R resolution)Checks whether the givenresolutionrepresents an year.abstract StringresolutionAsString()Returns a current resolution as a string.voidsendBufferedValues()Sends thebufferedDateStringandbufferedResolutionsto the server, and clears their values.voidsendBufferedValuesWithDelay()Puts thebufferedDateStringandbufferedResolutionschanges into the rpc queue and clears their values.voidsetCurrentDate(Date date)Sets the date value.voidsetCurrentDate(Map<R,Integer> dateValues)Set the current date using a map with date values.voidsetCurrentLocale(String currentLocale)Sets the locale String.voidsetCurrentResolution(R currentResolution)Sets the resolution.protected voidsetDate(Date date)Sets the current date for this VDateField.voidsetDefaultDate(Date date)Set the default date to open popup when no date is selected.voidsetDefaultDate(Map<R,Integer> defaultValues)Set the default date using a map with date values.voidsetEnabled(boolean enabled)voidsetReadonly(boolean readonly)Sets whether this widget should be read-only or not.voidsetShowISOWeekNumbers(boolean showISOWeekNumbers)Sets whether ISO 8601 week numbers should be shown in the date selector or not.protected abstract booleansupportsTime()Checks whether time is supported by this widget.abstract voidupdateBufferedValues()Update buffered valuesbufferedDateStringandbufferedResolutionsthat will be sent to the server.-
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, doAttachChildren, doDetachChildren, orphan, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
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, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel
getWidget, getWidgetCount, getWidgetIndex, remove
-
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
getWidgetIndex
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
CLASSNAME
public static final String CLASSNAME
Default classname for this widget.- See Also:
- Constant Field Values
-
client
public ApplicationConnection client
For internal use only. May be removed or replaced in the future.
-
connector
public AbstractDateFieldConnector<R extends Enum<R>> connector
For internal use only. May be removed or replaced in the future.
-
currentLocale
protected String currentLocale
Currently used locale string, e.g.en_US.
-
readonly
protected boolean readonly
Is the widget read-only or not.
-
enabled
protected boolean enabled
Is the widget enabled or not.
-
rpc
public AbstractDateFieldServerRpc rpc
The RPC send calls to the server.- Since:
- 8.2
-
bufferedResolutions
protected Map<R extends Enum<R>,Integer> bufferedResolutions
A temporary holder of the time units (resolutions), which would be sent to the server throughsendBufferedValues(). The key is the resolution. The value can benull.- Since:
- 8.2
-
bufferedDateString
protected String bufferedDateString
A temporary holder of the date string, which would be sent to the server throughsendBufferedValues().- Since:
- 8.2
-
dts
public DateTimeService dts
For internal use only. May be removed or replaced in the future.
-
showISOWeekNumbers
protected boolean showISOWeekNumbers
Should ISO 8601 week numbers be shown in the date selector or not.
-
-
Constructor Detail
-
VDateField
public VDateField(R resolution)
Constructs a widget for a date field.- Parameters:
resolution- the resolution for this widget (day, month, ...)
-
-
Method Detail
-
getCurrentResolution
public R getCurrentResolution()
Returns the current resolution.- Returns:
- the resolution
-
setCurrentResolution
public void setCurrentResolution(R currentResolution)
Sets the resolution.- Parameters:
currentResolution- the new resolution
-
getCurrentLocale
public String getCurrentLocale()
Returns the current locale String.- Returns:
- the locale String
-
setCurrentLocale
public void setCurrentLocale(String currentLocale)
Sets the locale String.- Parameters:
currentLocale- the new locale String.
-
getCurrentDate
public Date getCurrentDate()
Returns the current date value.- Returns:
- the date value
-
setCurrentDate
public void setCurrentDate(Date date)
Sets the date value.- Parameters:
date- the new date value
-
setDefaultDate
public void setDefaultDate(Date date)
Set the default date to open popup when no date is selected.- Parameters:
date- default date to show as the initial (non-selected) value when opening a popup with no value selected- Since:
- 8.1.2
-
setCurrentDate
public void setCurrentDate(Map<R,Integer> dateValues)
Set the current date using a map with date values.The map contains integer representation of values per resolution. The method should construct a date based on the map and set it via
setCurrentDate(Date)- Parameters:
dateValues- a map with date values to convert into a date
-
setDefaultDate
public void setDefaultDate(Map<R,Integer> defaultValues)
Set the default date using a map with date values.- Parameters:
defaultValues- a map from resolutions to date values- Since:
- 8.1.2
- See Also:
setCurrentDate(Map)
-
getDefaultDate
public Date getDefaultDate()
Sets the default date when no date is selected.- Returns:
- the default date
- Since:
- 8.1.2
-
isReadonly
public boolean isReadonly()
Returns whether this widget is read-only or not.- Returns:
trueif read-only,falseotherwise
-
setReadonly
public void setReadonly(boolean readonly)
Sets whether this widget should be read-only or not.- Parameters:
readonly-trueif read-only,falseotherwise
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled
-
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled
-
getDateTimeService
public DateTimeService getDateTimeService()
Returns the date time service for this widget.- Returns:
- the date time service
-
getId
@Deprecated public String getId()
Deprecated.This method is not used by the framework code anymore.Returns the connector id that corresponds with this widget.- Returns:
- the connector id
-
getClient
public ApplicationConnection getClient()
Returns the current application connection.- Returns:
- the application connection
-
isShowISOWeekNumbers
public boolean isShowISOWeekNumbers()
Returns whether ISO 8601 week numbers should be shown in the date selector or not. ISO 8601 defines that a week always starts with a Monday so the week numbers are only shown if this is the case.- Returns:
trueif week number should be shown,falseotherwise
-
setShowISOWeekNumbers
public void setShowISOWeekNumbers(boolean showISOWeekNumbers)
Sets whether ISO 8601 week numbers should be shown in the date selector or not. ISO 8601 defines that a week always starts with a Monday so the week numbers are only shown if this is the case.- Parameters:
showISOWeekNumbers-trueif week number should be shown,falseotherwise
-
getDate
public Date getDate()
Returns a copy of the current date. Modifying the returned date will not modify the value of this VDateField. UsesetDate(Date)to change the current date.For internal use only. May be removed or replaced in the future.
- Returns:
- A copy of the current date
-
setDate
protected void setDate(Date date)
Sets the current date for this VDateField.- Parameters:
date- The new date to use
-
getResolutionVariable
public String getResolutionVariable(R resolution)
Returns a resolution variable name for the givenresolution.- Parameters:
resolution- the given resolution- Returns:
- the resolution variable name
-
updateBufferedValues
public abstract void updateBufferedValues()
Update buffered valuesbufferedDateStringandbufferedResolutionsthat will be sent to the server.This method should NOT send values to the server.
This method can be implemented by subclasses to update buffered values from component values.
- Since:
- 8.4
-
sendBufferedValues
public void sendBufferedValues()
Sends thebufferedDateStringandbufferedResolutionsto the server, and clears their values.- Since:
- 8.2
-
sendBufferedValuesWithDelay
public void sendBufferedValuesWithDelay()
Puts thebufferedDateStringandbufferedResolutionschanges into the rpc queue and clears their values.Note: The value will not be sent to the server immediately. It will be sent when a non
Delayedannotated rpc is triggered.- Since:
- 8.9
-
getResolutions
public Stream<R> getResolutions()
Returns all available resolutions for the field in the ascending order (which is the same as order of enumeration ordinals).The method uses
doGetResolutions()to make sure that the order is the correct one.- Returns:
- stream of all available resolutions in the ascending order.
- See Also:
doGetResolutions()
-
resolutionAsString
public abstract String resolutionAsString()
Returns a current resolution as a string.The method is used to generate a style name for the current resolution.
- Returns:
- the current resolution as a string
-
isYear
public abstract boolean isYear(R resolution)
Checks whether the givenresolutionrepresents an year.- Parameters:
resolution- the given resolution- Returns:
trueif theresolutionrepresents an year
-
supportsTime
protected abstract boolean supportsTime()
Checks whether time is supported by this widget.- Returns:
trueif time is supported in addition to date,falseif only dates are supported- Since:
- 8.1
-
getDate
protected abstract Date getDate(Map<R,Integer> dateValues)
Returns a date based on the provided date values map.- Parameters:
dateValues- a map with date values to convert into a date- Returns:
- the date based on the dateValues map
- See Also:
setCurrentDate(Map)
-
doGetResolutions
protected abstract R[] doGetResolutions()
Returns all available resolutions as an array.No any order is required (in contrary to
getResolutions().- Returns:
- all available resolutions
- See Also:
getResolutions()
-
-