org.cruxframework.crux.widgets.client.datepicker
Class DatePicker

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.cruxframework.crux.widgets.client.datepicker.DatePicker
All Implemented Interfaces:
com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.client.LeafValueEditor<Date>>, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasHighlightHandlers<Date>, com.google.gwt.event.logical.shared.HasShowRangeHandlers<Date>, com.google.gwt.event.logical.shared.HasValueChangeHandlers<Date>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.TakesValue<Date>, com.google.gwt.user.client.ui.HasValue<Date>, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget, CruxWidget

public class DatePicker
extends com.google.gwt.user.client.ui.Composite
implements CruxWidget

Author:
Samuel Almeida Cardoso (samuel@cruxframework.org)

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
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
DatePicker()
           
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addHighlightHandler(com.google.gwt.event.logical.shared.HighlightHandler<Date> handler)
           
 com.google.gwt.event.shared.HandlerRegistration addShowRangeHandler(com.google.gwt.event.logical.shared.ShowRangeHandler<Date> handler)
           
 com.google.gwt.event.shared.HandlerRegistration addShowRangeHandlerAndFire(com.google.gwt.event.logical.shared.ShowRangeHandler<Date> handler)
          Adds a show range handler and immediately activate the handler on the current view.
 void addStyleToDates(String styleName, Date date)
          Add a style name to the given dates.
 void addStyleToDates(String styleName, Date date, Date... moreDates)
          Add a style name to the given dates.
 void addStyleToDates(String styleName, Date initDate, Date finalDate)
          Add a style name to the given dates.
 void addStyleToDates(String styleName, Iterable<Date> dates)
          Add a style name to the given dates.
 void addTransientStyleToDates(String styleName, Date date)
          Adds the given style name to the specified dates, which must be visible.
 void addTransientStyleToDates(String styleName, Date date, Date... moreDates)
          Adds the given style name to the specified dates, which must be visible.
 void addTransientStyleToDates(String styleName, Iterable<Date> dates)
          Adds the given style name to the specified dates, which must be visible.
 com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Date> handler)
           
 com.google.gwt.editor.client.LeafValueEditor<Date> asEditor()
          Returns a TakesValueEditor backed by the DatePicker.
 String getBaseStyleName()
           
 Date getCurrentMonth()
          Gets the current month the date picker is showing.
 Date getFirstDate()
          Returns the first shown date.
 Date getHighlightedDate()
          Gets the highlighted date (the one the mouse is hovering over), if any.
 Date getLastDate()
          Returns the last shown date.
protected  org.cruxframework.crux.widgets.client.datepicker.GWTOverriddenCalendarModel getModel()
          Gets the GWTOverriddenCalendarModel associated with this date picker.
 org.cruxframework.crux.widgets.client.datepicker.GWTOverriddenMonthSelector getMonthSelector()
          Gets the GWTOverriddenMonthSelector associated with this date picker.
 Date getMonthToOpen()
           
 String getStyleOfDate(Date date)
          Gets the style associated with a date (does not include styles set via addTransientStyleToDates(java.lang.String, java.util.Date)).
 Date getValue()
          Returns the selected date, or null if none is selected.
 org.cruxframework.crux.widgets.client.datepicker.GWTOverriddenCalendarView getView()
          Gets the GWTOverriddenCalendarView associated with this date picker.
 int getVisibleYearCount()
          Returns the number of year to display in the years selection dropdown.
 boolean isDateEnabled(Date date)
          Is the visible date enabled?
 boolean isDateVisible(Date date)
          Is the date currently shown in the date picker?
 boolean isYearAndMonthDropdownVisible()
          Is the year and month selectable via a dropdown?
 boolean isYearArrowsVisible()
          Can the user navigate through the years?
 void onLoad()
           
protected  void refreshAll()
          Refreshes all components of this date picker.
 void removeStyleFromDates(String styleName, Date date)
          Removes the styleName from the given dates (even if it is transient).
 void removeStyleFromDates(String styleName, Date date, Date... moreDates)
          Removes the styleName from the given dates (even if it is transient).
 void removeStyleFromDates(String styleName, Iterable<Date> dates)
          Removes the styleName from the given dates (even if it is transient).
 void setCurrentMonth(Date month)
          Sets the date picker to show the given month, use getFirstDate() and getLastDate() to access the exact date range the date picker chose to display.
 void setMonthToOpen(Date monthToOpen)
           
 void setStyleName(String styleName)
          Sets the date picker style name.
 void setTransientEnabledOnDates(boolean enabled, Date date)
          Sets a visible date to be enabled or disabled.
 void setTransientEnabledOnDates(boolean enabled, Date date, Date... moreDates)
          Sets a visible date to be enabled or disabled.
 void setTransientEnabledOnDates(boolean enabled, Iterable<Date> dates)
          Sets a group of visible dates to be enabled or disabled.
