com.smartgwt.client.widgets.form.fields
Class RelativeDateItem

java.lang.Object
  extended by com.smartgwt.client.core.JsObject
      extended by com.smartgwt.client.core.DataClass
          extended by com.smartgwt.client.core.RefDataClass
              extended by com.smartgwt.client.widgets.form.fields.FormItem
                  extended by com.smartgwt.client.widgets.form.fields.CanvasItem
                      extended by com.smartgwt.client.widgets.form.fields.RelativeDateItem
All Implemented Interfaces:
HasHandlers, HasBlurHandlers, HasChangedHandlers, HasChangeHandlers, HasClickHandlers, HasDoubleClickHandlers, HasFocusHandlers, HasIconClickHandlers, HasIconKeyPressHandlers, HasItemHoverHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasShowValueHandlers, HasTitleClickHandlers, HasTitleDoubleClickHandlers, HasTitleHoverHandlers

public class RelativeDateItem
extends CanvasItem

A FormItem for entering a date relative to today or relative to some other date, or a specific date. Typically used for filtering data by date.

The RelativeDateItem consists of a ComboBoxItem where the user may directly choose one of several preset options, choose to enter a quantity and time unit (eg "4 months ago" or "3 years from now") or directly type in an absolute date value (7/18/2009).


Field Summary
 
Fields inherited from class com.smartgwt.client.core.JsObject
jsObj
 
Constructor Summary
RelativeDateItem()
           
RelativeDateItem(JavaScriptObject jsObj)
           
RelativeDateItem(String name)
           
RelativeDateItem(String name, String title)
           
 
Method Summary
 void formatEditorValue()
          RelativeDateItems do not make use of the standard FormItem.formatEditorValue and FormItem.parseEditorValue methods.
static Date getAbsoluteDate(RelativeDate relativeDate)
          Converts a RelativeDate to a concrete Date.
static Date getAbsoluteDate(RelativeDate relativeDate, Date baseDate)
          Converts a RelativeDate to a concrete Date.
 Date getBaseDate()
          Base date for calculating the relative date entered by the user.
 int getCenturyThreshold()
          Only used if we're showing the date in a text field.
 String getDaysAgoTitle()
          The title to show for historical periods when the TimeUnit is "day".
 String getDaysFromNowTitle()
          The title to show for future periods when the TimeUnit is "day".
 int getDefaultQuantity()
          Default quantity to show in the quantityField.
 Date getEndDate()
          Maximum date the selectors will allow the user to pick.
 void getEnteredValue()
          Returns the raw text value typed into this items value text field
 String getHoursAgoTitle()
          The title to show for historical periods when the TimeUnit is "hour".
 String getHoursFromNowTitle()
          The title to show for future periods when the TimeUnit is "hour".
 String getInputFormat()
          Format for direct user input of date values.
 String getMillisecondsAgoTitle()
          The title to show for historical periods when the TimeUnit is "millisecond".
 String getMillisecondsFromNowTitle()
          The title to show for future periods when the TimeUnit is "millisecond".
 String getMinutesAgoTitle()
          The title to show for historical periods when the TimeUnit is "minute".
 String getMinutesFromNowTitle()
          The title to show for future periods when the TimeUnit is "minute".
 String getMonthsAgoTitle()
          The title to show for historical periods when the TimeUnit is "month".
 String getMonthsFromNowTitle()
          The title to show for future periods when the TimeUnit is "month".
 OperatorId getOperator()
          What operator to use when RelativeDateItem.getCriterion is called.
static RelativeDateItem getOrCreateRef(JavaScriptObject jsObj)
           
 String getPickerConstructor()
          Smart GWT class for the dateChooser autoChild displayed to allow the user to directly select dates.
 String getPickerIconPrompt()
          Prompt to show when the user hovers the mouse over the picker icon for this RelativeDateItem.
 RelativeDateRangePosition getRangePosition()
          Does this items relative date value refer to the start or end of the chosen date? Useful when using this item to generate filter criteria, such as the from or to value for an inclusive range.
 RelativeDate getRelativeDate()
          Returns the RelativeDate for the current value.
 String getSecondsAgoTitle()
          The title to show for historical periods when the TimeUnit is "second".
 String getSecondsFromNowTitle()
          The title to show for future periods when the TimeUnit is "second".
 Boolean getShowCalculatedDateField()
          Should the Calculated-Date be displayed to the right of the pickerIcon.
 Boolean getShowChooserIcon()
          Should we show the icon that shells a date-chooser?
 Boolean getShowFutureOptions()
          Should we show time-unit options in the future? If set to false, for each timeUnitOption we will show only past options [for example "N weeks ago"].
 Boolean getShowPastOptions()
          Should we show time-unit options in the past? If set to false, for each timeUnitOption we will show only future options [for example "N weeks from now"].
 Date getStartDate()
          Minimum date the selectors will allow the user to pick.
 TimeUnit[] getTimeUnitOptions()
          List of time units that will be offered for relative dates.
 Boolean getUseSharedPicker()
          When set to true (the default), use a single shared date-picker across all widgets that use one.
 String getWeeksAgoTitle()
          The title to show for historical periods when the TimeUnit is "week".
 String getWeeksFromNowTitle()
          The title to show for future periods when the TimeUnit is "week".
 String getYearsAgoTitle()
          The title to show for historical periods when the TimeUnit is "year".
 String getYearsFromNowTitle()
          The title to show for future periods when the TimeUnit is "year".
 void parseEditorValue()
          RelativeDateItems do not make use of the standard FormItem.formatEditorValue and FormItem.parseEditorValue methods.
 void setBaseDate(Date baseDate)
          Base date for calculating the relative date entered by the user.
 void setCenturyThreshold(int centuryThreshold)
          Only used if we're showing the date in a text field.
 void setDateFormatter(DateDisplayFormat dateFormatter)
          Format for displaying dates in the valueField and calculatedDateField.
 void setDateFormatter(DateDisplayFormatter formatter)
          Formatter function for displaying dates in the valueField and calculatedDateField in some custom format.
 void setDateParser(DateParser parser)
          Custom date parser function for direct user input of date values.
 void setDaysAgoTitle(String daysAgoTitle)
          The title to show for historical periods when the TimeUnit is "day".
 void setDaysFromNowTitle(String daysFromNowTitle)
          The title to show for future periods when the TimeUnit is "day".
 void setDefaultQuantity(int defaultQuantity)
          Default quantity to show in the quantityField.
 void setEditorValueFormatter(FormItemValueFormatter formatter)
          RelativeDateItems do not make use of the standard FormItem.setEditorValueFormatter() and FormItem.setEditorValueParser() methods.
 void setEditorValueParser(FormItemValueParser parser)
          RelativeDateItems do not make use of the standard FormItem.setEditorValueFormatter() and FormItem.setEditorValueParser() methods.
 void setEndDate(Date endDate)
          Maximum date the selectors will allow the user to pick.
 void setHoursAgoTitle(String hoursAgoTitle)
          The title to show for historical periods when the TimeUnit is "hour".
 void setHoursFromNowTitle(String hoursFromNowTitle)
          The title to show for future periods when the TimeUnit is "hour".
 void setInputFormat(String inputFormat)
          Format for direct user input of date values.
 void setMillisecondsAgoTitle(String millisecondsAgoTitle)
          The title to show for historical periods when the TimeUnit is "millisecond".
 void setMillisecondsFromNowTitle(String millisecondsFromNowTitle)
          The title to show for future periods when the TimeUnit is "millisecond".
 void setMinutesAgoTitle(String minutesAgoTitle)
          The title to show for historical periods when the TimeUnit is "minute".
 void setMinutesFromNowTitle(String minutesFromNowTitle)
          The title to show for future periods when the TimeUnit is "minute".
 void setMonthsAgoTitle(String monthsAgoTitle)
          The title to show for historical periods when the TimeUnit is "month".
 void setMonthsFromNowTitle(String monthsFromNowTitle)
          The title to show for future periods when the TimeUnit is "month".
 void setOperator(OperatorId operator)
          What operator to use when RelativeDateItem.getCriterion is called.
 void setPickerConstructor(String pickerConstructor)
          Smart GWT class for the dateChooser autoChild displayed to allow the user to directly select dates.
 void setPickerIconPrompt(String pickerIconPrompt)
          Prompt to show when the user hovers the mouse over the picker icon for this RelativeDateItem.
 void setPresetOptions(LinkedHashMap valueMap)
          Set up a set of standard relative dates such as "today" or "tomorrow" that the user can choose directly from the valueField of this item.
 void setRangePosition(RelativeDateRangePosition rangePosition)
          Does this items relative date value refer to the start or end of the chosen date? Useful when using this item to generate filter criteria, such as the from or to value for an inclusive range.
 void setRangeRoundingGranularity(Map rangeRoundingGranularity)
          A map from a granularity of time specified by a user to the granularity of time used for rounding.
 void setSecondsAgoTitle(String secondsAgoTitle)
          The title to show for historical periods when the TimeUnit is "second".
 void setSecondsFromNowTitle(String secondsFromNowTitle)
          The title to show for future periods when the TimeUnit is "second".
 void setShowCalculatedDateField(Boolean showCalculatedDateField)
          Should the Calculated-Date be displayed to the right of the pickerIcon.
 void setShowChooserIcon(Boolean showChooserIcon)
          Should we show the icon that shells a date-chooser?
 void setShowFutureOptions(Boolean showFutureOptions)
          Should we show time-unit options in the future? If set to false, for each timeUnitOption we will show only past options [for example "N weeks ago"].
 void setShowPastOptions(Boolean showPastOptions)
          Should we show time-unit options in the past? If set to false, for each timeUnitOption we will show only future options [for example "N weeks from now"].
 void setStartDate(Date startDate)
          Minimum date the selectors will allow the user to pick.
 void setTimeUnitOptions(TimeUnit... timeUnitOptions)
          List of time units that will be offered for relative dates.
 void setUseSharedPicker(Boolean useSharedPicker)
          When set to true (the default), use a single shared date-picker across all widgets that use one.
 void setWeeksAgoTitle(String weeksAgoTitle)
          The title to show for historical periods when the TimeUnit is "week".
 void setWeeksFromNowTitle(String weeksFromNowTitle)
          The title to show for future periods when the TimeUnit is "week".
 void setYearsAgoTitle(String yearsAgoTitle)
          The title to show for historical periods when the TimeUnit is "year".
 void setYearsFromNowTitle(String yearsFromNowTitle)
          The title to show for future periods when the TimeUnit is "year".
 
