org.primefaces.extensions.model.timeline
Class TimelineModel

java.lang.Object
  extended by org.primefaces.extensions.model.timeline.TimelineModel
All Implemented Interfaces:
java.io.Serializable

public class TimelineModel
extends java.lang.Object
implements java.io.Serializable

Model class for the Timeline component which consists of TimelineEvents.

Since:
0.7 (reimplemented)
Version:
$Revision: 1.0 $
Author:
Oleg Varaksin / last modified by $Author: $
See Also:
Serialized Form

Constructor Summary
TimelineModel()
           
TimelineModel(java.util.List<TimelineEvent> events)
           
 
Method Summary
 void add(TimelineEvent event)
          Adds a given event to the model without UI update.
 void add(TimelineEvent event, TimelineUpdater timelineUpdater)
          Adds a given event to the model with UI update.
 void addAll(java.util.Collection<TimelineEvent> events)
          Adds all given event to the model without UI update.
 void addAll(java.util.Collection<TimelineEvent> events, TimelineUpdater timelineUpdater)
          Adds all given events to the model with UI update.
 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 event)
          Deletes a given event in the model without UI update.
 void delete(TimelineEvent event, TimelineUpdater timelineUpdater)
          Deletes a given event in the model with UI update.
 void deleteAll(java.util.Collection<TimelineEvent> events)
          Deletes all given events in the model without UI update.
 void deleteAll(java.util.Collection<TimelineEvent> events, TimelineUpdater timelineUpdater)
          Deletes all given events in the model with UI update.
 TimelineEvent getEvent(int index)
          Gets event by its index as int
 TimelineEvent getEvent(java.lang.String index)
          Gets event by its index as String
 java.util.List<TimelineEvent> getEvents()
          Gets all events in this model
 int getIndex(TimelineEvent event)
          Gets index of the given timeline event
 java.util.TreeSet<TimelineEvent> getOverlappedEvents(TimelineEvent event)
          Gets all overlapped events to the given one.
 TimelineEvent merge(TimelineEvent event, java.util.Collection<TimelineEvent> events)
          Merge the given one event with the given collection of events without UI update.
 TimelineEvent merge(TimelineEvent event, java.util.Collection<TimelineEvent> events, TimelineUpdater timelineUpdater)
          Merge the given one event with the given collection of events with UI update.
 void select(TimelineEvent event, TimelineUpdater timelineUpdater)
          Selects a given event in UI visually.
 void setEvents(java.util.List<TimelineEvent> events)
          Sets events into this model
 void update(TimelineEvent event)
          Updates a given event in the model without UI update.
 void update(TimelineEvent event, TimelineUpdater timelineUpdater)
          Updates a given event in the model with UI update.
 void updateAll(java.util.Collection<TimelineEvent> events)
          Updates all given events in the model without UI update.
 void updateAll(java.util.Collection<TimelineEvent> events, TimelineUpdater timelineUpdater)
          Updates all given events in the model with UI update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimelineModel

public TimelineModel()

TimelineModel

public TimelineModel(java.util.List<TimelineEvent> events)
Method Detail

add

public void add(TimelineEvent event)
Adds a given event to the model without UI update.

Parameters:
event - event to be added

add

public void add(TimelineEvent event,
                TimelineUpdater timelineUpdater)
Adds a given event to the model with UI update.

Parameters:
event - event to be added
timelineUpdater - TimelineUpdater instance to add the event in UI

addAll

public void addAll(java.util.Collection<TimelineEvent> events)
Adds all given event to the model without UI update.

Parameters:
events - collection of events to be added

addAll

public void addAll(java.util.Collection<TimelineEvent> events,
                   TimelineUpdater timelineUpdater)
Adds all given events to the model with UI update.

Parameters:
events - collection of events to be added
timelineUpdater - TimelineUpdater instance to add the events in UI

update

public void update(TimelineEvent event)
Updates a given event in the model without UI update.

Parameters:
event - event to be updated

update

public void update(TimelineEvent event,
                   TimelineUpdater timelineUpdater)
Updates a given event in the model with UI update.

Parameters:
event - event to be added
timelineUpdater - TimelineUpdater instance to update the event in UI

updateAll

public void updateAll(java.util.Collection<TimelineEvent> events)
Updates all given events in the model without UI update.

Parameters:
events - collection of events to be updated

updateAll

public void updateAll(java.util.Collection<TimelineEvent> events,
                      TimelineUpdater timelineUpdater)
Updates all given events in the model with UI update.

Parameters:
events - collection of events to be updated
timelineUpdater - TimelineUpdater instance to update the events in UI

delete

public void delete(TimelineEvent event)
Deletes a given event in the model without UI update.

Parameters:
event - event to be deleted

delete

public void delete(TimelineEvent event,
                   TimelineUpdater timelineUpdater)
Deletes a given event in the model with UI update.

Parameters:
event - event to be deleted
timelineUpdater - TimelineUpdater instance to delete the event in UI

deleteAll

public void deleteAll(java.util.Collection<TimelineEvent> events)
Deletes all given events in the model without UI update.

Parameters:
events - collection of events to be deleted

deleteAll

public void deleteAll(java.util.Collection<TimelineEvent> events,
                      TimelineUpdater timelineUpdater)
Deletes all given events in the model with UI update.

Parameters:
events - collection of events to be deleted
timelineUpdater - TimelineUpdater instance to delete the events in UI

select

public void select(TimelineEvent event,
                   TimelineUpdater timelineUpdater)
Selects a given event in UI visually. To unselect all events, pass a null as event.

Parameters:
event - event to be selected
timelineUpdater - 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 java.util.TreeSet<TimelineEvent> getOverlappedEvents(TimelineEvent 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 ordered overlapped events or null if no overlapping exist

merge

public TimelineEvent merge(TimelineEvent event,
                           java.util.Collection<TimelineEvent> 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 events
events - collection of events
Returns:
TimelineEvent result event after merging
Throws:
java.lang.IllegalStateException - thrown if not all events are within the same group

merge

public TimelineEvent merge(TimelineEvent event,
                           java.util.Collection<TimelineEvent> 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 events
events - collection of events
timelineUpdater - TimelineUpdater instance to update the merged events in UI
Returns:
TimelineEvent result event after merging
Throws:
java.lang.IllegalStateException - thrown if not all events are within the same group

getEvents

public java.util.List<TimelineEvent> getEvents()
Gets all events in this model

Returns:
List list of events

setEvents

public void setEvents(java.util.List<TimelineEvent> events)
Sets events into this model

Parameters:
events - List list of events

getEvent

public TimelineEvent getEvent(java.lang.String index)
Gets event by its index as String

Parameters:
index - index
Returns:
TimelineEvent found event or null

getEvent

public TimelineEvent getEvent(int index)
Gets event by its index as int

Parameters:
index - index
Returns:
TimelineEvent found event or null

getIndex

public int getIndex(TimelineEvent event)
Gets index of the given timeline event

Parameters:
event - given event
Returns:
int positive index or -1 if the given event is not available in the timeline


Copyright © 2011-2013. All Rights Reserved.