protected  void setup()
          Sets up the date picker.
 void setValue(Date newValue)
          Sets the GWTOverriddenDatePicker's value.
 void setValue(Date newValue, boolean fireEvents)
          Sets the GWTOverriddenDatePicker's value.
 void setVisibleYearCount(int numberOfYears)
          Set the number of years to display in the years selection dropdown.
 void setYearAndMonthDropdownVisible(boolean dropdownVisible)
          If the dropdownVisible is equal to true, the user will be able to change the current month and the current year of the date picker via two dropdown lists.
 void setYearArrowsVisible(boolean yearArrowsVisible)
          Set if the user can navigate through the years via a set of backward and forward buttons.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, 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, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, 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.IsWidget
asWidget
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

DatePicker

public DatePicker()
Method Detail

getBaseStyleName

public String getBaseStyleName()
Specified by:
getBaseStyleName in interface CruxWidget
Returns:
the default widget style name

addStyleToDates

public void addStyleToDates(String styleName,
                            Date initDate,
                            Date finalDate)
Add a style name to the given dates.


getMonthToOpen

public Date getMonthToOpen()

setMonthToOpen

public void setMonthToOpen(Date monthToOpen)

addHighlightHandler

public com.google.gwt.event.shared.HandlerRegistration addHighlightHandler(com.google.gwt.event.logical.shared.HighlightHandler<Date> handler)
Specified by:
addHighlightHandler in interface com.google.gwt.event.logical.shared.HasHighlightHandlers<Date>

addShowRangeHandler

public com.google.gwt.event.shared.HandlerRegistration addShowRangeHandler(com.google.gwt.event.logical.shared.ShowRangeHandler<Date> handler)
Specified by:
addShowRangeHandler in interface com.google.gwt.event.logical.shared.HasShowRangeHandlers<Date>

addShowRangeHandlerAndFire

public com.google.gwt.event.shared.HandlerRegistration addShowRangeHandlerAndFire(com.google.gwt.event.logical.shared.ShowRangeHandler<Date> handler)
Adds a show range handler and immediately activate the handler on the current view.

Parameters:
handler - the handler
Returns:
the handler registration

addStyleToDates

public void addStyleToDates(String styleName,
                            Date date)
Add a style name to the given dates.


addStyleToDates

public void addStyleToDates(String styleName,
                            Date date,
                            Date... moreDates)
Add a style name to the given dates.


addStyleToDates

public void addStyleToDates(String styleName,
                            Iterable<Date> dates)
Add a style name to the given dates.


addTransientStyleToDates

public void addTransientStyleToDates(String styleName,
                                     Date date)
Adds the given style name to the specified dates, which must be visible. This is only set until the next time the DatePicker is refreshed.


addTransientStyleToDates

public final void addTransientStyleToDates(String styleName,
                                           Date date,
                                           Date... moreDates)
Adds the given style name to the specified dates, which must be visible. This is only set until the next time the DatePicker is refreshed.


addTransientStyleToDates

public final void addTransientStyleToDates(String styleName,
                                           Iterable<Date> dates)
Adds the given style name to the specified dates, which must be visible. This is only set until the next time the DatePicker is refreshed.


addValueChangeHandler

public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Date> handler)
Specified by:
addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<Date>

asEditor

public com.google.gwt.editor.client.LeafValueEditor<Date> asEditor()
Returns a TakesValueEditor backed by the DatePicker.

Specified by:
asEditor in interface com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.client.LeafValueEditor<Date>>

getCurrentMonth

public Date getCurrentMonth()
Gets the current month the date picker is showing.

A datepicker may show days not in the current month. It must show all days in the current month.

Returns:
the current month

getFirstDate

public final Date getFirstDate()
Returns the first shown date.

Returns:
the first date.

getHighlightedDate

public final Date getHighlightedDate()
Gets the highlighted date (the one the mouse is hovering over), if any.

Returns:
the highlighted date

getLastDate

public final Date getLastDate()
Returns the last shown date.

Returns:
the last date.

getVisibleYearCount

public int getVisibleYearCount()
Returns the number of year to display in the years selection dropdown.


getStyleOfDate

public String getStyleOfDate(Date date)
Gets the style associated with a date (does not include styles set via addTransientStyleToDates(java.lang.String, java.util.Date)).