Methods inherited from class com.smartgwt.client.widgets.form.fields.CanvasItem
addShowValueHandler, canEditCriterion, createCanvas, getApplyPromptToCanvas, getCanvas, getCriterion, getEditCriteriaInInnerForm, getOverflow, getPrompt, getShouldSaveValue, hasAdvancedCriteria, setApplyPromptToCanvas, setCanvas, setCriterion, setEditCriteriaInInnerForm, setOverflow, setPrompt, setShouldSaveValue, setupCanvasConstructor, storeValue, storeValue, storeValue
 
Methods inherited from class com.smartgwt.client.widgets.form.fields.FormItem
addBlurHandler, addChangedHandler, addChangeHandler, addClickHandler, addDoubleClickHandler, addFocusHandler, addIconClickHandler, addIconKeyPressHandler, addItemHoverHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addTitleClickHandler, addTitleDoubleClickHandler, addTitleHoverHandler, blurItem, clearValue, disable, enable, focusInItem, getAccessKey, getAlign, getAllowExpressions, getAlwaysFetchMissingValues, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsString, getBrowserSpellCheck, getCanEdit, getCanFocus, getCellHeight, getCellStyle, getConfig, getContainerWidget, getCriteriaField, getCriterion, getDataPath, getDateFormatter, getDefaultIconSrc, getDisabled, getDisplayField, getDisplayFieldName, getDisplayValue, getDisplayValue, getEditorTypeConfig, getEmptyDisplayValue, getEmptyValueIcon, getEndRow, getErrorIconHeight, getErrorIconSrc, getErrorIconWidth, getErrorMessageWidth, getFetchMissingValues, getFieldName, getFilterLocally, getForm, getFullDataPath, getGlobalTabIndex, getHeight, getHint, getHintStyle, getHoverAlign, getHoverDelay, getHoverHeight, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getIcon, getIconHeight, getIconPageRect, getIconPrompt, getIconRect, getIconVAlign, getIconWidth, getImageURLPrefix, getImageURLSuffix, getImplicitSave, getImplicitSaveOnBlur, getLeft, getLocateItemBy, getMultipleValueSeparator, getName, getOptionCriteria, getOptionFilterContext, getOptionOperationId, getPageLeft, getPageRect, getPageTop, getPickerIconHeight, getPickerIconName, getPickerIconSrc, getPickerIconWidth, getPrintTextBoxStyle, getPrintTitleStyle, getRect, getRejectInvalidValueOnChange, getRequired, getRequiredMessage, getRowSpan, getSelectedRecord, getSelectOnFocus, getShowDisabled, getShowErrorIcon, getShowErrorStyle, getShowErrorText, getShowFocused, getShowFocusedIcons, getShowFocusedPickerIcon, getShowHint, getShowIcons, getShowOverIcons, getShowPickerIcon, getShowTitle, getShowValueIconOnly, getStartRow, getStopOnError, getSuppressValueIcon, getSynchronousValidation, getTabIndex, getTextAlign, getTextBoxStyle, getTimeFormatter, getTitle, getTitleAlign, getTitleColSpan, getTitleOrientation, getTitleStyle, getTitleVAlign, getTooltip, getTop, getType, getValidateOnChange, getValidateOnExit, getValidOperators, getVAlign, getValue, getValueField, getValueFieldName, getValueIconHeight, getValueIconLeftPadding, getValueIconRightPadding, getValueIconSize, getValueIconWidth, getVisible, getVisibleHeight, getVisibleWidth, getWidth, getWrapTitle, hide, invalidateDisplayValueCache, isCreated, isDisabled, isDrawn, isVisible, redraw, setAccessKey, setAlign, setAllowExpressions, setAlwaysFetchMissingValues, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setBrowserSpellCheck, setCanEdit, setCanFocus, setCellHeight, setCellStyle, setColSpan, setColSpan, setCriteriaField, setDataPath, setDefaultIconSrc, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDisabled, setDisplayField, setDisplayFormat, setDisplayFormat, setEditorType, setEmptyDisplayValue, setEmptyValueIcon, setEndRow, setErrorFormatter, setErrorIconHeight, setErrorIconSrc, setErrorIconWidth, setErrorMessageWidth, setErrorOrientation, setFetchMissingValues, setFilterLocally, setGlobalTabIndex, setHeight, setHeight, setHint, setHintStyle, setHoverAlign, setHoverDelay, setHoverHeight, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setIconHeight, setIconPrompt, setIcons, setIconVAlign, setIconWidth, setImageURLPrefix, setImageURLSuffix, setImplicitSave, setImplicitSaveOnBlur, setInitHandler, setInputTransformer, setItemHoverFormatter, setItemTitleHoverFormatter, setLeft, setLocateItemBy, setMultipleValueSeparator, setName, setOptionCriteria, setOptionDataSource, setOptionFilterContext, setOptionOperationId, setPickerIconHeight, setPickerIconName, setPickerIconSrc, setPickerIconWidth, setPrintTextBoxStyle, setPrintTitleStyle, setProperty, setProperty, setProperty, setProperty, setProperty, setRedrawOnChange, setRejectInvalidValueOnChange, setRequired, setRequiredMessage, setRowSpan, setSelectOnFocus, setShowDisabled, setShowErrorIcon, setShowErrorStyle, setShowErrorText, setShowFocused, setShowFocusedIcons, setShowFocusedPickerIcon, setShowHint, setShowIcons, setShowIfCondition, setShowOverIcons, setShowPickerIcon, setShowTitle, setShowValueIconOnly, setStartRow, setStopOnError, setSuppressValueIcon, setSynchronousValidation, setTabIndex, setTextAlign, setTextBoxStyle, setTimeFormatter, setTitle, setTitleAlign, setTitleColSpan, setTitleOrientation, setTitleStyle, setTitleVAlign, setTooltip, setTop, setType, setValidateOnChange, setValidateOnExit, setValidators, setValidOperators, setVAlign, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueField, setValueFormatter, setValueIconHeight, setValueIconLeftPadding, setValueIconMapper, setValueIconRightPadding, setValueIcons, setValueIconSize, setValueIconWidth, setValueMap, setValueMap, setVisible, setWidth, setWidth, setWrapTitle, shouldFetchMissingValue, show, showPicker, stopHover, updateState, validate
 
