Class ActivityStream

All Implemented Interfaces:
Animatable<ActivityStream>, CanDrop<ActivityStream>, Draggable<ActivityStream>, Fetchable<ActivityStream>, HandleHotKey<ActivityStream>, HandleMouseEvents<ActivityStream>, BasedOnDataDescriptor<ActivityStream>, Filterable<ActivityStream>, Scrollable<ActivityStream>

Acitivity stream component

The component displays activity stream items in a chronological order. This component is mainly used for displaying events and comments. Users can comment on events, the previous/replied to comments will be displayed as quotes. The individual items can be displayed under each other, chronologically, (ActivityStreamType.DEFAULT) or grouped by topics, under each other, chronologically (ActivityStreamType.TOPIC_VIEW).

The component can be based on a DataDescriptor, in which case, the displayed items will be built from the specified DataDescriptor columns. The component does not modify the DataDescriptor, it only displays items based on its contents.

The component has a default item renderer, but a custom one can be implemented as well. Items created with the custom renderer can be made of any components, and can have any program logic applied to it. To create a custom renderer, the ActivityStreamItemCreator interface must be implemented. This implemented class can be instantiated by calling the setItemCreator(ActivityStreamItemCreator) method. After it is called, the items will be created with this custom renderer class.

Supported events:

AnimationStart AnimationEnd, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable Drop, DragStart, DragEnd HotKey

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

    • ActivityStream

      public ActivityStream()
      Creates an activity stream component.
    • ActivityStream

      public ActivityStream(String language)
      Creates an activity stream 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.
    • ActivityStream

      public ActivityStream(String id, String language)
      Creates an activity stream 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.
  • Method Details

    • getType

      public final ActivityStreamType getType()
      Gets the display type of the activity stream
      Returns:
      The display type of the activity stream
    • setType

      public final ActivityStream setType(ActivityStreamType type)
      Sets the display type of the activity stream
      Parameters:
      type - The display type to be used. The display types are listed in the ActivityStreamType enum. If null the component will use the default display mode (ActivityStreamType.DEFAULT).
      Returns:
      The activity stream component
    • redrawItems

      public ActivityStream redrawItems()
      Returns:
      The activity stream component
    • addItem

      public final ActivityStream addItem(ActivityStreamItem item)
      Adds an item to the activity stream.
      Parameters:
      item - The instance of the item to be added
      Returns:
      The activity stream component
    • setOrderType

      public final ActivityStream 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 activity stream component
    • getOrderType

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

      public ActivityStream addComponent(Component component)
      The Activity Stream component can only have ActivityStreamItem components added to it. Therefore, this component is practically identical to the addItem(ActivityStreamItem) method (it adds the specified item to the component).
      Overrides:
      addComponent in class Component<ActivityStream>
      Parameters:
      component - The component to be added to the activity stream. Only accepts ActivityStreamItem components, or components that extends from that class
      Returns:
      The activity stream component
      Throws:
      IllegalArgumentException - If the specifeid component is not a ActivityStreamItem component
    • orderItems

      protected List<ActivityStreamItem> orderItems()
      Returns:
      The ordered list, that contains the stream items. If the stream contains no items, the list will be empty
    • drawSubComponents

      public ActivityStream drawSubComponents(StringWriter writer)
      Description copied from class: Component

      Draws the component's subcomponents

      This method doesn't need to be used during application development. This method is used when developing a custom component.

      Overrides:
      drawSubComponents in class Component<ActivityStream>
      Parameters:
      writer - The HTML string writer StringWriter instance. This is where the subcomponent's HTML string is written.
      Returns:
      The component
    • formatDate

      protected final String formatDate(Date date)
      Parameters:
      date - The date is to be formatted
      Returns:
      The converted string, in the specified format, or null if the specified date is null
    • getItems

      public final List<ActivityStreamItem> getItems()
      Gets a list of every activity stream item
      Returns:
      A list containing every assigned activity stream item. If the component has no items, the list will be empty
    • setDataDescriptor

      public final ActivityStream setDataDescriptor(DataDescriptor dataDescriptor)
      Sets the Activity Stream's DataDescriptor
      Specified by:
      setDataDescriptor in interface BasedOnDataDescriptor<ActivityStream>
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the activity stream items are read from. If null, the component won't be able to read data from the database.
      Returns:
      The activity stream component
    • setDataDescriptor

      public final ActivityStream setDataDescriptor(DataDescriptor dataDescriptor, ActivityStreamItemCreator itemCreator)
      Sets the Activity Stream's DataDescriptor, and sets the specified custom item renderer.
      Parameters:
      dataDescriptor - The DataDescriptor instance, from which the activity stream items are read from. If null, the component won't be able to read data from the database.
      itemCreator - The item renderer class instance. If null, the items will be created using the default item creator.
      Returns:
      The activity stream component
    • getDataDescriptor

      public final DataDescriptor getDataDescriptor()
      Gets the Activity Stream's DataDescriptor
      Specified by:
      getDataDescriptor in interface BasedOnDataDescriptor<ActivityStream>
      Returns:
      The DataDescriptor instance, from which the activity stream items are read from, or null if no DataDescriptor was specified for the component
    • setItemCreator

      public final ActivityStream setItemCreator(ActivityStreamItemCreator itemCreator)
      Sets the custom item renderer. If set, the items will be created by the specified class. If not specified, the default one will be used.
      Parameters:
      itemCreator - The item renderer class instance. If null, the items will be created using the default item creator.
      Returns:
      The activity stream component
    • getItemCreator

      public final ActivityStreamItemCreator getItemCreator()
      Gets the custom item renderer class instance
      Returns:
      The set custom item renderer instance, or null, if none was set
    • getUsernameColumnName

      public String getUsernameColumnName()
      Gets the name of the DataDescriptor column, that contains the usernames.
      Returns:
      The name of the DataDescriptor column, that contains the usernames or null, if not set
    • setUsernameColumnName

      public ActivityStream setUsernameColumnName(String usernameColumnName)
      Sets the name of the DataDescriptor column, that contains the usernames.
      Parameters:
      usernameColumnName - The name of the DataDescriptor column, that contains the usernames.
      Returns:
      The activity stream component
    • getTimeColumnName

      public String getTimeColumnName()
      Gets the name of the DataDescriptor column, that contains the event times
      Returns:
      The name of the DataDescriptor column, that contains the event times or null, if not set
    • setTimeColumnName

      public ActivityStream setTimeColumnName(String timeColumnName)
      Sets the name of the DataDescriptor column, that contains the event times
      Parameters:
      timeColumnName - The name of the DataDescriptor column, that contains the event times
      Returns:
      The activity stream component
    • getTextColumnName

      public String getTextColumnName()
      Gets the name of the DataDescriptor column, that contains the event's text content.
      Returns:
      The name of the DataDescriptor column, that contains the event's text content or null, if not set
    • setTextColumnName

      public ActivityStream setTextColumnName(String textColumnName)
      Sets the name of the DataDescriptor column, that contains the event's text content.
      Parameters:
      textColumnName - The name of the DataDescriptor column, that contains the event's text content
      Returns:
      The activity stream component
    • getParentItemColumnName

      public String getParentItemColumnName()
      Gets the name of the DataDescriptor column, that contains the event's parent ID.
      Returns:
      The name of the DataDescriptor column, that contains the event's parent ID or null, if not set
    • setParentItemColumnName

      public ActivityStream setParentItemColumnName(String parentItemColumnName)
      Sets the name of the DataDescriptor column, that contains the event's parent ID.
      Parameters:
      parentItemColumnName - The name of the DataDescriptor column, that contains the event's parent ID
      Returns:
      The activity stream component
    • getIconColumnName

      public String getIconColumnName()
      Gets the name of the DataDescriptor column, that contains the event's icon
      Returns:
      The name of the DataDescriptor column, that contains the event's icon or null, if not set
    • setIconColumnName

      public ActivityStream setIconColumnName(String iconColumnName)
      Sets the name of the DataDescriptor column, that contains the event's icon
      Parameters:
      iconColumnName - The name of the DataDescriptor column, that contains the event's icon
      Returns:
      The activity stream component
    • getIconBackgroundColumnName

      public String getIconBackgroundColumnName()
      Gets the name of the DataDescriptor column, that contains the event's icon background color
      Returns:
      The name of the DataDescriptor column, that contains the event's icon background color or null, if not specified
    • setIconBackgroundColumnName

      public ActivityStream setIconBackgroundColumnName(String iconBackgroundColumnName)
      Sets the name of the DataDescriptor column, that contains the event's icon background color
      Parameters:
      iconBackgroundColumnName - The name of the DataDescriptor column, that contains the event's icon background color
      Returns:
      The activity stream component
    • clear

      public final ActivityStream clear()
      Clears every item from the component
      Returns:
      The activity stream component
    • 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<ActivityStream>
      Returns:
      The used filter criteria
    • fetchData

      public ActivityStream fetchData()
      Fetches data from the database. Both the default and the simple criteria are applied (with "AND"), so only data that meets both criteria are used
      Specified by:
      fetchData in interface Fetchable<ActivityStream>
      Specified by:
      fetchData in interface Filterable<ActivityStream>
      Returns:
      The activity stream component
      Throws:
      UnsupportedOperationException - If no DataDescriptor was specified for the component, but the method was called
    • setFilterCriteria

      public ActivityStream setFilterCriteria(Criteria criteria)
      Sets the (simple) filter criteria used when fetching data
      Specified by:
      setFilterCriteria in interface Filterable<ActivityStream>
      Parameters:
      criteria - The filter criteria to be applied. If null, the criteria won't be set, but if one was previously set, that one will be deleted
      Returns:
      The activity stream component
    • getFilterCriteria

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

      public final ActivityStream setDefaultCriteria(Criteria criteria)
      Sets the default criteria, used during the data fetch
      Parameters:
      criteria - The criteria to be used
      Returns:
      The activity stream component
    • getDefaultCriteria

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

      public ActivityStream 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 disabled, the fetch must be handled by the program logic, by calling the fetchData() method.
      Specified by:
      setAutoFetchData in interface Fetchable<ActivityStream>
      Specified by:
      setAutoFetchData in interface Filterable<ActivityStream>
      Parameters:
      autoFetch - If true, the data fetch is automatic, otherwise not.
      Returns:
      The activity stream component
    • isAutoFetchData

      public boolean isAutoFetchData()
      Determines if the auto fetch is enabled or not.
      Specified by:
      isAutoFetchData in interface Fetchable<ActivityStream>
      Specified by:
      isAutoFetchData in interface Filterable<ActivityStream>
      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<ActivityStream>
    • 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<ActivityStream>
      Returns:
      If the componentwas drawn, true, otherwise false
    • setCustomFetch

      public ActivityStream 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<ActivityStream>
      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