org.opencms.workplace.list
Class CmsHtmlList

java.lang.Object
  extended byorg.opencms.workplace.list.CmsHtmlList

public class CmsHtmlList
extends java.lang.Object

The main class of the html list widget.

Since:
6.0.0
Version:
$Revision: 1.35 $
Author:
Michael Moossen

Field Summary
static java.lang.String ICON_LEFT
          Standard list button location.
static java.lang.String ICON_RIGHT
          Standard list button location.
static java.lang.String ITEM_SEPARATOR
          Constant for item separator char used for coding/encoding multiselection.
static java.lang.String NO_SELECTION_HELP_VAR
          Var name for error message if no item has been selected.
static java.lang.String NO_SELECTION_MATCH_HELP_VAR
          Var name for error message if number of selected items does not match.
 
Constructor Summary
CmsHtmlList(java.lang.String id, CmsMessageContainer name, CmsListMetadata metadata)
          Default Constructor.
 
Method Summary
 void addAllItems(java.util.Collection listItems)
          Adds a collection new list items to the content of the list.
 void addItem(CmsListItem listItem)
          Adds a new item to the content of the list.
 void clear(java.util.Locale locale)
          This method resets the content of the list (no the metadata).
 java.util.List getAllContent()
          Returns all list items in the list, may be not visible and sorted.
 java.util.List getContent()
          Returns the filtered list of list items.
 int getCurrentPage()
          returns the number of the current page.
 java.util.List getCurrentPageItems()
          Returns all items of the current page.
 CmsListOrderEnum getCurrentSortOrder()
          Returns the current used sort order.
 java.lang.String getId()
          Returns the id.
 CmsListItem getItem(java.lang.String id)
          This method returns the item identified by the parameter id.
 int getMaxItemsPerPage()
          Returns the maximum number of items per page.
 CmsListMetadata getMetadata()
          Returns the metadata.
 CmsMessageContainer getName()
          Returns the name of the list.
 int getNumberOfPages()
          Returns the filtered number of pages.
 java.lang.String getSearchFilter()
          Returns the search filter.
 int getSize()
          Return the filtered number of items.
 java.lang.String getSortedColumn()
          Returns the sorted column's name.
 CmsListState getState()
          Returns a filled list state.
 int getTotalNumberOfPages()
          Returns the total number of pages.
 int getTotalSize()
          Return the total number of items.
 void insertAllItems(java.util.Collection listItems, java.util.Locale locale)
          Inserts a collection of list items in an already initialized list.
 void insertItem(CmsListItem listItem, java.util.Locale locale)
          Inserts an item in an already initialized list.
 boolean isPrintable()
          Returns the printable flag.
 java.lang.String listCsv(CmsWorkplace wp)
          Generates the csv output for the list.
 java.lang.String listHtml(CmsWorkplace wp)
          Generates the html code for the list.
 java.lang.String listJs(java.util.Locale locale)
          Generate the need js code for the list.
 CmsListItem newItem(java.lang.String id)
          Returns a new list item for this list.
 java.lang.String printableHtml(CmsWorkplace wp)
          Returns html code for printing the list.
 java.util.List removeAllItems(java.util.Collection ids, java.util.Locale locale)
          Removes a collection of list items from the list.
 CmsListItem removeItem(java.lang.String id, java.util.Locale locale)
          Removes an item from the list.
 java.util.List replaceAllItems(java.util.List listItems, java.util.Locale locale)
          Replace a list of items in the list.
 CmsListItem replaceItem(CmsListItem listItem, java.util.Locale locale)
          Replace an item in the list.
 void setCurrentPage(int currentPage)
          Sets the current page.
 void setMaxItemsPerPage(int maxItemsPerPage)
          Sets the maximum number of items per page.
 void setSearchFilter(java.lang.String searchFilter, java.util.Locale locale)
          Sets the search filter.
 void setSortedColumn(java.lang.String sortedColumn, java.util.Locale locale)
          Sets the sorted column.
 void setState(CmsListState listState, java.util.Locale locale)
          Sets the list state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_LEFT

public static final java.lang.String ICON_LEFT
Standard list button location.

See Also:
Constant Field Values

ICON_RIGHT

public static final java.lang.String ICON_RIGHT
Standard list button location.