Methods inherited from class com.smartgwt.client.core.RefDataClass
getRef, getRef
 
Methods inherited from class com.smartgwt.client.core.DataClass
doAddHandler, fireEvent, getAttributeAsDoubleArray, getAttributeAsIntArray, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute
 
Methods inherited from class com.smartgwt.client.core.JsObject
setJsObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

RelativeDateItem

public RelativeDateItem()

RelativeDateItem

public RelativeDateItem(JavaScriptObject jsObj)

RelativeDateItem

public RelativeDateItem(String name)

RelativeDateItem

public RelativeDateItem(String name,
                        String title)
Method Detail

getOrCreateRef

public static RelativeDateItem getOrCreateRef(JavaScriptObject jsObj)

setBaseDate

public void setBaseDate(Date baseDate)
Base date for calculating the relative date entered by the user.

The default is to use the current date.

Parameters:
baseDate - baseDate Default value is null

getBaseDate

public Date getBaseDate()
Base date for calculating the relative date entered by the user.

The default is to use the current date.

Returns:
java.util.Date

setCenturyThreshold

public void setCenturyThreshold(int centuryThreshold)
Only used if we're showing the date in a text field. When parsing a date, if the year is specified with only 2 digits and is less than the centuryThreshold, then the year will be assumed to be 20xx; otherwise it will be interpreted according to default browser behaviour, which will consider it to be 19xx.

Parameters:
centuryThreshold - centuryThreshold Default value is 25
See Also:
Appearance overview and related methods

getCenturyThreshold

public int getCenturyThreshold()
Only used if we're showing the date in a text field. When parsing a date, if the year is specified with only 2 digits and is less than the centuryThreshold, then the year will be assumed to be 20xx; otherwise it will be interpreted according to default browser behaviour, which will consider it to be 19xx.

Returns:
int
See Also:
Appearance overview and related methods

setDaysAgoTitle

public void setDaysAgoTitle(String daysAgoTitle)
The title to show for historical periods when the TimeUnit is "day".

Parameters:
daysAgoTitle - daysAgoTitle Default value is "N days ago"

getDaysAgoTitle

public String getDaysAgoTitle()
The title to show for historical periods when the TimeUnit is "day".

Returns:
String

setDaysFromNowTitle

public void setDaysFromNowTitle(String daysFromNowTitle)
The title to show for future periods when the TimeUnit is "day".

Parameters:
daysFromNowTitle - daysFromNowTitle Default value is "N days from now"

getDaysFromNowTitle

public String getDaysFromNowTitle()
The title to show for future periods when the TimeUnit is "day".

Returns:
String

setDefaultQuantity

public void setDefaultQuantity(int defaultQuantity)
Default quantity to show in the quantityField.

Parameters:
defaultQuantity - defaultQuantity Default value is 1

getDefaultQuantity

public int getDefaultQuantity()
Default quantity to show in the quantityField.

Returns:
int

setEndDate

public void setEndDate(Date endDate)
Maximum date the selectors will allow the user to pick.

