Class Timeline

All Implemented Interfaces:
Animatable<Timeline>, CanDrop<Timeline>, Clickable<Timeline>, Draggable<Timeline>, Fetchable<Timeline>, HandleMouseEvents<Timeline>, BasedOnDataDescriptor<Timeline>, Filterable<Timeline>, Scrollable<Timeline>, Touchable<Timeline>

Timeline component

The component displays a timeline. Events and other information can be displayed in a chronological order for the user. The component can read data from the database, and it can display them, using either the default or custom display method. If you need to create a custom timeline item builder class, it must implement the TimelineItemCreator interface, and the class must be specified for the component, by using the setItemCreator(TimelineItemCreator) method. The custom builder class implementation can use any components, and these can be displayed on the individual items, so the items can have their own logic and custom operations.

The component supports multiple display types, that can be set and changed easily. These display types are contained in the Timeline.TimelineType enum

Supported events:

AnimationStart AnimationEnd, Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd

Since:
4.0
Author:
JBStrap
See Also:
  • Constructor Details

    • Timeline

      public Timeline()
      Creates an empty, FLAT timeline component
    • Timeline

      public Timeline(String language)
      Creates an empty, FLAT timeline component, with the specified language
      Parameters:
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
    • Timeline

      public Timeline(String id, String language)
      Creates an empty, FLAT timeline component, with the specified language
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
    • Timeline

      public Timeline(Timeline.TimelineType type)
      Creates an empty timeline component with the specified display type
      Parameters:
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(String language, Timeline.TimelineType type)
      Creates an empty timeline component with the specified display type and language
      Parameters:
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(String id, String language, Timeline.TimelineType type)
      Creates an empty timeline component with the specified display type and language
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(DataDescriptor dataDescriptor, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor and item creator.
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
      See Also:
    • Timeline

      public Timeline(String id, DataDescriptor dataDescriptor, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor and item creator.
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
      See Also:
    • Timeline

      public Timeline(DataDescriptor dataDescriptor, String language, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor, item creator and language.
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
      See Also:
    • Timeline

      public Timeline(String id, DataDescriptor dataDescriptor, String language, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor, item creator and language.
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
      See Also:
    • Timeline

      public Timeline(DataDescriptor dataDescriptor, Timeline.TimelineType type)
      Creates a timeline component with the specified DataDescriptor and display type
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(String id, DataDescriptor dataDescriptor, Timeline.TimelineType type)
      Creates a timeline component with the specified DataDescriptor and display type
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(DataDescriptor dataDescriptor, String language, Timeline.TimelineType type)
      Creates a timeline component with the specified DataDescriptor, language and display type
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(String id, DataDescriptor dataDescriptor, String language, Timeline.TimelineType type)
      Creates a timeline component with the specified DataDescriptor, language and display type
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
    • Timeline

      public Timeline(DataDescriptor dataDescriptor, Timeline.TimelineType type, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor, item creator and display type
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
    • Timeline

      public Timeline(String id, DataDescriptor dataDescriptor, Timeline.TimelineType type, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor, item creator and display type
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
    • Timeline

      public Timeline(DataDescriptor dataDescriptor, String language, Timeline.TimelineType type, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor, language, item creator and display type
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
    • Timeline

      public Timeline(String id, DataDescriptor dataDescriptor, String language, Timeline.TimelineType type, TimelineItemCreator itemCreator)
      Creates a timeline component with the specified DataDescriptor, language, item creator and display type
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      language - The language code according to which the component is created. If not provided or the entered value is null, the component is created using the framework’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
  • Method Details

    • setType

      public final Timeline setType(Timeline.TimelineType type)
      Sets the display type of the timeline component
      Parameters:
      type - The display type to be used. The display types can be found in the Timeline.TimelineType enum. If null, the default type, Timeline.TimelineType.FLAT will be used
      Returns:
      The timeline component
    • getType

      public Timeline.TimelineType getType()
      Gets the timeline component's display type
      Returns:
      The display type
    • setDateFormat

      public Timeline setDateFormat(String dateFormat)
      Sets the date format used by the component. By default, the component uses the framework's default date format. The framework's default date format can be set in the JBStrapParamType.DATE_FORMAT JBStrap parameter
      Parameters:
      dateFormat - The date format to be used by the component. If null, the component will not display dates
      Returns:
      The timeline component
      Throws:
      IllegalArgumentException - If the specified format is an invalid date format
    • getDateFormat

      public final String getDateFormat()
      Gets the component's date format
      Returns:
      The used date format or null, if the component does not display dates
    • formatDate

      protected String formatDate(Date date)
      Parameters:
      date - The date to be formatted
      Returns:
      The specified date, formatted, or an empty string, if the date specified was null, or if the date format set was null
    • setTimeFormat

      public Timeline setTimeFormat(String timeFormat)
      Sets the time format used in the component. By default, the component uses the framework's default date format. The framework's default date format can be set in the JBStrapParamType.TIME_FORMAT JBStrap parameter
      Parameters:
      timeFormat - The time format. If null, no time will be displayed in the component
      Returns:
      The timeline component
      Throws:
      IllegalArgumentException - Occurs if the the specified format is not valid
    • getTimeFormat

      public final String getTimeFormat()
      Gets the component's time format
      Returns:
      The used time format or null, if the component does not display time
    • formatTime

      protected String formatTime(Date date)
      Parameters:
      date - The time to be formatted
      Returns:
      The specified time, formatted, or an empty string, if the time specified was null, or if the time format set was null
    • getCriteria

      public Criteria getCriteria()
      Gets the criteria that is used when querying data. The returned filter criteria contains the default and simple filter criteria, with an "AND" connection.
      Specified by:
      getCriteria in interface Filterable<Timeline>
      Returns:
      The used filter criteria or null if no criteria is used
    • setDefaultCriteria

      public final Timeline setDefaultCriteria(Criteria defaultCriteria)
      Sets the default criteria, used during the data fetch
      Parameters:
      defaultCriteria - The criteria to be used. If null, no default criteria will be used (but the other specified criteria will be used)
      Returns:
      The timeline component
    • getDefaultCriteria

      public final Criteria getDefaultCriteria()
      Gets the default criteria, used during the data fetch
      Returns:
      The default criteria or null, if not specified
    • setFilterCriteria

      public final Timeline setFilterCriteria(Criteria criteria)
      Sets the (simple) filter criteria used when fetching data
      Specified by:
      setFilterCriteria in interface Filterable<Timeline>
      Parameters:
      criteria - The filter criteria to be applied. If null, no criteria will be used, but the set default criteria will still apply
      Returns:
      The timeline component
    • getFilterCriteria

      public final Criteria getFilterCriteria()
      Gets the (simple) filter criteria used when fetching data
      Returns:
      The filter criteria, or null, if it wasn't set
    • setOrderType

      public Timeline setOrderType(OrderType orderType)
      Sets the component's ordering type. By default, the component displays items in a chronological order. The last item will be at the bottom of the component.
      Parameters:
      orderType - The component's order type. The usable types are found in the OrderType enum
      Returns:
      The timeline component
    • getOrderType

      public OrderType getOrderType()
      Gets the component's ordering type.
      Returns:
      The applied order type
    • setDataDescriptor

      public final Timeline setDataDescriptor(DataDescriptor dataDescriptor, TimelineItemCreator itemCreator)
      Sets the component's DataDescriptor and item creator class
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
      Returns:
      The timeline component
    • setDataDescriptor

      public final Timeline setDataDescriptor(DataDescriptor dataDescriptor)
      Sets the component's DataDescriptor
      Specified by:
      setDataDescriptor in interface BasedOnDataDescriptor<Timeline>
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the component can read data from
      Returns:
      The timeline component
    • setItemCreator

      public final Timeline setItemCreator(TimelineItemCreator itemCreator)
      Sets the component's item creator class
      Parameters:
      itemCreator - The timeline item creator class implementation. If null, the default creator class will be used
      Returns:
      The timeline component
    • getDataDescriptor

      public DataDescriptor getDataDescriptor()
      Gets the component's DataDescriptor
      Specified by:
      getDataDescriptor in interface BasedOnDataDescriptor<Timeline>
      Returns:
      The DataDescriptor instance, from which the component can read data from or null, if no DataDescriptor was set
    • getItemCreator

      public TimelineItemCreator getItemCreator()
      Sets the component's item creator
      Returns:
      The instance of the timeline creator class
    • getDateColumnName

      public final String getDateColumnName()
      Gets the name of the DataDescriptor column, that contains the timeline item's data
      Returns:
      The name of the DataDescriptor column, that contains the timeline item's data or null, if not set
    • setDateColumnName

      public final Timeline setDateColumnName(String dateColumnName)
      Sets the name of the DataDescriptor column, that contains the timeline item's data
      Parameters:
      dateColumnName - The name of the DataDescriptor column, that contains the timeline item's data
      Returns:
      The timeline component
    • getTitleColumnName

      public final String getTitleColumnName()
      Gets the name of the DataDescriptor column, that contains the timeline item's title
      Returns:
      The name of the DataDescriptor column, that contains the timeline item's title or null, if not set
    • setTitleColumnName

      public final Timeline setTitleColumnName(String titleColumnName)
      Sets the name of the DataDescriptor column, that contains the timeline item's title
      Parameters:
      titleColumnName - The name of the column that contains the timeline item's title
      Returns:
      The timeline component
    • getDetailColumnName

      public final String getDetailColumnName()
      Gets the name of the DataDescriptor column, that contains the timeline item's description
      Returns:
      The name of the DataDescriptor column, that contains the timeline item's description or null if not set
    • setDetailColumnName

      public final Timeline setDetailColumnName(String detailColumnName)
      Sets the name of the DataDescriptor column, that contains the timeline item's description
      Parameters:
      detailColumnName - The name of the DataDescriptor column, that contains the timeline item's description
      Returns:
      The timeline component
    • getIconColumnName

      public final String getIconColumnName()
      Gets the name of the DataDescriptor column, that contains the timeline item's icon name
      Returns:
      The name of the DataDescriptor column, that contains the timeline item's icon name
    • setIconColumnName

      public final Timeline setIconColumnName(String iconColumnName)
      Sets the name of the DataDescriptor column, that contains the timeline item's icon name
      Parameters:
      iconColumnName - The name of the DataDescriptor column, that contains the timeline item's icon name
      Returns:
      The timeline component
    • getIconBackgroundColumnName

      public final String getIconBackgroundColumnName()
      Gets the name of the DataDescriptor column, that contains the timeline item's icon background color
      Returns:
      The name of the DataDescriptor column, that contains the timeline item's icon background color
    • setIconBackgroundColumnName

      public final Timeline setIconBackgroundColumnName(String iconBackgroundColumnName)
      Sets the name of the DataDescriptor column, that contains the timeline item's icon background color
      Parameters:
      iconBackgroundColumnName - The name of the DataDescriptor column, that contains the timeline item's icon background color
      Returns:
      The timeline component
    • clear

      public final Timeline clear()
      Clears every item from the timeline
      Returns:
      The timeline component
    • fetchData

      public final Timeline fetchData()
      Fetches data from the database. Applies the default and simple criteria, with an "AND" connection
      Specified by:
      fetchData in interface Fetchable<Timeline>
      Specified by:
      fetchData in interface Filterable<Timeline>
      Returns:
      The component
      Throws:
      UnsupportedOperationException - If no DataDescriptor is set, or if no date column name is specified
    • setAutoFetchData

      public Timeline setAutoFetchData(boolean autoFetch)
      Sets if the auto data fetch is enabled. If enabled, the data is fetched automatically after the component is displayed. By default, this functionality is enabled.
      Specified by:
      setAutoFetchData in interface Fetchable<Timeline>
      Specified by:
      setAutoFetchData in interface Filterable<Timeline>
      Parameters:
      autoFetch - If true, the data fetch is automatic, otherwise not. If false, the fetch must be handled by the program logic, by calling the fetchData() method
      Returns:
      The component
    • isAutoFetchData

      public boolean isAutoFetchData()
      Determines if the auto fetch is enabled
      Specified by:
      isAutoFetchData in interface Fetchable<Timeline>
      Specified by:
      isAutoFetchData in interface Filterable<Timeline>
      Returns:
      If true, the automatic data fetch is enabled, otherwise not.
    • onShow

      public void onShow()
      Description copied from class: Component
      The operations to be executed after the component is displayed on the client

      By default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is displayed. This method is nearly identical to the afterDraw() method, they differ in when they are executed. This method runs after the component is displayed on the client. Meaning that it is executed even if the component isn't redrawn, but only set to be visible after being hidden.

      Overrides:
      onShow in class Component<Timeline>
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Timeline>
      Returns:
      If the componentwas drawn, true, otherwise false
    • setCustomFetch

      public Timeline setCustomFetch(FetchEvent fetchEvent)
      Sets a custom query. When calling the fetchData method, the specified FetchEvent implementation is called, then callback methods are run on records returned by the onFetch method.
      Parameters:
      fetchEvent - Custom query implementation
    • fetch

      public List<Record> fetch(int startRow, int endRow, Criteria criteria, List<Order> orders, Client client) throws FindException, DataAccessException
      Description copied from interface: Fetchable
      This method implements actual data retrieval. The Fetchable.fetchData() function runs callback methods on the returned records.
      Specified by:
      fetch in interface Fetchable<Timeline>
      Parameters:
      startRow - The first row of the query that appears in the returned list
      endRow - The last row of the query that appears in the returned list
      criteria - The criteria used during the query If null, no criteria will be used, every record is queried.
      orders - The orderings that will be applied to the query results. If null, the data will not be ordered.
      client - The client that started the query. If null, the query will happen without checking for access rights.
      Returns:
      The list of records that meet the specified filter criteria.
      Throws:
      FindException - Occurs if an error was encountered during the query
      DataAccessException - Occurs if the user in the specified client has no access to read the data