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:
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionCreates an activity stream component.ActivityStream
(String language) Creates an activity stream component, with the specified language.ActivityStream
(String id, String language) Creates an activity stream component, with the specified language. -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component component) The Activity Stream component can only haveActivityStreamItem
components added to it.final ActivityStream
addItem
(ActivityStreamItem item) Adds an item to the activity stream.final ActivityStream
clear()
Clears every item from the componentdrawSubComponents
(StringWriter writer) Draws the component's subcomponentsThis method implements actual data retrieval.Fetches data from the database.protected final String
formatDate
(Date date) Gets the criteria that is used when querying data.final DataDescriptor
Gets the Activity Stream's DataDescriptorfinal Criteria
Gets the default criteria, used during the data fetchGets the (simple) filter criteria used when fetching dataGets the name of the DataDescriptor column, that contains the event's icon background colorGets the name of the DataDescriptor column, that contains the event's iconGets the custom item renderer class instancefinal List<ActivityStreamItem>
getItems()
Gets a list of every activity stream itemfinal OrderType
Gets the component's ordering type.Gets the name of the DataDescriptor column, that contains the event's parent ID.Gets the name of the DataDescriptor column, that contains the event's text content.Gets the name of the DataDescriptor column, that contains the event timesfinal ActivityStreamType
getType()
Gets the display type of the activity streamGets the name of the DataDescriptor column, that contains the usernames.boolean
Determines if the auto fetch is enabled or not.void
onShow()
The operations to be executed after the component is displayed on the clientprotected List<ActivityStreamItem>
setAutoFetchData
(boolean autoFetch) Sets if the auto data fetch is enabled.setCustomFetch
(FetchEvent fetchEvent) Sets a custom query.final ActivityStream
setDataDescriptor
(DataDescriptor dataDescriptor) Sets the Activity Stream's DataDescriptorfinal ActivityStream
setDataDescriptor
(DataDescriptor dataDescriptor, ActivityStreamItemCreator itemCreator) Sets the Activity Stream's DataDescriptor, and sets the specified custom item renderer.final ActivityStream
setDefaultCriteria
(Criteria criteria) Sets the default criteria, used during the data fetchsetFilterCriteria
(Criteria criteria) Sets the (simple) filter criteria used when fetching datasetIconBackgroundColumnName
(String iconBackgroundColumnName) Sets the name of the DataDescriptor column, that contains the event's icon background colorsetIconColumnName
(String iconColumnName) Sets the name of the DataDescriptor column, that contains the event's iconfinal ActivityStream
setItemCreator
(ActivityStreamItemCreator itemCreator) Sets the custom item renderer.final ActivityStream
setOrderType
(OrderType orderType) Sets the component's ordering type.setParentItemColumnName
(String parentItemColumnName) Sets the name of the DataDescriptor column, that contains the event's parent ID.setTextColumnName
(String textColumnName) Sets the name of the DataDescriptor column, that contains the event's text content.setTimeColumnName
(String timeColumnName) Sets the name of the DataDescriptor column, that contains the event timesfinal ActivityStream
setType
(ActivityStreamType type) Sets the display type of the activity streamsetUsernameColumnName
(String usernameColumnName) Sets the name of the DataDescriptor column, that contains the usernames.boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, init, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.Fetchable
addFetchDoneHandler, fireFetchDoneEvent
Methods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeys
Methods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
Methods inherited from interface com.jbstrap.ui.Scrollable
addScrollHandler
-
Constructor Details
-
ActivityStream
public ActivityStream()Creates an activity stream component. -
ActivityStream
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 parameterJBStrapParamType.DEFAULT_LANGUAGE
.
-
ActivityStream
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 parameterJBStrapParamType.DEFAULT_LANGUAGE
.
-
-
Method Details
-
getType
Gets the display type of the activity stream- Returns:
- The display type of the activity stream
-
setType
Sets the display type of the activity stream- Parameters:
type
- The display type to be used. The display types are listed in theActivityStreamType
enum. Ifnull
the component will use the default display mode (ActivityStreamType.DEFAULT
).- Returns:
- The activity stream component
-
redrawItems
- Returns:
- The activity stream component
-
addItem
Adds an item to the activity stream.- Parameters:
item
- The instance of the item to be added- Returns:
- The activity stream component
-
setOrderType
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 theOrderType
enum- Returns:
- The activity stream component
-
getOrderType
Gets the component's ordering type.- Returns:
- The component's order type
-
addComponent
The Activity Stream component can only haveActivityStreamItem
components added to it. Therefore, this component is practically identical to theaddItem(ActivityStreamItem)
method (it adds the specified item to the component).- Overrides:
addComponent
in classComponent<ActivityStream>
- Parameters:
component
- The component to be added to the activity stream. Only acceptsActivityStreamItem
components, or components that extends from that class- Returns:
- The activity stream component
- Throws:
IllegalArgumentException
- If the specifeid component is not aActivityStreamItem
component
-
orderItems
- Returns:
- The ordered list, that contains the stream items. If the stream contains no items, the list will be empty
-
drawSubComponents
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 classComponent<ActivityStream>
- Parameters:
writer
- The HTML string writer StringWriter instance. This is where the subcomponent's HTML string is written.- Returns:
- The component
-
formatDate
- Parameters:
date
- The date is to be formatted- Returns:
- The converted string, in the specified format, or
null
if the specified date isnull
-
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
Sets the Activity Stream's DataDescriptor- Specified by:
setDataDescriptor
in interfaceBasedOnDataDescriptor<ActivityStream>
- Parameters:
dataDescriptor
- The DataDescriptor instance, from which the activity stream items are read from. Ifnull
, 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. Ifnull
, the component won't be able to read data from the database.itemCreator
- The item renderer class instance. Ifnull
, the items will be created using the default item creator.- Returns:
- The activity stream component
-
getDataDescriptor
Gets the Activity Stream's DataDescriptor- Specified by:
getDataDescriptor
in interfaceBasedOnDataDescriptor<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
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. Ifnull
, the items will be created using the default item creator.- Returns:
- The activity stream component
-
getItemCreator
Gets the custom item renderer class instance- Returns:
- The set custom item renderer instance, or
null
, if none was set
-
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
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
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
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
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
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
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
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
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
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
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
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
Clears every item from the component- Returns:
- The activity stream component
-
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 interfaceFilterable<ActivityStream>
- Returns:
- The used filter criteria
-
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 interfaceFetchable<ActivityStream>
- Specified by:
fetchData
in interfaceFilterable<ActivityStream>
- Returns:
- The activity stream component
- Throws:
UnsupportedOperationException
- If no DataDescriptor was specified for the component, but the method was called
-
setFilterCriteria
Sets the (simple) filter criteria used when fetching data- Specified by:
setFilterCriteria
in interfaceFilterable<ActivityStream>
- Parameters:
criteria
- The filter criteria to be applied. Ifnull
, the criteria won't be set, but if one was previously set, that one will be deleted- Returns:
- The activity stream component
-
getFilterCriteria
Gets the (simple) filter criteria used when fetching data- Returns:
- The filter criteria, or
null
, if it wasn't set
-
setDefaultCriteria
Sets the default criteria, used during the data fetch- Parameters:
criteria
- The criteria to be used- Returns:
- The activity stream component
-
getDefaultCriteria
Gets the default criteria, used during the data fetch- Returns:
- The default criteria or
null
, if not specified
-
setAutoFetchData
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 thefetchData()
method.- Specified by:
setAutoFetchData
in interfaceFetchable<ActivityStream>
- Specified by:
setAutoFetchData
in interfaceFilterable<ActivityStream>
- Parameters:
autoFetch
- Iftrue
, 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 interfaceFetchable<ActivityStream>
- Specified by:
isAutoFetchData
in interfaceFilterable<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 clientBy 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 classComponent<ActivityStream>
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis 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 withfalse
. Otherwise, it must return withtrue
.- Specified by:
writeHTML
in classComponent<ActivityStream>
- Returns:
- If the componentwas drawn,
true
, otherwisefalse
-
setCustomFetch
Sets a custom query. When calling the fetchData method, the specifiedFetchEvent
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. TheFetchable.fetchData()
function runs callback methods on the returned records.- Specified by:
fetch
in interfaceFetchable<ActivityStream>
- Parameters:
startRow
- The first row of the query that appears in the returned listendRow
- The last row of the query that appears in the returned listcriteria
- The criteria used during the query Ifnull
, no criteria will be used, every record is queried.orders
- The orderings that will be applied to the query results. Ifnull
, the data will not be ordered.client
- The client that started the query. Ifnull
, 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 queryDataAccessException
- Occurs if the user in the specified client has no access to read the data
-