See startDate for details on how this restriction works.

Parameters:
endDate - endDate Default value is 12/31/2015
See Also:
Appearance overview and related methods

getEndDate

public Date getEndDate()
Maximum date the selectors will allow the user to pick.

See startDate for details on how this restriction works.

Returns:
java.util.Date
See Also:
Appearance overview and related methods

setHoursAgoTitle

public void setHoursAgoTitle(String hoursAgoTitle)
The title to show for historical periods when the TimeUnit is "hour".

Parameters:
hoursAgoTitle - hoursAgoTitle Default value is "N hours ago"

getHoursAgoTitle

public String getHoursAgoTitle()
The title to show for historical periods when the TimeUnit is "hour".

Returns:
String

setHoursFromNowTitle

public void setHoursFromNowTitle(String hoursFromNowTitle)
The title to show for future periods when the TimeUnit is "hour".

Parameters:
hoursFromNowTitle - hoursFromNowTitle Default value is "N hours from now"

getHoursFromNowTitle

public String getHoursFromNowTitle()
The title to show for future periods when the TimeUnit is "hour".

Returns:
String

setInputFormat

public void setInputFormat(String inputFormat)
Format for direct user input of date values.

If unset, the input format will be determined based on the specified displayFormat if possible, otherwise picked up from the Date class (see Date.setInputFormat).

Overrides:
setInputFormat in class FormItem
Parameters:
inputFormat - inputFormat Default value is null
See Also:
FormItem.setDateFormatter(com.smartgwt.client.types.DateDisplayFormat)

getInputFormat

public String getInputFormat()
Format for direct user input of date values.

If unset, the input format will be determined based on the specified displayFormat if possible, otherwise picked up from the Date class (see Date.setInputFormat).

Overrides:
getInputFormat in class FormItem
Returns:
If useTextField is true this method returns a standard String, determining how values entered by the user are to be converted to Javascript Date objects.

If an explicit inputFormat has been specified it will be returned, otherwise, the input format will be automatically derived from the dateFormatter property.

Note that the inputFormat will ignore any separator characters and padding of values. However if necessary entirely custom date formatting and parsing may be achieved via the setEditorValueFormatter() and setEditorValueParser() APIs.

See Also:
FormItem.getDateFormatter()

setMillisecondsAgoTitle

public void setMillisecondsAgoTitle(String millisecondsAgoTitle)
The title to show for historical periods when the TimeUnit is "millisecond".

Parameters:
millisecondsAgoTitle - millisecondsAgoTitle Default value is "N milliseconds ago"

getMillisecondsAgoTitle

public String getMillisecondsAgoTitle()
The title to show for historical periods when the TimeUnit is "millisecond".

Returns:
String

setMillisecondsFromNowTitle

public void setMillisecondsFromNowTitle(String millisecondsFromNowTitle)
The title to show for future periods when the TimeUnit is "millisecond".

Parameters:
millisecondsFromNowTitle - millisecondsFromNowTitle Default value is "N milliseconds from now"

getMillisecondsFromNowTitle

public String getMillisecondsFromNowTitle()
The title to show for future periods when the TimeUnit is "millisecond".

Returns:
String

setMinutesAgoTitle

public void setMinutesAgoTitle(String minutesAgoTitle)
The title to show for historical periods when the TimeUnit is "minute".

Parameters:
minutesAgoTitle - minutesAgoTitle Default value is "N minutes ago"

getMinutesAgoTitle

public String getMinutesAgoTitle()
The title to show for historical periods when the TimeUnit is "minute".

Returns:
String

setMinutesFromNowTitle

public void setMinutesFromNowTitle(String minutesFromNowTitle)
The title to show for future periods when the TimeUnit is "minute".

Parameters:
minutesFromNowTitle - minutesFromNowTitle Default value is "N minutes from now"

getMinutesFromNowTitle

public String getMinutesFromNowTitle()
The title to show for future periods when the TimeUnit is "minute".

Returns:
String

setMonthsAgoTitle

public void setMonthsAgoTitle(String monthsAgoTitle)
The title to show for historical periods when the TimeUnit is "month".

Parameters:
monthsAgoTitle - monthsAgoTitle Default value is "N months ago"

getMonthsAgoTitle

public String getMonthsAgoTitle()
The title to show for historical periods when the TimeUnit is "month".

Returns:
String

setMonthsFromNowTitle

public void setMonthsFromNowTitle(String monthsFromNowTitle)
The title to show for future periods when the TimeUnit is "month".

Parameters:
monthsFromNowTitle - monthsFromNowTitle Default value is "N months from now"

getMonthsFromNowTitle

public String getMonthsFromNowTitle()
The title to show for future periods when the TimeUnit is "month".

Returns:
String

setOperator

public void setOperator(OperatorId operator)
What operator to use when RelativeDateItem.getCriterion is called.

Overrides:
setOperator in class FormItem
Parameters:
operator - operator Default value is "greaterThan"
See Also:
CriteriaEditing overview and related methods