See Also:
Constant Field Values

ITEM_SEPARATOR

public static final java.lang.String ITEM_SEPARATOR
Constant for item separator char used for coding/encoding multiselection.

See Also:
Constant Field Values

NO_SELECTION_HELP_VAR

public static final java.lang.String NO_SELECTION_HELP_VAR
Var name for error message if no item has been selected.

See Also:
Constant Field Values

NO_SELECTION_MATCH_HELP_VAR

public static final java.lang.String NO_SELECTION_MATCH_HELP_VAR
Var name for error message if number of selected items does not match.

See Also:
Constant Field Values
Constructor Detail

CmsHtmlList

public CmsHtmlList(java.lang.String id,
                   CmsMessageContainer name,
                   CmsListMetadata metadata)
Default Constructor.

Parameters:
id - unique id of the list, is used as name for controls and js functions and vars
name - the display name
metadata - the list's metadata
Method Detail

addAllItems

public void addAllItems(java.util.Collection listItems)
Adds a collection new list items to the content of the list.

If you need to add or remove items from or to the list at a later step, use the insertAllItems(Collection, Locale) or removeAllItems(Collection, Locale) methods.

Parameters:
listItems - the collection of list items to add
See Also:
List.addAll(Collection)

addItem

public void addItem(CmsListItem listItem)
Adds a new item to the content of the list.

If you need to add or remove an item from or to the list at a later step, use the insertItem(CmsListItem, Locale) or removeItem(String, Locale) methods.

Parameters:
listItem - the list item
See Also:
List.add(Object)

clear

public void clear(java.util.Locale locale)
This method resets the content of the list (no the metadata).

Parameters:
locale - the locale for sorting/searching

getAllContent

public java.util.List getAllContent()
Returns all list items in the list, may be not visible and sorted.

Returns:
all list items

getContent

public java.util.List getContent()
Returns the filtered list of list items.

Equals to getAllContent() if no filter is set.

Returns:
the filtered list of list items

getCurrentPage

public int getCurrentPage()
returns the number of the current page.

Returns:
the number of the current page

getCurrentPageItems

public java.util.List getCurrentPageItems()
Returns all items of the current page.

Returns:
all items of the current page, a list of CmsListItem objects

getCurrentSortOrder

public CmsListOrderEnum getCurrentSortOrder()
Returns the current used sort order.

Returns:
the current used sort order

getId

public java.lang.String getId()
Returns the id.

Returns:
the id

getItem

public CmsListItem getItem(java.lang.String id)
This method returns the item identified by the parameter id.

Only current visible item can be retrieved using this method.

Parameters:
id - the id of the item to look for
Returns:
the requested item or null if not found

getMaxItemsPerPage

public int getMaxItemsPerPage()
Returns the maximum number of items per page.

Returns:
the maximum number of items per page

getMetadata

public CmsListMetadata getMetadata()
Returns the metadata.

Returns:
the metadata

getName

public CmsMessageContainer getName()
Returns the name of the list.

Returns:
the list's name

getNumberOfPages

public int getNumberOfPages()
Returns the filtered number of pages.

Equals to getTotalNumberOfPages() if no filter is set.

Returns:
the filtered of pages

getSearchFilter

public java.lang.String getSearchFilter()
Returns the search filter.

Returns:
the search filter

getSize

public int getSize()
Return the filtered number of items.

Equals to getTotalSize() if no filter is set.

Returns:
the filtered number of items

getSortedColumn

public java.lang.String getSortedColumn()
Returns the sorted column's name.

Returns:
the sorted column's name

getState

public CmsListState getState()
Returns a filled list state.

Returns:
the state of the list

getTotalNumberOfPages

public int getTotalNumberOfPages()
Returns the total number of pages.

Returns:
the total number of pages

getTotalSize

public int getTotalSize()
Return the total number of items.

Returns:
the total number of items

insertAllItems

public void insertAllItems(java.util.Collection listItems,
                           java.util.Locale locale)
Inserts a collection of list items in an already initialized list.

Keeping care of all the state like sorted column, sorting order, displayed page and search filter.

Parameters:
listItems - the collection of list items to insert
locale - the locale

insertItem

public void insertItem(CmsListItem listItem,
                       java.util.Locale locale)
