org.opencms.workplace.list
Class CmsHtmlList

java.lang.Object
  extended by org.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.49 $
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.
protected  int m_currentPage
          Current displayed page number.
protected  CmsListOrderEnum m_currentSortOrder
          Current sort order.
protected  java.util.List m_filteredItems
          Filtered list of items or null if no filter is set and not sorted.
protected  java.lang.String m_id
          Dhtml id.
protected  boolean m_isBoxed
          If this flag is set the list will be surrounded by a box.
protected  int m_maxItemsPerPage
          Maximum number of items per page.
protected  CmsListMetadata m_metadata
          Metadata for building the list.
protected  CmsMessageContainer m_name
          Display Name of the list.
protected  java.util.List m_originalItems
          Really content of the list.
protected  boolean m_printable
          printable flag.
protected  java.lang.String m_searchFilter
          Search filter text.
protected  boolean m_showTitle
          Show the title of the list.
protected  int m_size
          The filtered content size, only used if data self managed.
protected  java.lang.String m_sortedColumn
          Column name to be sorted.
protected  int m_totalSize
          The total size, only used is data self managed.
protected  java.util.List m_visibleItems
          Items currently displayed.
protected  A_CmsListDialog m_wp
          The related workplace dialog object.
static java.lang.String NO_SELECTION_HELP_VAR
          Constant name for error message if no item has been selected.
static java.lang.String NO_SELECTION_MATCH_HELP_VAR
          Constant 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 clear()
          This method resets the content of the list (no the metadata).
protected  int displayedFrom()
          Returns the number (from 1) of the first displayed item.
protected  int displayedTo()
          Returns the number (from 1) of the last displayed item.
 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.
 A_CmsListDialog getWp()
          Returns the workplace dialog object.
protected  java.lang.String htmlBegin()
          Generates the initial html code.
protected  java.lang.String htmlEnd()
          Generates the need html code for ending a list.
static java.lang.String htmlPageSelector(int nrPages, int itemsPage, int nrItems, int curPage, java.util.Locale locale)
          Generates the list of html option elements for a html select control to select a page of a list.
protected  java.lang.String htmlPagingBar()
          Generates the needed html code for the paging bar.
protected  java.lang.String htmlTitle()
          Returns the html for the title of the list.
protected  java.lang.String htmlToolBar()
          Returns the html code for the toolbar (search bar + multiactions bar).
 boolean isBoxed()
          Returns the isBoxed flag.
 boolean isPrintable()
          Returns the printable flag.
 boolean isShowTitle()
          Returns if the list title is shown.
 java.lang.String listCsv()
          Generates the csv output for the list.
 java.lang.String listHtml()
          Generates the html code for the list.
 java.lang.String listJs()
          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()
          Returns html code for printing the list.
 CmsListItem removeItem(java.lang.String id)
          Removes an item from the list.
 void setBoxed(boolean isBoxed)
          Sets the isBoxed flag.
 void setContent(java.util.Collection listItems)
          Sets the list item to display in the list.
 void setCurrentPage(int currentPage)
          Sets the current page.
 void setMaxItemsPerPage(int maxItemsPerPage)
          Sets the maximum number of items per page.
protected  void setMetadata(CmsListMetadata metadata)
          Sets the metadata for this list.
 void setName(CmsMessageContainer name)
          Sets the name of the list.
 void setSearchFilter(java.lang.String searchFilter)
          Sets the search filter.
 void setShowTitle(boolean showTitle)
          Sets if the list title is shown.
 void setSize(int size)
          Sets the current filtered size, only used if data self managed.
 void setSortedColumn(java.lang.String sortedColumn)
          Sets the sorted column.
 void setState(CmsListState listState)
          Sets the list state.
 void setTotalSize(int totalSize)
          Sets the total Size, only used if data self managed.
 void setWp(A_CmsListDialog wp)
          Sets the workplace dialog object.
 
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
Constant 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
Constant name for error message if number of selected items does not match.

See Also:
Constant Field Values

m_currentPage

protected int m_currentPage
Current displayed page number.


m_currentSortOrder

protected CmsListOrderEnum m_currentSortOrder
Current sort order.


m_filteredItems

protected java.util.List m_filteredItems
Filtered list of items or null if no filter is set and not sorted.


m_id

protected final java.lang.String m_id
Dhtml id.


m_isBoxed

protected boolean m_isBoxed
If this flag is set the list will be surrounded by a box.


m_maxItemsPerPage

protected int m_maxItemsPerPage
Maximum number of items per page.


m_metadata

protected CmsListMetadata m_metadata
Metadata for building the list.


m_name