getOperator

public OperatorId getOperator()
What operator to use when RelativeDateItem.getCriterion is called.

Overrides:
getOperator in class FormItem
Returns:
OperatorId
See Also:
CriteriaEditing overview and related methods

setPickerConstructor

public void setPickerConstructor(String pickerConstructor)
Smart GWT class for the dateChooser autoChild displayed to allow the user to directly select dates.

Parameters:
pickerConstructor - pickerConstructor Default value is "DateChooser"

getPickerConstructor

public String getPickerConstructor()
Smart GWT class for the dateChooser autoChild displayed to allow the user to directly select dates.

Returns:
String

setPickerIconPrompt

public void setPickerIconPrompt(String pickerIconPrompt)
Prompt to show when the user hovers the mouse over the picker icon for this RelativeDateItem. May be overridden for localization of your application.

Parameters:
pickerIconPrompt - pickerIconPrompt Default value is "Show Date Chooser"

getPickerIconPrompt

public String getPickerIconPrompt()
Prompt to show when the user hovers the mouse over the picker icon for this RelativeDateItem. May be overridden for localization of your application.

Returns:
String

setRangePosition

public void setRangePosition(RelativeDateRangePosition rangePosition)
Does this items relative date value refer to the start or end of the chosen date? Useful when using this item to generate filter criteria, such as the from or to value for an inclusive range.

If unset "start" is assumed.

Note : This is an advanced setting

Parameters:
rangePosition - rangePosition Default value is null
See Also:
setOperator(com.smartgwt.client.types.OperatorId), setRangeRoundingGranularity(java.util.Map)

getRangePosition

public RelativeDateRangePosition getRangePosition()
Does this items relative date value refer to the start or end of the chosen date? Useful when using this item to generate filter criteria, such as the from or to value for an inclusive range.

If unset "start" is assumed.

Returns:
RelativeDateRangePosition
See Also:
getOperator(), com.smartgwt.client.widgets.form.fields.RelativeDateItem#getRangeRoundingGranularity

setSecondsAgoTitle

public void setSecondsAgoTitle(String secondsAgoTitle)
The title to show for historical periods when the TimeUnit is "second".

Parameters:
secondsAgoTitle - secondsAgoTitle Default value is "N seconds ago"

getSecondsAgoTitle

public String getSecondsAgoTitle()
The title to show for historical periods when the TimeUnit is "second".

Returns:
String

setSecondsFromNowTitle

public void setSecondsFromNowTitle(String secondsFromNowTitle)
The title to show for future periods when the TimeUnit is "second".

Parameters:
secondsFromNowTitle - secondsFromNowTitle Default value is "N seconds from now"

getSecondsFromNowTitle

public String getSecondsFromNowTitle()
The title to show for future periods when the TimeUnit is "second".

Returns:
String

setShowCalculatedDateField

public void setShowCalculatedDateField(Boolean showCalculatedDateField)
Should the Calculated-Date be displayed to the right of the pickerIcon.

Parameters:
showCalculatedDateField - showCalculatedDateField Default value is true

getShowCalculatedDateField

public Boolean getShowCalculatedDateField()
Should the Calculated-Date be displayed to the right of the pickerIcon.

Returns:
Boolean

setShowChooserIcon

public void setShowChooserIcon(Boolean showChooserIcon)
Should we show the icon that shells a date-chooser?

Parameters:
showChooserIcon - showChooserIcon Default value is true

getShowChooserIcon

public Boolean getShowChooserIcon()
Should we show the icon that shells a date-chooser?

Returns:
Boolean

setShowFutureOptions

public void setShowFutureOptions(Boolean showFutureOptions)
Should we show time-unit options in the future? If set to false, for each timeUnitOption we will show only past options [for example "N weeks ago"].

Note: this does not change the presetOptions, which show up in addition to the time-unit options ("N days from now", etc). The default preset options include both past and future presets so developers may wish to modify the presets to ensure only future options are available.

Parameters:
showFutureOptions - showFutureOptions Default value is true

getShowFutureOptions

public Boolean getShowFutureOptions()
Should we show time-unit options in the future? If set to false, for each timeUnitOption we will show only past options [for example "N weeks ago"].

Note: this does not change the presetOptions, which show up in addition to the time-unit options ("N days from now", etc). The default preset options include both past and future presets so developers may wish to modify the presets to ensure only future options are available.

Returns:
Boolean

setShowPastOptions

public void setShowPastOptions(Boolean showPastOptions)
Should we show time-unit options in the past? If set to false, for each timeUnitOption we will show only future options [for example "N weeks from now"].

Note: this does not change the presetOptions, which show up in addition to the time-unit options ("N days from now", etc). The default preset options include both past and future presets so developers may wish to modify the presets to ensure only past options are available.

Parameters:
showPastOptions - showPastOptions Default value is true

getShowPastOptions

public Boolean getShowPastOptions()
Should we show time-unit options in the past? If set to false, for each timeUnitOption we will show only future options [for example "N weeks from now"].