Inserts an item in an already initialized list.

Keeping care of all the state like sorted column, sorting order, displayed page and search filter.

Parameters:
listItem - the list item to insert
locale - the locale

isPrintable

public boolean isPrintable()
Returns the printable flag.

Returns:
the printable flag

listCsv

public java.lang.String listCsv(CmsWorkplace wp)
Generates the csv output for the list.

Synchronized to not collide with listHtml(CmsWorkplace).

Parameters:
wp - the workplace object
Returns:
csv output

listHtml

public java.lang.String listHtml(CmsWorkplace wp)
Generates the html code for the list.

Synchronized to not collide with printableHtml(CmsWorkplace).

Parameters:
wp - the workplace object
Returns:
html code

listJs

public java.lang.String listJs(java.util.Locale locale)
Generate the need js code for the list.

Parameters:
locale - the locale
Returns:
js code

newItem

public CmsListItem newItem(java.lang.String id)
Returns a new list item for this list.

Parameters:
id - the id of the item has to be unique
Returns:
a new list item

printableHtml

public java.lang.String printableHtml(CmsWorkplace wp)
Returns html code for printing the list.

Synchronized to not collide with listHtml(CmsWorkplace).

Parameters:
wp - the workplace object
Returns:
html code

removeAllItems

public java.util.List removeAllItems(java.util.Collection ids,
                                     java.util.Locale locale)
Removes a collection of list items from the list.

Keeping care of all the state like sorted column, sorting order, displayed page and search filter.

Try to use it instead of A_CmsListDialog.refreshList().

Parameters:
ids - the collection of ids of the items to remove
locale - the locale
Returns:
the list of removed list items

removeItem

public CmsListItem removeItem(java.lang.String id,
                              java.util.Locale locale)
Removes an item from the list.

Keeping care of all the state like sorted column, sorting order, displayed page and search filter.

Try to use it instead of A_CmsListDialog.refreshList().

Parameters:
id - the id of the item to remove
locale - the locale
Returns:
the removed list item

replaceAllItems

public java.util.List replaceAllItems(java.util.List listItems,
                                      java.util.Locale locale)
Replace a list of items in the list.

Keeping care of all the state like sorted column, sorting order, displayed page and search filter.

If the list already contains an item with the id of a given list item, it will be removed and replaced by the new list item. if not, this method is the same as the insertAllItems(Collection, Locale) method. Try to use it instead of A_CmsListDialog.refreshList().

Parameters:
listItems - the list of CmsListItems to replace
locale - the locale
Returns:
the removed list item, or null

replaceItem

public CmsListItem replaceItem(CmsListItem listItem,
                               java.util.Locale locale)
Replace an item in the list.

Keeping care of all the state like sorted column, sorting order, displayed page and search filter.

If the list already contains an item with the id of the given list item, it will be removed and replaced by the new list item. if not, this method is the same as the insertItem(CmsListItem, Locale) method. Try to use it instead of A_CmsListDialog.refreshList().

Parameters:
listItem - the listItem to replace
locale - the locale
Returns:
the removed list item, or null

setCurrentPage

public void setCurrentPage(int currentPage)
                    throws CmsIllegalArgumentException
Sets the current page.

Parameters:
currentPage - the current page to set
Throws:
CmsIllegalArgumentException - if the argument is invalid

setMaxItemsPerPage

public void setMaxItemsPerPage(int maxItemsPerPage)
Sets the maximum number of items per page.

Parameters:
maxItemsPerPage - the maximum number of items per page to set

setSearchFilter

public void setSearchFilter(java.lang.String searchFilter,
                            java.util.Locale locale)
Sets the search filter.

Parameters:
searchFilter - the search filter to set
locale - the used locale for searching/sorting

setSortedColumn

public void setSortedColumn(java.lang.String sortedColumn,
                            java.util.Locale locale)
                     throws CmsIllegalArgumentException
Sets the sorted column.

Parameters:
sortedColumn - the sorted column to set
locale - the used locale for sorting
Throws:
CmsIllegalArgumentException - if the sortedColumn argument is invalid

setState

public void setState(CmsListState listState,
                     java.util.Locale locale)
Sets the list state.

This may involve sorting, filtering and paging.

Parameters:
listState - the state to be set
locale - the locale