protected CmsMessageContainer m_name
Display Name of the list.


m_originalItems

protected java.util.List m_originalItems
Really content of the list.


m_printable

protected boolean m_printable
printable flag.


m_searchFilter

protected java.lang.String m_searchFilter
Search filter text.


m_showTitle

protected boolean m_showTitle
Show the title of the list.


m_size

protected int m_size
The filtered content size, only used if data self managed.


m_sortedColumn

protected java.lang.String m_sortedColumn
Column name to be sorted.


m_totalSize

protected int m_totalSize
The total size, only used is data self managed.


m_visibleItems

protected java.util.List m_visibleItems
Items currently displayed.


m_wp

protected transient A_CmsListDialog m_wp
The related workplace dialog object.

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

htmlPageSelector

public static java.lang.String htmlPageSelector(int nrPages,
                                                int itemsPage,
                                                int nrItems,
                                                int curPage,
                                                java.util.Locale locale)
Generates the list of html option elements for a html select control to select a page of a list.

Parameters:
nrPages - the total number of pages
itemsPage - the maximum number of items per page
nrItems - the total number of items
curPage - the current page
locale - the locale
Returns:
html code

clear

public void clear()
This method resets the content of the list (no the metadata).


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

getWp

public A_CmsListDialog getWp()
Returns the workplace dialog object.

Returns:
the workplace dialog object

isBoxed

public boolean isBoxed()
Returns the isBoxed flag.

If this flag is set the list will be surrounded by a box.

Returns:
the isBoxed flag

isPrintable

public boolean isPrintable()
Returns the printable flag.

Returns:
the printable flag

isShowTitle

public boolean isShowTitle()
Returns if the list title is shown.

Returns:
true if the list title is shown, otherwise false

listCsv

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

Returns:
csv output

listHtml

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

Returns:
html code

listJs

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

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()
Returns html code for printing the list.

Returns:
html code

removeItem

public CmsListItem removeItem(java.lang.String id)
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
Returns:
the removed list item

setBoxed

public void setBoxed(boolean isBoxed)
Sets the isBoxed flag.

If this flag is set, the list will be surrounded by a box.

Parameters:
isBoxed - the isBoxed flag to set

setContent

public void setContent(java.util.Collection listItems)
Sets the list item to display in the list.

Parameters:
listItems - a collection of CmsListItem objects

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

setName

public void setName(CmsMessageContainer name)
Sets the name of the list.

Parameters:
name - the name of the list

setSearchFilter

public void setSearchFilter(java.lang.String searchFilter)
Sets the search filter.

Parameters:
searchFilter - the search filter to set

setShowTitle

public void setShowTitle(boolean showTitle)
Sets if the list title is shown.

Parameters:
showTitle - true if the list title is shown, otherwise false

setSize

public void setSize(int size)
Sets the current filtered size, only used if data self managed.

Parameters:
size - the size to set

setSortedColumn

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

Parameters:
sortedColumn - the sorted column to set
Throws:
CmsIllegalArgumentException - if the sortedColumn argument is invalid

setState

public void setState(CmsListState listState)
Sets the list state.

This may involve sorting, filtering and paging.

Parameters:
listState - the state to be set

setTotalSize

public void setTotalSize(int totalSize)
Sets the total Size, only used if data self managed.

Parameters:
totalSize - the total Size to set

setWp

public void setWp(A_CmsListDialog wp)
Sets the workplace dialog object.

Parameters:
wp - the workplace dialog object to set

displayedFrom

protected int displayedFrom()
Returns the number (from 1) of the first displayed item.

Returns:
the number (from 1) of the first displayed item, or zero if the list is empty

displayedTo

protected int displayedTo()
Returns the number (from 1) of the last displayed item.

Returns:
the number (from 1) of the last displayed item, or zero if the list is empty

htmlBegin

protected java.lang.String htmlBegin()
Generates the initial html code.

Returns:
html code

htmlEnd

protected java.lang.String htmlEnd()
Generates the need html code for ending a list.

Returns:
html code

htmlPagingBar

protected java.lang.String htmlPagingBar()
Generates the needed html code for the paging bar.

Returns:
html code

htmlTitle

protected java.lang.String htmlTitle()
Returns the html for the title of the list.

Returns:
html code

htmlToolBar

protected java.lang.String htmlToolBar()
Returns the html code for the toolbar (search bar + multiactions bar).

Returns:
html code

setMetadata

protected void setMetadata(CmsListMetadata metadata)
Sets the metadata for this list.

Should only be used by the A_CmsListDialog class for temporally removing the metadata object while the list is saved in the CmsWorkplaceSettings.

Parameters:
metadata - the list metadata