Note: this does not change the presetOptions, which show up in addition to the time-unit options ("N days from now", etc). The default preset options include both past and future presets so developers may wish to modify the presets to ensure only past options are available.

Returns:
Boolean

setStartDate

public void setStartDate(Date startDate)
Minimum date the selectors will allow the user to pick.

NOTE: by design, setting startDate and endDate will not always prevent the user from picking invalid values. In particular:

This is by design as it allows the user to set the day, month and year in whatever order is convenient, rather than forcing them to pick in a specific order.

For actual enforcement of a date being in correct range before data is submitted, a Validator of type "dateRange" should always be declared.

Parameters:
startDate - startDate Default value is 1/1/1995
See Also:
Appearance overview and related methods

getStartDate

public Date getStartDate()
Minimum date the selectors will allow the user to pick.

NOTE: by design, setting startDate and endDate will not always prevent the user from picking invalid values. In particular:

This is by design as it allows the user to set the day, month and year in whatever order is convenient, rather than forcing them to pick in a specific order.

For actual enforcement of a date being in correct range before data is submitted, a Validator of type "dateRange" should always be declared.

Returns:
java.util.Date
See Also:
Appearance overview and related methods

setTimeUnitOptions

public void setTimeUnitOptions(TimeUnit... timeUnitOptions)
List of time units that will be offered for relative dates.

Each available time unit option will cause two options to appear in the valueField. For example, if "day" is an available time unit option, there will be "N days ago" and "N days from now".

Parameters:
timeUnitOptions - timeUnitOptions Default value is ["day", "week", "month"]
See Also:
setShowPastOptions(java.lang.Boolean), setShowFutureOptions(java.lang.Boolean), setRangeRoundingGranularity(java.util.Map)

getTimeUnitOptions

public TimeUnit[] getTimeUnitOptions()
List of time units that will be offered for relative dates.

Each available time unit option will cause two options to appear in the valueField. For example, if "day" is an available time unit option, there will be "N days ago" and "N days from now".

Returns:
TimeUnit
See Also:
getShowPastOptions(), getShowFutureOptions(), com.smartgwt.client.widgets.form.fields.RelativeDateItem#getRangeRoundingGranularity

setUseSharedPicker

public void setUseSharedPicker(Boolean useSharedPicker)
When set to true (the default), use a single shared date-picker across all widgets that use one. When false, create a new picker using the autoChild system. See picker and pickerProperties for details on setting up an unshared picker.

Parameters:
useSharedPicker - useSharedPicker Default value is true

getUseSharedPicker

public Boolean getUseSharedPicker()
When set to true (the default), use a single shared date-picker across all widgets that use one. When false, create a new picker using the autoChild system. See picker and pickerProperties for details on setting up an unshared picker.

Returns:
Boolean

setWeeksAgoTitle

public void setWeeksAgoTitle(String weeksAgoTitle)
The title to show for historical periods when the TimeUnit is "week".

Parameters:
weeksAgoTitle - weeksAgoTitle Default value is "N weeks ago"

getWeeksAgoTitle

public String getWeeksAgoTitle()
The title to show for historical periods when the TimeUnit is "week".

Returns:
String

setWeeksFromNowTitle

public void setWeeksFromNowTitle(String weeksFromNowTitle)
The title to show for future periods when the TimeUnit is "week".

Parameters:
weeksFromNowTitle - weeksFromNowTitle Default value is "N weeks from now"

getWeeksFromNowTitle

public String getWeeksFromNowTitle()
The title to show for future periods when the TimeUnit is "week".

Returns:
String

setYearsAgoTitle

public void setYearsAgoTitle(String yearsAgoTitle)
The title to show for historical periods when the TimeUnit is "year".

Parameters:
yearsAgoTitle - yearsAgoTitle Default value is "N years ago"

getYearsAgoTitle

public String getYearsAgoTitle()
The title to show for historical periods when the TimeUnit is "year".

Returns:
String

setYearsFromNowTitle

public void setYearsFromNowTitle(String yearsFromNowTitle)
The title to show for future periods when the TimeUnit is "year".

Parameters:
yearsFromNowTitle - yearsFromNowTitle Default value is "N years from now"

getYearsFromNowTitle

public String getYearsFromNowTitle()
The title to show for future periods when the TimeUnit is "year".

Returns:
String

formatEditorValue

public void formatEditorValue()
RelativeDateItems do not make use of the standard FormItem.formatEditorValue and FormItem.parseEditorValue methods. Developers can customize the display values for these items in the following ways:


getEnteredValue

public void getEnteredValue()
Returns the raw text value typed into this items value text field


parseEditorValue

public void parseEditorValue()
RelativeDateItems do not make use of the standard FormItem.formatEditorValue and FormItem.parseEditorValue methods. Developers can customize the display values for these items in the following ways:


getRelativeDate

public RelativeDate getRelativeDate()
Returns the RelativeDate for the current value.

Returns:
the RelativeDate for the current value or null if not set

getAbsoluteDate

