Class MiniDateRangeItem

All Implemented Interfaces:
HasHandlers, HasBlurHandlers, HasChangedHandlers, HasChangeHandlers, HasClickHandlers, HasDoubleClickHandlers, HasEditorEnterHandlers, HasEditorExitHandlers, HasFocusHandlers, HasIconClickHandlers, HasIconKeyPressHandlers, HasItemHoverHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasPendingStatusChangedHandlers, HasPickerIconClickHandlers, HasShowContextMenuHandlers, HasTitleClickHandlers, HasTitleDoubleClickHandlers, HasTitleHoverHandlers, HasValueHoverHandlers, HasValueIconClickHandlers

public class MiniDateRangeItem extends StaticTextItem
Provides a compact interface for editing a date range, by providing a formatted, read-only display of the current selected date range with an icon to launch a DateRangeDialog to edit the range.
  • Constructor Details

    • MiniDateRangeItem

      public MiniDateRangeItem()
    • MiniDateRangeItem

      public MiniDateRangeItem(JavaScriptObject jsObj)
    • MiniDateRangeItem

      public MiniDateRangeItem(String name)
    • MiniDateRangeItem

      public MiniDateRangeItem(String name, String title)
  • Method Details

    • getOrCreateRef

      public static MiniDateRangeItem getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changePickerIconDefaults

      public static void changePickerIconDefaults(FormItemIcon defaults)
    • setAllowRelativeDates

      public MiniDateRangeItem setAllowRelativeDates(Boolean allowRelativeDates)
      Whether the DateRangeDialog opened when the pickerIcon is clicked should display RelativeDateItems or DateItems.
      Parameters:
      allowRelativeDates - New allowRelativeDates value. Default value is true
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getAllowRelativeDates

      public Boolean getAllowRelativeDates()
      Whether the DateRangeDialog opened when the pickerIcon is clicked should display RelativeDateItems or DateItems.
      Returns:
      Current allowRelativeDates value. Default value is true
    • setAutoValidate

      public MiniDateRangeItem setAutoValidate(Boolean autoValidate)
      If this attribute is set to true, the pop up date range dialog will automatically validate the user-entered "to" and "from" values on "OK"-click, and refuse to dismiss if these items contain invalid values.

      If this method is called after the component has been drawn/initialized: Setter for autoValidate
      Parameters:
      autoValidate - New auto-validate setting. Default value is true
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getAutoValidate

      public Boolean getAutoValidate()
      If this attribute is set to true, the pop up date range dialog will automatically validate the user-entered "to" and "from" values on "OK"-click, and refuse to dismiss if these items contain invalid values.
      Returns:
      Current autoValidate value. Default value is true
    • setCanFocus

      public MiniDateRangeItem setCanFocus(Boolean canFocus)
      MiniDateRangeItems are marked as canFocus:true, and set up with properties such that focus will always go to the icon to launch the dateRange dialog. Set canFocus to false to suppress this behavior.
      Overrides:
      setCanFocus in class FormItem
      Parameters:
      canFocus - New canFocus value. Default value is true
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
      See Also:
    • getCanFocus

      public Boolean getCanFocus()
      MiniDateRangeItems are marked as canFocus:true, and set up with properties such that focus will always go to the icon to launch the dateRange dialog. Set canFocus to false to suppress this behavior.
      Overrides:
      getCanFocus in class FormItem
      Returns:
      Current canFocus value. Default value is true
      See Also:
    • setCanTabToIcons

      public MiniDateRangeItem setCanTabToIcons(Boolean canTabToIcons)
      MiniDateRangeItems rely on their icon being able to receive focus for normal user interaction as they have no other focusable element. canTabToIcons is overridden to achieve this even if the property has been set to false at the form level.

      Note : This is an advanced setting

      Overrides:
      setCanTabToIcons in class FormItem
      Parameters:
      canTabToIcons - New canTabToIcons value. Default value is true
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getCanTabToIcons

      public Boolean getCanTabToIcons()
      MiniDateRangeItems rely on their icon being able to receive focus for normal user interaction as they have no other focusable element. canTabToIcons is overridden to achieve this even if the property has been set to false at the form level.
      Overrides:
      getCanTabToIcons in class FormItem
      Returns:
      Current canTabToIcons value. Default value is true
    • setDateDisplayFormat

      public MiniDateRangeItem setDateDisplayFormat(DateDisplayFormat dateDisplayFormat)
      Format for displaying dates to the user.

      If this attribute is unset, the display value is formatted intelligently according to the dates involved. For example, if both dates appear in the same month, the value will be formatted as

      Month date1 - date2, Year

      and, if in different months of the same year,

      Month1 date1 - Month2 date2, Year.

      If either date-value is unset, the display-value is formatted according to fromDateOnlyPrefix and toDateOnlyPrefix.

      Parameters:
      dateDisplayFormat - New dateDisplayFormat value. Default value is null
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getDateDisplayFormat

      public DateDisplayFormat getDateDisplayFormat()
      Format for displaying dates to the user.

      If this attribute is unset, the display value is formatted intelligently according to the dates involved. For example, if both dates appear in the same month, the value will be formatted as

      Month date1 - date2, Year

      and, if in different months of the same year,

      Month1 date1 - Month2 date2, Year.

      If either date-value is unset, the display-value is formatted according to fromDateOnlyPrefix and toDateOnlyPrefix.

      Returns:
      Current dateDisplayFormat value. Default value is null
    • setFromDateOnlyPrefix

      public MiniDateRangeItem setFromDateOnlyPrefix(String fromDateOnlyPrefix)
      The text to prepend to the formatted date when only a fromDate is supplied.
      Parameters:
      fromDateOnlyPrefix - New fromDateOnlyPrefix value. Default value is "Since"
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getFromDateOnlyPrefix

      public String getFromDateOnlyPrefix()
      The text to prepend to the formatted date when only a fromDate is supplied.
      Returns:
      Current fromDateOnlyPrefix value. Default value is "Since"
    • setPickerIcon

      public MiniDateRangeItem setPickerIcon(FormItemIcon pickerIcon)
      Icon that launches a DateChooser for choosing an absolute date.
      Parameters:
      pickerIcon - New pickerIcon value. Default value is null
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getPickerIcon

      public FormItemIcon getPickerIcon()
      Icon that launches a DateChooser for choosing an absolute date.
      Returns:
      Current pickerIcon value. Default value is null
    • setPickerIconPrompt

      public MiniDateRangeItem setPickerIconPrompt(String pickerIconPrompt)
      The prompt to show when the mouse is hovered over the pickerIcon.
      Overrides:
      setPickerIconPrompt in class FormItem
      Parameters:
      pickerIconPrompt - New pickerIconPrompt value. Default value is "Show Date Chooser"
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
      See Also:
    • getPickerIconPrompt

      public String getPickerIconPrompt()
      The prompt to show when the mouse is hovered over the pickerIcon.
      Overrides:
      getPickerIconPrompt in class FormItem
      Returns:
      Current pickerIconPrompt value. Default value is "Show Date Chooser"
      See Also:
    • getRangeDialog

      public DateRangeDialog getRangeDialog()
      Pop-up DateRangeDialog for entering a date range.

      This component is an AutoChild named "rangeDialog". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current rangeDialog value. Default value is null
    • setShouldSaveValue

      public MiniDateRangeItem setShouldSaveValue(Boolean shouldSaveValue)
      Allow miniDateRangeItems' values to show up in the form's values array, or if DynamicForm.getValuesAsCriteria() is called, for the criterion to be included in the returned AdvancedCriteria object
      Overrides:
      setShouldSaveValue in class FormItem
      Parameters:
      shouldSaveValue - New shouldSaveValue value. Default value is true
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getShouldSaveValue

      public Boolean getShouldSaveValue()
      Allow miniDateRangeItems' values to show up in the form's values array, or if DynamicForm.getValuesAsCriteria() is called, for the criterion to be included in the returned AdvancedCriteria object
      Overrides:
      getShouldSaveValue in class FormItem
      Returns:
      Current shouldSaveValue value. Default value is true
    • setTextBoxStyle

      public MiniDateRangeItem setTextBoxStyle(String textBoxStyle)
      Base CSS class name for a form item's text box element.

      See FormItemStyling for an overview of formItem styling, and the CompoundFormItem_skinning discussion for special skinning considerations.

      If the textBoxStyle is changed at runtime, updateState() must be called to update the visual state of this item.

      Overrides:
      setTextBoxStyle in class StaticTextItem
      Parameters:
      textBoxStyle - New textBoxStyle value. Default value is "textItem"
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
      See Also:
    • getTextBoxStyle

      public String getTextBoxStyle()
      Base CSS class name for a form item's text box element.

      See FormItemStyling for an overview of formItem styling, and the CompoundFormItem_skinning discussion for special skinning considerations.

      If the textBoxStyle is changed at runtime, updateState() must be called to update the visual state of this item.

      Overrides:
      getTextBoxStyle in class StaticTextItem
      Returns:
      Current textBoxStyle value. Default value is "textItem"
      See Also:
    • setToDateOnlyPrefix

      public MiniDateRangeItem setToDateOnlyPrefix(String toDateOnlyPrefix)
      The text to prepend to the formatted date when only a toDate is supplied.
      Parameters:
      toDateOnlyPrefix - New toDateOnlyPrefix value. Default value is "Before"
      Returns:
      MiniDateRangeItem instance, for chaining setter calls
    • getToDateOnlyPrefix

      public String getToDateOnlyPrefix()
      The text to prepend to the formatted date when only a toDate is supplied.
      Returns:
      Current toDateOnlyPrefix value. Default value is "Before"
    • hasAdvancedCriteria

      public Boolean hasAdvancedCriteria()
      Overridden to return true: dateRangeItems always generate AdvancedCriteria.
      Overrides:
      hasAdvancedCriteria in class FormItem
      Returns:
      true
      See Also:
    • setDefaultProperties

      public static void setDefaultProperties(MiniDateRangeItem miniDateRangeItemProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties of the class instance passed to this function. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      miniDateRangeItemProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setFromDate

      public void setFromDate(Date fromDate)
      Initial value for the "from" date. Sets the fromDate for this DateRangeItem.
      Parameters:
      fromDate - the date from which this item should start it's range. Default value is today
    • getFromDate

      public Date getFromDate()
      Initial value for the "from" date.
      Returns:
      java.util.Date
    • setToDate

      public void setToDate(Date toDate)
      Initial value for the "to" date. Sets the toDate for this DateRangeItem.
      Parameters:
      toDate - the date at which this item should end it's range. Default value is today
    • getToDate

      public Date getToDate()
      Initial value for the "to" date.
      Returns:
      java.util.Date
    • getValue

      public DateRange getValue()
      Retrieves the current value of this dateRangeItem. The return value is a DateRange object that excludes start and end values if they aren't set.
      Overrides:
      getValue in class FormItem
      Returns:
      the current value of this item
    • setValue

      public void setValue(DateRange value)
      Sets the value for this dateRangeItem. The value parameter is a DateRange object that optionally includes both start and end values.
      Parameters:
      value - the new value for this item
    • setCriterionGetter

      public void setCriterionGetter(FormItemCriterionGetter getter)
      The default getCriterion() implementation returns the Criterion entered in the fields shown in the rangeDialog.

      If both dates are entered, a Criterion with an "and" operator and both "greaterOrEqual" and "lessOrEqual" sub-criteria will be returned. If either date is omitted, only the "greaterOrEqual" (from date) or "lessOrEqual" (to date) Criterion is returned.

      Overrides:
      setCriterionGetter in class FormItem
      Parameters:
      getter - provides a method to get a criterion object based on this field's current edited value(s).
      See Also: