Package org.primefaces.model.timeline
Class TimelineModel<E,G>
- java.lang.Object
-
- org.primefaces.model.timeline.TimelineModel<E,G>
-
- All Implemented Interfaces:
Serializable
public class TimelineModel<E,G> extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TimelineModel()
TimelineModel(List<TimelineEvent<E>> events)
TimelineModel(List<TimelineEvent<E>> events, List<TimelineGroup<G>> groups)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(TimelineEvent<E> event)
Adds a given event to the model without UI update.void
add(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Adds a given event to the model with UI update.void
addAll(Collection<TimelineEvent<E>> events)
Adds all given event to the model without UI update.void
addAll(Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Adds all given events to the model with UI update.void
addAllGroups(Collection<TimelineGroup<G>> groups)
Adds all given groups to the model.void
addGroup(TimelineGroup<G> group)
Adds a given group to the model.void
clear()
Clears the timeline model without UI update (no events are available after that)void
clear(TimelineUpdater timelineUpdater)
Clears the timeline model with UI update (no events are available after that)void
delete(TimelineEvent<E> event)
Deletes a given event in the model without UI update.void
delete(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Deletes a given event in the model with UI update.void
deleteAll(Collection<TimelineEvent<E>> events)
Deletes all given events in the model without UI update.void
deleteAll(Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Deletes all given events in the model with UI update.TimelineEvent<E>
getEvent(String id)
Gets event by its id property.List<TimelineEvent<E>>
getEvents()
Gets all events in this modelList<TimelineGroup<G>>
getGroups()
Gets all groups in this modelSet<TimelineEvent<E>>
getOverlappedEvents(TimelineEvent<E> event)
Gets all overlapped events to the given one.boolean
hasEvent(TimelineEvent<E> event)
Check if current model has the event passed as parameter.TimelineEvent<E>
merge(TimelineEvent<E> event, Collection<TimelineEvent<E>> events)
Merge the given one event with the given collection of events without UI update.TimelineEvent<E>
merge(TimelineEvent<E> event, Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Merge the given one event with the given collection of events with UI update.void
select(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Selects a given event in UI visually.void
setEvents(List<TimelineEvent<E>> events)
Sets events into this modelvoid
setGroups(List<TimelineGroup<G>> groups)
Sets groups into this modelvoid
update(TimelineEvent<E> event)
Updates a given event in the model without UI update.void
update(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Updates a given event in the model with UI update.void
updateAll(Collection<TimelineEvent<E>> events)
Updates all given events in the model without UI update.void
updateAll(Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Updates all given events in the model with UI update.
-
-
-
Constructor Detail
-
TimelineModel
public TimelineModel()
-
TimelineModel
public TimelineModel(List<TimelineEvent<E>> events)
-
TimelineModel
public TimelineModel(List<TimelineEvent<E>> events, List<TimelineGroup<G>> groups)
-
-
Method Detail
-
add
public void add(TimelineEvent<E> event)
Adds a given event to the model without UI update.- Parameters:
event
- event to be added
-
addGroup
public void addGroup(TimelineGroup<G> group)
Adds a given group to the model.- Parameters:
group
- group to be added
-
add
public void add(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Adds a given event to the model with UI update.- Parameters:
event
- event to be addedtimelineUpdater
- TimelineUpdater instance to add the event in UI
-
addAll
public void addAll(Collection<TimelineEvent<E>> events)
Adds all given event to the model without UI update.- Parameters:
events
- collection of events to be added
-
addAllGroups
public void addAllGroups(Collection<TimelineGroup<G>> groups)
Adds all given groups to the model.- Parameters:
groups
- collection of groups to be added
-
addAll
public void addAll(Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Adds all given events to the model with UI update.- Parameters:
events
- collection of events to be addedtimelineUpdater
- TimelineUpdater instance to add the events in UI
-
update
public void update(TimelineEvent<E> event)
Updates a given event in the model without UI update.- Parameters:
event
- event to be updated
-
update
public void update(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Updates a given event in the model with UI update.- Parameters:
event
- event to be addedtimelineUpdater
- TimelineUpdater instance to update the event in UI
-
updateAll
public void updateAll(Collection<TimelineEvent<E>> events)
Updates all given events in the model without UI update.- Parameters:
events
- collection of events to be updated
-
updateAll
public void updateAll(Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Updates all given events in the model with UI update.- Parameters:
events
- collection of events to be updatedtimelineUpdater
- TimelineUpdater instance to update the events in UI
-
delete
public void delete(TimelineEvent<E> event)
Deletes a given event in the model without UI update.- Parameters:
event
- event to be deleted
-
delete
public void delete(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Deletes a given event in the model with UI update.- Parameters:
event
- event to be deletedtimelineUpdater
- TimelineUpdater instance to delete the event in UI
-
deleteAll
public void deleteAll(Collection<TimelineEvent<E>> events)
Deletes all given events in the model without UI update.- Parameters:
events
- collection of events to be deleted
-
deleteAll
public void deleteAll(Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Deletes all given events in the model with UI update.- Parameters:
events
- collection of events to be deletedtimelineUpdater
- TimelineUpdater instance to delete the events in UI
-
select
public void select(TimelineEvent<E> event, TimelineUpdater timelineUpdater)
Selects a given event in UI visually. To unselect all events, pass a null as event.- Parameters:
event
- event to be selectedtimelineUpdater
- TimelineUpdater instance to select the event in UI
-
clear
public void clear()
Clears the timeline model without UI update (no events are available after that)
-
clear
public void clear(TimelineUpdater timelineUpdater)
Clears the timeline model with UI update (no events are available after that)- Parameters:
timelineUpdater
- TimelineUpdater instance to clear the timeline in UI
-
getOverlappedEvents
public Set<TimelineEvent<E>> getOverlappedEvents(TimelineEvent<E> event)
Gets all overlapped events to the given one. The given and overlapped events belong to the same group. Events are ordered by their start dates - first events with more recent start dates and then events with older start dates. If start dates are equal, events will be ordered by their end dates. In this case, if an event has a null end date, it is ordered before the event with a not null end date.- Parameters:
event
- given event- Returns:
- TreeSet<TimelineEvent<E>> ordered overlapped events or null if no overlapping exist
-
merge
public TimelineEvent<E> merge(TimelineEvent<E> event, Collection<TimelineEvent<E>> events)
Merge the given one event with the given collection of events without UI update. Only events within one group can be merged. Note: after merging, the merged event will get the same properties as the given one event except start and end dates.- Parameters:
event
- given event to be merged with collection of eventsevents
- collection of events- Returns:
- TimelineEvent result event after merging
- Throws:
IllegalStateException
- thrown if not all events are within the same group
-
merge
public TimelineEvent<E> merge(TimelineEvent<E> event, Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater)
Merge the given one event with the given collection of events with UI update. Only events within one group can be merged. Note: after merging, the merged event will get the same properties as the given one event except start and end dates.- Parameters:
event
- given event to be merged with collection of eventsevents
- collection of eventstimelineUpdater
- TimelineUpdater instance to update the merged events in UI- Returns:
- TimelineEvent result event after merging
- Throws:
IllegalStateException
- thrown if not all events are within the same group
-
getEvents
public List<TimelineEvent<E>> getEvents()
Gets all events in this model- Returns:
- List<TimelineEvent<E>> list of events
-
setEvents
public void setEvents(List<TimelineEvent<E>> events)
Sets events into this model- Parameters:
events
- List<TimelineEvent<E>> list of events
-
getGroups
public List<TimelineGroup<G>> getGroups()
Gets all groups in this model- Returns:
- List<TimelineGroup<G>> list of groups
-
setGroups
public void setGroups(List<TimelineGroup<G>> groups)
Sets groups into this model- Parameters:
groups
- List<TimelineGroup<G>> list of groups
-
getEvent
public TimelineEvent<E> getEvent(String id)
Gets event by its id property.- Parameters:
id
- id property of the event- Returns:
- TimelineEvent found event or null
-
hasEvent
public boolean hasEvent(TimelineEvent<E> event)
Check if current model has the event passed as parameter.- Parameters:
event
-- Returns:
-
-