Parameters:
date - the date
Returns:
the styles associated with this date

getValue

public final Date getValue()
Returns the selected date, or null if none is selected.

Specified by:
getValue in interface com.google.gwt.user.client.TakesValue<Date>
Specified by:
getValue in interface com.google.gwt.user.client.ui.HasValue<Date>
Returns:
the selected date, or null

isDateEnabled

public boolean isDateEnabled(Date date)
Is the visible date enabled?

Parameters:
date - the date, which must be visible
Returns:
is the date enabled?

isDateVisible

public boolean isDateVisible(Date date)
Is the date currently shown in the date picker?

Parameters:
date -
Returns:
is the date currently shown

isYearArrowsVisible

public boolean isYearArrowsVisible()
Can the user navigate through the years?

Returns:
is the year navigation is enabled

isYearAndMonthDropdownVisible

public boolean isYearAndMonthDropdownVisible()
Is the year and month selectable via a dropdown?


onLoad

public void onLoad()
Overrides:
onLoad in class com.google.gwt.user.client.ui.Widget

removeStyleFromDates

public void removeStyleFromDates(String styleName,
                                 Date date)
Removes the styleName from the given dates (even if it is transient).


removeStyleFromDates

public void removeStyleFromDates(String styleName,
                                 Date date,
                                 Date... moreDates)
Removes the styleName from the given dates (even if it is transient).


removeStyleFromDates

public void removeStyleFromDates(String styleName,
                                 Iterable<Date> dates)
Removes the styleName from the given dates (even if it is transient).


setCurrentMonth

public void setCurrentMonth(Date month)
Sets the date picker to show the given month, use getFirstDate() and getLastDate() to access the exact date range the date picker chose to display.

A datepicker may show days not in the current month. It must show all days in the current month.

Parameters:
month - the month to show

setVisibleYearCount

public void setVisibleYearCount(int numberOfYears)
Set the number of years to display in the years selection dropdown. The range of years will be centered on the selected date.


setYearArrowsVisible

public void setYearArrowsVisible(boolean yearArrowsVisible)
Set if the user can navigate through the years via a set of backward and forward buttons.


setYearAndMonthDropdownVisible

public void setYearAndMonthDropdownVisible(boolean dropdownVisible)
If the dropdownVisible is equal to true, the user will be able to change the current month and the current year of the date picker via two dropdown lists.


setStyleName

public void setStyleName(String styleName)
Sets the date picker style name.

Overrides:
setStyleName in class com.google.gwt.user.client.ui.UIObject

setTransientEnabledOnDates

public final void setTransientEnabledOnDates(boolean enabled,
                                             Date date)
Sets a visible date to be enabled or disabled. This is only set until the next time the DatePicker is refreshed.


setTransientEnabledOnDates

public final void setTransientEnabledOnDates(boolean enabled,
                                             Date date,
                                             Date... moreDates)
Sets a visible date to be enabled or disabled. This is only set until the next time the DatePicker is refreshed.


setTransientEnabledOnDates

public final void setTransientEnabledOnDates(boolean enabled,
                                             Iterable<Date> dates)
Sets a group of visible dates to be enabled or disabled. This is only set until the next time the DatePicker is refreshed.


setValue

public final void setValue(Date newValue)
Sets the GWTOverriddenDatePicker's value.

Specified by:
setValue in interface com.google.gwt.user.client.TakesValue<Date>
Specified by:
setValue in interface com.google.gwt.user.client.ui.HasValue<Date>
Parameters:
newValue - the new value

setValue

public final void setValue(Date newValue,
                           boolean fireEvents)
Sets the GWTOverriddenDatePicker's value.

Specified by:
setValue in interface com.google.gwt.user.client.ui.HasValue<Date>
Parameters:
newValue - the new value for this date picker
fireEvents - should events be fired.

getModel

protected final org.cruxframework.crux.widgets.client.datepicker.GWTOverriddenCalendarModel getModel()
Gets the GWTOverriddenCalendarModel associated with this date picker.

Returns:
the model

getMonthSelector

public final org.cruxframework.crux.widgets.client.datepicker.GWTOverriddenMonthSelector getMonthSelector()
Gets the GWTOverriddenMonthSelector associated with this date picker.

Returns:
the month selector

getView

public final org.cruxframework.crux.widgets.client.datepicker.GWTOverriddenCalendarView getView()
Gets the GWTOverriddenCalendarView associated with this date picker.

Returns:
the view

refreshAll

protected final void refreshAll()
Refreshes all components of this date picker.


setup

protected void setup()
Sets up the date picker.



Copyright © 2015. All rights reserved.