public static Date getAbsoluteDate(RelativeDate relativeDate)
Converts a RelativeDate to a concrete Date.

Parameters:
relativeDate - the relative date to convert
Returns:
resulting absolute date value

getAbsoluteDate

public static Date getAbsoluteDate(RelativeDate relativeDate,
                                   Date baseDate)
Converts a RelativeDate to a concrete Date.

Parameters:
relativeDate - the relative date to convert
baseDate - base value for conversion. Defaults to today
Returns:
resulting absolute date value

setPresetOptions

public void setPresetOptions(LinkedHashMap valueMap)
Set up a set of standard relative dates such as "today" or "tomorrow" that the user can choose directly from the valueField of this item.

This is similar to a standard FormItem::setValueMap(), valueMap - the parameter passed in should be a HashMap mapping RelativeDate strings to display values. The default set of preset options (expressed in JSON) are:

 {
  "$today" : "Today",
  "$yesterday" : "Yesterday",
  "$tomorrow" : "Tomorrow",
  "-1w" : "Current day of last week",
  "+1w" : "Current day of next week",
  "-1m" : "Current day of last month",
  "+1m" : "Current day of next month"
  }
  
In addition to these presets, options are shown for each of the #setTimeUnitOptions,time unit options.

Parameters:
-

setRangeRoundingGranularity

public void setRangeRoundingGranularity(Map rangeRoundingGranularity)
A map from a granularity of time specified by a user to the granularity of time used for rounding.

A relative date such as "n days from now" is normally shifted to the end of the day when used as a range endpoint, and the beginning of the day when used as the beginning of a range. (The rounding direction on some item can be specified via +link{relativeDateItem.rangePosition}). This causes the intuitive behavior that "from yesterday to today" is from the beginning of yesterday to the end of today, and that "from today until 5 days from now" includes the entirety of Friday if today is Monday.

This same rule can be applied to any time granularity, such that "from now until 20 minutes from now" is up to 5:32 if it is now 5:11:34, and "from now until 2 months from now" means end of June if it is mid-April.

User intuitions about where this rounding is expected for any given time period tend to vary based on what kind of event is being discussed and subtle phrasing differences (consider "up to one year from now", "until next year", "within the next couple of years"). The defaults behaviors are:

To customize this rounding behavior, this attribute may be set to a Map mapping each timeUnit to the granularity for that timeUnit.
For example the following config code would produce an item where the user could select only day or week values, and the selected value would be rounded to the beginning of the day if a day was selected, or the beginning of the week if a week was selected:
  RelativeDateItem fromDate = new RelativeDateItem("from");
  fromDate.setRangePosition(RelativeDateRangePosition.START);
  fromDate.setTimeUnitOptions(TimeUnit.DAY, TimeUnit.WEEK);
    
  Map roundingMap = new HashMap();
  roundingMap.put(TimeUnit.DAY, TimeUnit.DAY);
  roundingMap.put(TimeUnit.WEEK, TimeUnit.WEEK);
  fromDate.setRangeRoundingGranularity(roundingMap);
 

Parameters:
rangeRoundingGranularity -

setDateFormatter

public void setDateFormatter(DateDisplayFormat dateFormatter)
Format for displaying dates in the valueField and calculatedDateField. Defaults to the system-wide default established by Date.setShortDisplayFormat, or if this item has its type specified as datetime, Date.setShortDatetimeDisplayFormat.

Overrides:
setDateFormatter in class FormItem
Parameters:
dateFormatter - dateFormatter Default value is null
See Also:
FormItem.setTimeFormatter(com.smartgwt.client.types.TimeDisplayFormat), Appearance overview and related methods

setDateFormatter

public void setDateFormatter(DateDisplayFormatter formatter)
Formatter function for displaying dates in the valueField and calculatedDateField in some custom format. Typically the setDateParser(DateParser) method should also be applied to ensure dates can be both formatted and edited date strings parsed back into actual date values.

Parameters:
dateFormatter - dateFormatter Default value is null

setDateParser

public void setDateParser(DateParser parser)
Custom date parser function for direct user input of date values. Typically used in conjunction with setDateFormatter(DateDisplayFormatter).

Note that setDateFormatter(DateDisplayFormat) and setInputFormat(String) already provide a mechanism for customizing the display format for date values displayed in this item.


setEditorValueParser

public void setEditorValueParser(FormItemValueParser parser)
RelativeDateItems do not make use of the standard FormItem.setEditorValueFormatter() and FormItem.setEditorValueParser() methods. Developers can customize the display values for these items in the following ways:

Overrides:
setEditorValueParser in class FormItem
Parameters:
parser - the FormItemValueParser

setEditorValueFormatter

public void setEditorValueFormatter(FormItemValueFormatter formatter)
RelativeDateItems do not make use of the standard FormItem.setEditorValueFormatter() and FormItem.setEditorValueParser() methods. Developers can customize the display values for these items in the following ways:

Overrides:
setEditorValueFormatter in class FormItem
Parameters:
formatter - the FormItemValueFormatter