Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
MicrobaComponent
com.michaelbaranov.microba.calendar.CalendarPane
public class CalendarPane
extends MicrobaComponent
implements CalendarColors
Field Summary | |
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static int |
|
static int |
|
Constructor Summary | |
| |
| |
| |
| |
| |
|
Method Summary | |
void |
|
void |
|
boolean |
|
void |
|
void |
|
void |
|
Date |
|
int |
|
HolidayPolicy |
|
Locale |
|
CalendarResources |
|
int |
|
String | |
VetoPolicy |
|
TimeZone |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
static Date |
|
public static final String PROPERTY_NAME_DATE
The name of a "date" property.
public static final String PROPERTY_NAME_FOCUS_LOST_BEHAVIOR
The name of a "focusLocatBehavior" property.
public static final String PROPERTY_NAME_HOLIDAY_POLICY
The name of a "holidayPolicy" property.
public static final String PROPERTY_NAME_LOCALE
The name of a "locale" property.
public static final String PROPERTY_NAME_RESOURCES
The name of a "resources" property.
public static final String PROPERTY_NAME_SHOW_NONE_BTN
The name of a "showNoneButton" property.
public static final String PROPERTY_NAME_SHOW_NUMBER_WEEK
The name of a "resources" property.
public static final String PROPERTY_NAME_SHOW_TODAY_BTN
The name of a "showTodayButton" property.
public static final String PROPERTY_NAME_STRIP_TIME
The name of a "stripTime" property.
public static final String PROPERTY_NAME_STYLE
The name of a "style" property.
public static final String PROPERTY_NAME_VETO_POLICY
The name of a "vetoPolicy" property.
public static final String PROPERTY_NAME_ZONE
The name of a "zone" property.
public static final int STYLE_CLASSIC
A constant for the "style" property.
- Field Value:
- 32
public static final int STYLE_MODERN
A constant for the "style" property.
- Field Value:
- 16
public CalendarPane()
Constructor.
public CalendarPane(Date initialDate)
Constructor.
public CalendarPane(Date initialDate, int style)
Constructor.
public CalendarPane(Date initialDate, int style, Locale locale)
Constructor.
public CalendarPane(Date initialDate, int style, Locale locale, TimeZone zone)
Constructor.
public CalendarPane(int style)
Constructor.
public void addActionListener(ActionListener listener)
Adds anActionListener
listener.
- Parameters:
listener
- a listener to add
- See Also:
ActionListener
public void addCommitListener(CommitListener listener)
Adds anCommitListener
listener.
- Parameters:
listener
- a listener to add
- See Also:
CommitListener
public boolean commitEdit()
Forces the control to commit current user's edit. The opertaion may fail because the date in the control may be restricted by current veto policy. If successfull, the current date of the control may change, aCommitEvent
is fired.
- Returns:
true
if successful,false
otherwise
public void commitOrRevert()
Forces the control to commit or revert user's edit depending on the current focus lost behavior as if the focus would be lost.
public void fireActionEvent()
Fires aActionEvent
to all registered listeners.
- See Also:
ActionEvent
,ActionListener
public void fireCommitEvent(boolean commit)
Fires aCommitEvent
to all registered listeners.
- Parameters:
commit
-true
to indicate commit,false
to indicate revert
- See Also:
CommitEvent
,CommitListener
public Date getDate()
Returns currently selected date in the control. The returned date is guaranteed to pass the restriction check by the currentVetoPolicy
. Based on the value ofstripTime
property, the returned date may be automatically stripped.
- Returns:
- currently selected date
- See Also:
stripTime
,stripTime(Date,TimeZone,Locale)
public int getFocusLostBehavior()
Returns the focus lost behavior. Possible values are:Original meaning preserved.
JFormattedTextField.COMMIT
JFormattedTextField.COMMIT_OR_REVERT
JFormattedTextField.REVERT
JFormattedTextField.PERSIST
- Returns:
- the focus lost behavior constant
- See Also:
JFormattedTextField
public HolidayPolicy getHolidayPolicy()
Returns current holliday policy (model). The policy is used to query holliday dates and holliday descriptions.
- Returns:
- current holliday policy or
null
if none set
- See Also:
HolidayPolicy
public Locale getLocale()
Returns current locale.
- Returns:
- current locale
public CalendarResources getResources()
Resurns current calendar resources model. The model is used to query localized resources for the control.
- Returns:
- current calendar resources model
- See Also:
CalendarResources
public int getStyle()
Returns current visual style of the control.
- Returns:
- current visual style constant.
public String getUIClassID()
public VetoPolicy getVetoPolicy()
Returns the current veto policy (model). The policy is used to veto dates in the control.
- Returns:
- current veto policy or
null
if none set
- See Also:
VetoPolicy
public TimeZone getZone()
Returns current time zone.
- Returns:
- current time zone
public boolean isShowNoneButton()
Is the none-button visible? The none-button allows the user to select empty date (null-date, no date).
- Returns:
true
if the none-button is visible,false
otherwise
public boolean isShowNumberOfWeek()
Is the number of every week visible?
- Returns:
true
if the number of every week is visible,false
otherwise
public boolean isShowTodayButton()
Is today button visible? The today button allows the user to quickly select current date.
- Returns:
true
if the today button is visible,false
otherwise
public boolean isStripTime()
Is time protion of the date automatically striped, based on current locale and ime zone?
- Returns:
true
ifgetDate()
returns a stripped date,false
otherwise
public void removeActionListener(ActionListener listener)
Removes anActionListener
listener.
- Parameters:
listener
- a listener to remove
- See Also:
ActionListener
public void removeCommitListener(CommitListener listener)
Removes anCommitListener
listener.
- Parameters:
listener
- a listener to remove
- See Also:
CommitListener
public void revertEdit()
Forces the control to revert current user's edit to reflect current control's date. The current date of the control may change, aCommitEvent
is fired.
public void setDate(Date date) throws PropertyVetoException
Sets currently selected date to the control. The given date is checked against the currentVetoPolicy
. If the check is passed, the date is transferred to the control and the control is updated to display the date. APropertyChangeEvent
may be fired, anActionEvent
may be fired.
- Parameters:
date
- the date to set
public void setFocusLostBehavior(int behavior)
Sets the focus lost behaviour. Possible values are:Original meaning preserved.
JFormattedTextField.COMMIT
JFormattedTextField.COMMIT_OR_REVERT
JFormattedTextField.REVERT
JFormattedTextField.PERSIST
- Parameters:
behavior
- the focus lost behavior constant
- See Also:
JFormattedTextField
public void setHolidayPolicy(HolidayPolicy holidayPolicy)
Sets current holliday policy (model) then updates the control to reflect the policy set. The policy is used to query holliday dates and holiday descriptions.
- Parameters:
holidayPolicy
- a holliday policy to set. May benull
- See Also:
VetoPolicy
public void setLocale(Locale locale)
Sets current locale. The locale is used to construct internalCalendar
instances and affects visual representation of the control.
- Parameters:
locale
- the locale to set
public void setResources(CalendarResources resources)
Sets current calendar resources model. The model is used to query localized resources for the control.
- Parameters:
resources
- a calendar resources model to set. Should not benull
- See Also:
CalendarResources
public void setShowNoneButton(boolean visible)
Shows or hides the none-button. The none-button allows the user to select empty date (null-date, no date).
- Parameters:
visible
-true
to show the none-buttonfalse
to hide
public void setShowNumberOfWeek(boolean visible)
Shows or hides the the number of every week. The number of week is based on the current locale for the component.
- Parameters:
visible
-true
to show the the number of every weekfalse
to hide
public void setShowTodayButton(boolean visible)
Shows or hides the today-button. The today-button allows the user to quickly select current date.
- Parameters:
visible
-true
to show the today-buttonfalse
to hide
public void setStripTime(boolean stripTime)
MakesgetDate()
either strip the time portion of the date, or keep it.
- Parameters:
stripTime
-true
to strip time,false
to keep time
public void setStyle(int style)
Sets the current visual style of the control. The control is then updated to reflect the new style.
- Parameters:
style
- the style to set
- See Also:
STYLE_CLASSIC
,STYLE_MODERN
public void setVetoPolicy(VetoPolicy vetoModel)
Sets the current veto policy (model). The policy is used to veto dates in the control.
- Parameters:
vetoModel
- a veto policy to set. May benull
public void setZone(TimeZone zone)
Sets current time zone. The time zone is used to construct internalCalendar
instances and affects visual representation of the control. The dates returned bygetDate()
will have all time components set to zero considering the current locale.
- Parameters:
zone
- the time zone to set
public static Date stripTime(Date date, TimeZone zone, Locale locale)
Returns same date as given, but time portion (hours, minutes, seconds, fraction of second) set to zero, based on given locale and time zone. Utility method. Examle:
Fri Sep 29 15:57:23 EEST 2006 -> Fri Sep 29 00:00:00 EEST 2006
- Parameters:
date
- date to strip time fromzone
- time zone to get zero fields inlocale
- locale to base the calendar on
- Returns:
- stripped date