public class Calendar extends Object implements EventTarget
CalendarSource
. These calendar sources are then added to
DateControl.getCalendarSources()
.
// create the calendar and listen to all changes
Calendar calendar = new Calendar("Home");
calendar.addEventHandler(CalendarEvent.ANY, evt -> handleEvent(evt));
// create the calendar source and attach the calendar
CalendarSource source = new CalendarSource("Online Calendars");
source.getCalendars().add(calendar);
// attach the source to the date control / calendar view.
CalendarView view = new CalendarView();
view.getCalendarSources().add(source);
Type | Property and Description |
---|---|
ObjectProperty<Duration> |
lookAheadDuration
Stores a time duration used for the entry search functionality of this
calendar.
|
ObjectProperty<Duration> |
lookBackDuration
Stores a time duration used for the entry search functionality of this
calendar.
|
StringProperty |
name
A property used to store the name of the calendar.
|
BooleanProperty |
readOnly
A property used to control if the calendar is read-only or not.
|
StringProperty |
shortName
A property used to store the short name of the calendar.
|
StringProperty |
style
A property used to store the visual style that will be used for the
calendar in the UI.
|
Modifier and Type | Class and Description |
---|---|
static class |
Calendar.Style
Predefined visual styles for calendars.
|
Constructor and Description |
---|
Calendar()
Constructs a new calendar.
|
Calendar(String name)
Constructs a new calendar with the given name.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntries(Collection<Entry<?>> entries)
Adds the given entries to the calendar.
|
void |
addEntries(Entry<?>... entries)
Adds the given entries to the calendar.
|
void |
addEntries(Iterable<Entry<?>> entries)
Adds the entries returned by the iterable to the calendar.
|
void |
addEntries(Iterator<Entry<?>> entries)
Adds the entries returned by the iterator to the calendar.
|
void |
addEntry(Entry<?> entry)
Adds the given entry to the calendar.
|
void |
addEventHandler(EventHandler<CalendarEvent> l)
Adds an event handler for calendar events.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain givenTail) |
void |
clear()
Removes all entries from the calendar.
|
Map<LocalDate,List<Entry<?>>> |
findEntries(LocalDate startDate,
LocalDate endDate,
ZoneId zoneId)
Queries the calendar for all entries within the time interval defined by
the start date and end date.
|
List<Entry<?>> |
findEntries(String searchText)
Queries the calendar for entries that match the given search text.
|
void |
fireEvent(CalendarEvent evt)
Fires the given calendar event to all event handlers currently registered
with this calendar.
|
Instant |
getEarliestTimeUsed()
Gets the earliest time used by this calendar, that means the start of the
first entry stored.
|
Instant |
getLatestTimeUsed()
Gets the latest time used by this calendar, that means the end of the
last entry stored.
|
Duration |
getLookAheadDuration()
Returns the value of
lookAheadDurationProperty() . |
Duration |
getLookBackDuration()
Returns the value of
lookBackDurationProperty() . |
String |
getName()
Returns the value of
nameProperty() . |
String |
getShortName()
Returns the value of
shortNameProperty() . |
String |
getStyle()
Returns the value of
styleProperty() . |
boolean |
isReadOnly()
Returns the value of
readOnlyProperty() . |
ObjectProperty<Duration> |
lookAheadDurationProperty()
Stores a time duration used for the entry search functionality of this
calendar.
|
ObjectProperty<Duration> |
lookBackDurationProperty()
Stores a time duration used for the entry search functionality of this
calendar.
|
StringProperty |
nameProperty()
A property used to store the name of the calendar.
|
BooleanProperty |
readOnlyProperty()
A property used to control if the calendar is read-only or not.
|
void |
removeEntries(Collection<Entry<?>> entries)
Removes the given entries from the calendar.
|
void |
removeEntries(Entry<?>... entries)
Removes the given entries from the calendar.
|
void |
removeEntries(Iterable<Entry<?>> entries)
Adds the entries returned by the iterable to the calendar.
|
void |
removeEntries(Iterator<Entry<?>> entries)
Removes the entries returned by the iterator from the calendar.
|
void |
removeEntry(Entry<?> entry)
Removes the given entry from the calendar.
|
void |
removeEventHandler(EventHandler<CalendarEvent> l)
Removes an event handler from the calendar.
|
void |
setLookAheadDuration(Duration duration)
Sets the value of
lookAheadDurationProperty() . |
void |
setLookBackDuration(Duration duration)
Sets the value of
lookBackDurationProperty() . |
void |
setName(String name)
Sets the value of
nameProperty() . |
void |
setReadOnly(boolean readOnly)
Sets the value of
readOnlyProperty() . |
void |
setShortName(String name)
Sets the value of
shortNameProperty() . |
void |
setStyle(Calendar.Style style)
Sets the value of
styleProperty() based on one of the predefined
styles (see also the enum Calendar.Style ). |
void |
setStyle(String stylePrefix)
Sets the value of
styleProperty() . |
StringProperty |
shortNameProperty()
A property used to store the short name of the calendar.
|
void |
startBatchUpdates()
Tells the calendar that the application will perform a large number of changes.
|
void |
stopBatchUpdates()
Tells the calendar that the application is done making big changes.
|
StringProperty |
styleProperty()
A property used to store the visual style that will be used for the
calendar in the UI.
|
String |
toString() |
public final ObjectProperty<Duration> lookAheadDurationProperty
public final ObjectProperty<Duration> lookBackDurationProperty
public final StringProperty nameProperty
getName()
,
setName(String)
public final StringProperty shortNameProperty
getShortName()
,
setShortName(String)
public final StringProperty styleProperty
getStyle()
,
setStyle(Style)
public final BooleanProperty readOnlyProperty
isReadOnly()
,
setReadOnly(boolean)
public Calendar()
public Calendar(String name)
name
- the name of the calendarpublic final Instant getEarliestTimeUsed()
public final Instant getLatestTimeUsed()
public final void startBatchUpdates()
stopBatchUpdates()
.public final void stopBatchUpdates()
CalendarEvent.CALENDAR_CHANGED
which
will then force an update of the views.public final Map<LocalDate,List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId)
startDate
- the start of the time intervalendDate
- the end of the time intervalzoneId
- the time zone for which to find entriespublic final ObjectProperty<Duration> lookAheadDurationProperty()
public final void setLookAheadDuration(Duration duration)
lookAheadDurationProperty()
.duration
- the look ahead durationpublic final Duration getLookAheadDuration()
lookAheadDurationProperty()
.public final ObjectProperty<Duration> lookBackDurationProperty()
public final void setLookBackDuration(Duration duration)
lookBackDurationProperty()
.duration
- the look back durationpublic final Duration getLookBackDuration()
lookBackDurationProperty()
.public final List<Entry<?>> findEntries(String searchText)
searchText
- the search textEntry.matches(String)
public final void clear()
CalendarEvent.CALENDAR_CHANGED
event.public final void addEntry(Entry<?> entry)
Entry.setCalendar(Calendar)
.entry
- the entry to addpublic final void addEntries(Entry<?>... entries)
Entry.setCalendar(Calendar)
.entries
- the entries to addpublic final void addEntries(Collection<Entry<?>> entries)
Entry.setCalendar(Calendar)
.entries
- the collection of entries to addpublic final void addEntries(Iterator<Entry<?>> entries)
Entry.setCalendar(Calendar)
.entries
- the entries to addpublic final void addEntries(Iterable<Entry<?>> entries)
Entry.setCalendar(Calendar)
.entries
- the entries to addpublic final void removeEntry(Entry<?> entry)
Entry.setCalendar(Calendar)
.entry
- the entry to removepublic final void removeEntries(Entry<?>... entries)
Entry.setCalendar(Calendar)
.entries
- the entries to removepublic final void removeEntries(Collection<Entry<?>> entries)
Entry.setCalendar(Calendar)
.entries
- the collection of entries to removepublic final void removeEntries(Iterator<Entry<?>> entries)
Entry.setCalendar(Calendar)
.entries
- the entries to removepublic final void removeEntries(Iterable<Entry<?>> entries)
Entry.setCalendar(Calendar)
.entries
- the entries to addpublic final StringProperty nameProperty()
getName()
,
setName(String)
public final void setName(String name)
nameProperty()
.name
- the new name for the calendarpublic final String getName()
nameProperty()
.public final StringProperty shortNameProperty()
getShortName()
,
setShortName(String)
public final void setShortName(String name)
shortNameProperty()
.name
- the new short name for the calendarpublic final String getShortName()
shortNameProperty()
.public final StringProperty styleProperty()
getStyle()
,
setStyle(Style)
public final void setStyle(Calendar.Style style)
styleProperty()
based on one of the predefined
styles (see also the enum Calendar.Style
). The image below shows how the
styles appear in the UI.
style
- the calendar stylepublic final void setStyle(String stylePrefix)
styleProperty()
.stylePrefix
- the calendar stylepublic final String getStyle()
styleProperty()
.public final BooleanProperty readOnlyProperty()
isReadOnly()
,
setReadOnly(boolean)
public final boolean isReadOnly()
readOnlyProperty()
.public final void setReadOnly(boolean readOnly)
readOnlyProperty()
.readOnly
- the calendar can not be edited by the user if truepublic final void addEventHandler(EventHandler<CalendarEvent> l)
l
- the event handler to addpublic final void removeEventHandler(EventHandler<CalendarEvent> l)
l
- the event handler to removepublic final void fireEvent(CalendarEvent evt)
evt
- the event to firepublic final EventDispatchChain buildEventDispatchChain(EventDispatchChain givenTail)
buildEventDispatchChain
in interface EventTarget
Copyright © 2017 Dirk Lemmermann Software & Consulting. All rights reserved.