com.cc.framework.ui.painter.def
Class DefListPainter

java.lang.Object
  extended bycom.cc.framework.ui.painter.ControlPainter
      extended bycom.cc.framework.ui.painter.def.DefPainterBase
          extended bycom.cc.framework.ui.painter.def.DefListPainter

public class DefListPainter
extends DefPainterBase

Default painter for Lists

Since:
1.0
Version:
$Revision: 1.153 $
Author:
Harald Schulz

Field Summary
private  CellPainterContext cellPainterContext
          The Cell Painter Context
private  java.util.Map colpaintermap
          The painters for each column of the control
 
Fields inherited from class com.cc.framework.ui.painter.ControlPainter
log
 
Constructor Summary
DefListPainter(PainterContext painterContext, ListControl ctrl)
          Constructor
 
Method Summary
private  void addColumn(ColumnDesignModel column, org.apache.ecs.html.ColGroup colgroup)
          Ads all terminal columns (columns without children) recursively to the column group
protected  void assignColumnPainter(ColumnDesignModel column, ColumnPainter painter)
          Assigns a column painter to a specific column
protected  int calcTableColumns(ColumnDesignModel[] columns)
          This method calculates the number of visible columns
protected  int calcVisibleColumns(ColumnDesignModel column)
          Calculates the number of visible columns.
protected  int calcVisibleColumns(ColumnDesignModel[] columns)
          Calculates the number of visible columns in the given column set.
protected  int calcVisibleDepth(ColumnDesignModel column)
          Calculates the visible depth (number of column child levels) of the given column.
protected  int calcVisibleDepth(ColumnDesignModel[] columns)
          Calculates the visible depth (number of column child levels) of the given column set.
protected  CellPainterContext createCellPainterContext()
          Creates the context class that will be passed to the cell painters.
protected  void createColumnPainters(ColumnDesignModel[] columns)
          Creates a Table with a painter for each column
protected  void doAfterCreate()
          This template method gets called after element creation
protected  void doBeforeCreate()
          This template method gets called before element creation
protected  int doCalcualteTotalWidth(ColumnDesignModel[] columns)
          Calculates the total width for all columns
protected  org.apache.ecs.ConcreteElement doCreateBody(ColumnDesignModel[] columns)
          This method creates the body of the list control
protected  org.apache.ecs.ConcreteElement doCreateBodyDefault(ColumnDesignModel[] columns)
          Creates the body with a fixed (not scrollable) region
protected  org.apache.ecs.ConcreteElement doCreateBodyScrollable(ColumnDesignModel[] columns)
          Creates the body with a scrollable region
protected  void doCreateCells(org.apache.ecs.html.TR row, ColumnDesignModel[] columns, LineIterator iter, DeferredEnvironment env)
          Creates the Data for each cell of a row
protected  org.apache.ecs.ConcreteElement doCreateColGroup(ColumnDesignModel[] columns)
          Creates the HTML <COLGROUP> Element for the list
protected  ColumnPainter doCreateColumnPainter(ColumnDesignModel column)
          This method creates a concrete column painter for a given column object.
protected  org.apache.ecs.ConcreteElement doCreateElement()
          Creates the HTML Code for the following Elements: Title Body Footer (optional)
protected  void doCreateEmptyListCells(org.apache.ecs.html.TR row, ColumnDesignModel[] columns)
          Creates the cells for an "empty list" row
protected  org.apache.ecs.ConcreteElement doCreateExportButton(boolean empty)
          Creates the Export-Button
protected  org.apache.ecs.ConcreteElement doCreateFirstButton(boolean enabled)
          Creates the First-Button
protected  org.apache.ecs.ConcreteElement doCreateFooter()
          Creates an additional footer.
protected  org.apache.ecs.ConcreteElement doCreateFrames(AlignmentType alignmentFilter)
          Creates a frame container with all frames that match the given filter
protected  org.apache.ecs.ConcreteElement doCreateHeader()
          Creates an additional header.
protected  org.apache.ecs.ConcreteElement doCreateHeader(ColumnDesignModel[] columns)
          Creates the Row(s) with the column headers
protected  void doCreateHeaderCells(org.apache.ecs.html.TR[] headerrows, int level, ColumnDesignModel[] columns, boolean showLevel)
          Creates the cells for the given header column
protected  org.apache.ecs.ConcreteElement doCreateLastButton(boolean enabled)
          Creates the Last-Button
protected  java.util.Collection doCreateNavigationButtons()
          Creates the navigation buttons of the list
protected  org.apache.ecs.ConcreteElement doCreateNewButton()
          Creates the New-Button
protected  org.apache.ecs.ConcreteElement doCreateNextButton(boolean enabled, int page)
          Creates the next page Button
protected  org.apache.ecs.ConcreteElement doCreatePageButton(boolean enabled, int page)
          Creates the page Button
protected  org.apache.ecs.ConcreteElement doCreatePageButtonSeperator()
          Creates the separator between page buttons
protected  org.apache.ecs.ConcreteElement doCreatePrevButton(boolean enabled, int page)
          Creates the previous page Button
protected  org.apache.ecs.ConcreteElement doCreatePrintButton(boolean empty)
          Creates the Print-Button
protected  org.apache.ecs.ConcreteElement doCreateRefreshButton()
          Creates the Refresh-Button
protected  org.apache.ecs.ConcreteElement doCreateRows(ColumnDesignModel[] columns, LineIterator iter)
          Creates the rows of the List for the current page
protected  JavaScript doCreateScript()
          Creates the Java Script Code which is needed by the control
protected  java.util.Collection doCreateTitleButtons()
          Creates the buttons in the header of the list
protected  void doPaintCell(org.apache.ecs.html.TD cell, ColumnDesignModel column, LineIterator iter)
          The painter will call this method to paint the cells content
protected  void doPaintHeaderCell(org.apache.ecs.html.TD cell, ColumnDesignModel column)
          The painter will call this method to paint the column headers content
protected  void doPaintRow(org.apache.ecs.html.TR row, ColumnDesignModel[] columns, LineIterator iter, DeferredEnvironment env)
          Creates one row of the List
protected  int getCellPadding()
          Returns the cell padding for the list cells
protected  CellPainterContext getCellPainterContext()
           
protected  int getCellSpacing()
          Returns the cell spacing for the list cells
protected  ColumnPainter getColumnPainter(ColumnDesignModel column)
          Retrieves the column painter for the given column.
protected  ListControl getCtrl()
          Retrieves the control for this painter
protected  int getCurrentPage()
          Returns the number of the current page which is displayed.
protected  java.lang.String getDetailText()
          Returns the detail text for the header The first element in the array is the resource key
 java.lang.String getElementClass(int type)
          The method returns the HTML style class required for a list or treelist control.
protected  FrameTitle getFrameTitle()
          Creates the Title for the Frame
protected  int getMinRowCount()
          Returns the minimal number of rows on the page.
protected  int getPageButtons()
          Returns the number of page buttons to show
protected  java.lang.String getRowClass(int relRowIndex, boolean selected)
          Returns the HTML-Class for a Row
protected  int getRowsPerPage()
          Returns the number of rows on the page.
protected  int getTotalPages()
          Returns the total number of pages.
protected  boolean hasRows()
          Checks if the list control has any rows
protected  boolean isFirstPage()
          Returns true for the FirstPage
protected  boolean isLastPage()
          Returns true for the LastPage
protected  boolean isScrollable()
           
static void registerColumnPainter(java.lang.Class columnClass, ColumnPainter painter)
          Registers a column painter for the given column class
protected  boolean showButton(ControlButton button)
          This Method is called by the Painter before rendering a Button.
protected  boolean showFrame()
          Checks if the frame should be painted
 
Methods inherited from class com.cc.framework.ui.painter.def.DefPainterBase
createHelpElement, createHelpElement, doCreateHelpButton, doCreateHelpIcon
 
Methods inherited from class com.cc.framework.ui.painter.ControlPainter
ajaxPaint, attr, attr, attr, beginPaint, createActionPainter, createActionPainter, createElement, createImage, createImage, createImage, createInput, createInput, createSpacer, createSpacer, createSpacer, decorateURL, doAddDecorationsToRow, doAddDecorationsToRow, doAttachDecorations, encodeURL, endPaint, forceControlName, getAsString, getAwtColor, getColor, getContextPath, getControlName, getDecorationsOnce, getElementName, getFramePainter, getFrameworkString, getFrameworkString, getImage, getImage, getImage, getImageSrc, getImageSrc, getImageSrc, getLocale, getPageContext, getPainterContext, getPrincipal, getRequest, getResponse, getSession, getSmartCaption, getSmartDetail, getSource, getSource, getStringResource, getStyleId, html, html, html, init, isRunAtClient, localize, localize, localize, paint, removeHtml, removeHtml, request, response, session, showComments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colpaintermap

private transient java.util.Map colpaintermap
The painters for each column of the control

See Also:
ColumnPainter

cellPainterContext

private CellPainterContext cellPainterContext
The Cell Painter Context

Constructor Detail

DefListPainter

public DefListPainter(PainterContext painterContext,
                      ListControl ctrl)
Constructor

Parameters:
painterContext - The PainterContext
ctrl - The Control to render
Method Detail

createCellPainterContext

protected CellPainterContext createCellPainterContext()
Creates the context class that will be passed to the cell painters.

Returns:
CellPainterContext

getCtrl

protected ListControl getCtrl()
Retrieves the control for this painter

Returns:
Control

getTotalPages

protected int getTotalPages()
Returns the total number of pages.

Returns:
The total number of pages. Returns -1 if the number of pages is unknown

hasRows

protected boolean hasRows()
Checks if the list control has any rows

Returns:
boolean

getMinRowCount

protected int getMinRowCount()
Returns the minimal number of rows on the page. Returns -1 no empty lines should be displayed.

Returns:
The minimal number of rows on the page

getRowsPerPage

protected int getRowsPerPage()
Returns the number of rows on the page. Returns -1 if all rows should be displayed.

Returns:
The number of rows on the page

getCurrentPage

protected int getCurrentPage()
Returns the number of the current page which is displayed.

Returns:
The number of the current page

isScrollable

protected boolean isScrollable()
Returns:
returns true when the control should render a scrolling body

showButton

protected boolean showButton(ControlButton button)
This Method is called by the Painter before rendering a Button. By overwriting this method a derived class can show or hide buttons.

Parameters:
button - ControlButton
Returns:
boolean

showFrame

protected boolean showFrame()
Checks if the frame should be painted

Returns:
true if the frame should be painted

getPageButtons

protected int getPageButtons()
Returns the number of page buttons to show

Returns:
number of buttons

isFirstPage

protected boolean isFirstPage()
Returns true for the FirstPage

Returns:
boolean

isLastPage

protected boolean isLastPage()
Returns true for the LastPage

Returns:
boolean

getCellSpacing

protected int getCellSpacing()
Returns the cell spacing for the list cells

Returns:
spacing factor

getCellPadding

protected int getCellPadding()
Returns the cell padding for the list cells

Returns:
Padding factor

calcVisibleDepth

protected int calcVisibleDepth(ColumnDesignModel column)
Calculates the visible depth (number of column child levels) of the given column.

Parameters:
column - The root column of a column hierarchy
Returns:
returns the depth.
  • 0 = no column is visible
  • 1 = all Columns have no child columns
  • greater 1 = Columns have child levels

calcVisibleDepth

protected int calcVisibleDepth(ColumnDesignModel[] columns)
Calculates the visible depth (number of column child levels) of the given column set.

Parameters:
columns - The column set (column forest) to calculate
Returns:
returns the depth.
  • 0 = no column is visible
  • 1 = all Columns have no child columns
  • greater 1 = Columns have child levels

calcVisibleColumns

protected int calcVisibleColumns(ColumnDesignModel column)
Calculates the number of visible columns.

Parameters:
column - the root column of a column hierarchy
Returns:
number of visible columns in the column hierarchy

calcVisibleColumns

protected int calcVisibleColumns(ColumnDesignModel[] columns)
Calculates the number of visible columns in the given column set.

Parameters:
columns - column set
Returns:
number of visible columns in the column hierarchy

getRowClass

protected java.lang.String getRowClass(int relRowIndex,
                                       boolean selected)
Returns the HTML-Class for a Row

Parameters:
relRowIndex - relative Row Index
selected - true when the row is selected
Returns:
The style class for this row

getCellPainterContext

protected CellPainterContext getCellPainterContext()
Returns:
The Painter context that is used to render the cells of the list

doCreateNewButton

protected org.apache.ecs.ConcreteElement doCreateNewButton()
Creates the New-Button

Returns:
ConcreteElement

doCreateExportButton

protected org.apache.ecs.ConcreteElement doCreateExportButton(boolean empty)
Creates the Export-Button

Parameters:
empty - Indicates an empty list
Returns:
ConcreteElement

doCreatePrintButton

protected org.apache.ecs.ConcreteElement doCreatePrintButton(boolean empty)
Creates the Print-Button

Parameters:
empty - Indicates an empty list
Returns:
ConcreteElement

doCreateRefreshButton

protected org.apache.ecs.ConcreteElement doCreateRefreshButton()
Creates the Refresh-Button

Returns:
ConcreteElement

doCreateFirstButton

protected org.apache.ecs.ConcreteElement doCreateFirstButton(boolean enabled)
Creates the First-Button

Parameters:
enabled - true if the Button is enabled
Returns:
ConcreteElement

doCreateLastButton

protected org.apache.ecs.ConcreteElement doCreateLastButton(boolean enabled)
Creates the Last-Button

Parameters:
enabled - true if the Button is enabled
Returns:
ConcreteElement

doCreatePrevButton

protected org.apache.ecs.ConcreteElement doCreatePrevButton(boolean enabled,
                                                            int page)
Creates the previous page Button

Parameters:
enabled - true if the Button is enabled
page - page number
Returns:
ConcreteElement

doCreateNextButton

protected org.apache.ecs.ConcreteElement doCreateNextButton(boolean enabled,
                                                            int page)
Creates the next page Button

Parameters:
enabled - true if the Button is enabled
page - page number
Returns:
ConcreteElement

doCreatePageButton

protected org.apache.ecs.ConcreteElement doCreatePageButton(boolean enabled,
                                                            int page)
Creates the page Button

Parameters:
enabled - true if the Button is enabled
page - page number
Returns:
ConcreteElement

doCreateNavigationButtons

protected java.util.Collection doCreateNavigationButtons()
Creates the navigation buttons of the list

Returns:
collection of ConcreteElement Items

doCreatePageButtonSeperator

protected org.apache.ecs.ConcreteElement doCreatePageButtonSeperator()
Creates the separator between page buttons

Returns:
ConcreteElement

doCreateTitleButtons

protected java.util.Collection doCreateTitleButtons()
Creates the buttons in the header of the list

Returns:
collection of ConcreteElement Items

calcTableColumns

protected int calcTableColumns(ColumnDesignModel[] columns)
This method calculates the number of visible columns

Parameters:
columns - The column painters
Returns:
Number of columns for our HTML Table element

addColumn

private void addColumn(ColumnDesignModel column,
                       org.apache.ecs.html.ColGroup colgroup)
Ads all terminal columns (columns without children) recursively to the column group

Parameters:
column - the column to add
colgroup - the column group element

doCreateColGroup

protected org.apache.ecs.ConcreteElement doCreateColGroup(ColumnDesignModel[] columns)
Creates the HTML <COLGROUP> Element for the list

Parameters:
columns - The column painters
Returns:
ConcreteElement

doCreateHeaderCells

protected void doCreateHeaderCells(org.apache.ecs.html.TR[] headerrows,
                                   int level,
                                   ColumnDesignModel[] columns,
                                   boolean showLevel)
Creates the cells for the given header column

Parameters:
headerrows - HTML row elements that make up the header
level - the nesting level of the column
columns - the column list for the current level
showLevel - a value of false indicates that no header elements should be generated for the current header level. When a header cell spans multiple rows we must create only one cell element on the first row!

doCreateHeader

protected org.apache.ecs.ConcreteElement doCreateHeader(ColumnDesignModel[] columns)
Creates the Row(s) with the column headers

Parameters:
columns - The columns (including column groups!)
Returns:
ConcreteElement

doPaintHeaderCell

protected void doPaintHeaderCell(org.apache.ecs.html.TD cell,
                                 ColumnDesignModel column)
The painter will call this method to paint the column headers content

Parameters:
cell - the header cell to render
column - The column

doPaintCell

protected void doPaintCell(org.apache.ecs.html.TD cell,
                           ColumnDesignModel column,
                           LineIterator iter)
The painter will call this method to paint the cells content

Parameters:
cell - the cell to render
column - The column
iter - LineIterator with access to the row bean or null to create an empty row

doCreateCells

protected void doCreateCells(org.apache.ecs.html.TR row,
                             ColumnDesignModel[] columns,
                             LineIterator iter,
                             DeferredEnvironment env)
Creates the Data for each cell of a row

Parameters:
row - The HTML-Row element
columns - The columns (including column groups!)
iter - LineIterator with access to the row bean or null to create an empty row
env - The Environment that should be used to evaluate expressions

doPaintRow

protected void doPaintRow(org.apache.ecs.html.TR row,
                          ColumnDesignModel[] columns,
                          LineIterator iter,
                          DeferredEnvironment env)
Creates one row of the List

Parameters:
row - the Row element
columns - The column painters
iter - LineIterator
env - The Environment that should be used to evaluate expressions

doCreateEmptyListCells

protected void doCreateEmptyListCells(org.apache.ecs.html.TR row,
                                      ColumnDesignModel[] columns)
Creates the cells for an "empty list" row

Parameters:
row - The HTML-Row element
columns - The column painters

doCreateRows

protected org.apache.ecs.ConcreteElement doCreateRows(ColumnDesignModel[] columns,
                                                      LineIterator iter)
Creates the rows of the List for the current page

Parameters:
columns - The column painters
iter - a line iterator for the page to display
Returns:
ConcreteElement

doCreateBody

protected org.apache.ecs.ConcreteElement doCreateBody(ColumnDesignModel[] columns)
This method creates the body of the list control

Parameters:
columns - The column painters
Returns:
ConcreteElement

doCreateBodyDefault

protected org.apache.ecs.ConcreteElement doCreateBodyDefault(ColumnDesignModel[] columns)
Creates the body with a fixed (not scrollable) region

Parameters:
columns - ColumnDesignModel
Returns:
ConcreteElement

doCreateBodyScrollable

protected org.apache.ecs.ConcreteElement doCreateBodyScrollable(ColumnDesignModel[] columns)
Creates the body with a scrollable region

Parameters:
columns - ColumnDesignModel
Returns:
ConcreteElement

doCalcualteTotalWidth

protected int doCalcualteTotalWidth(ColumnDesignModel[] columns)
Calculates the total width for all columns

Parameters:
columns -
Returns:
The total width

doCreateHeader

protected org.apache.ecs.ConcreteElement doCreateHeader()
Creates an additional header.

Returns:
ConcreteElement

doCreateFooter

protected org.apache.ecs.ConcreteElement doCreateFooter()
Creates an additional footer. The current layout does not render a footer

Returns:
ConcreteElement

doCreateFrames

protected org.apache.ecs.ConcreteElement doCreateFrames(AlignmentType alignmentFilter)
Creates a frame container with all frames that match the given filter

Parameters:
alignmentFilter - the filter
Returns:
Frame container or null

registerColumnPainter

public static void registerColumnPainter(java.lang.Class columnClass,
                                         ColumnPainter painter)
Registers a column painter for the given column class

Parameters:
columnClass - the columns class
painter - Column painter instance

doCreateColumnPainter

protected ColumnPainter doCreateColumnPainter(ColumnDesignModel column)
This method creates a concrete column painter for a given column object.

Parameters:
column - the concrete column object
Returns:
a painter instance for the concrete column

createColumnPainters

protected void createColumnPainters(ColumnDesignModel[] columns)
Creates a Table with a painter for each column

Parameters:
columns - The list of columns

getColumnPainter

protected ColumnPainter getColumnPainter(ColumnDesignModel column)
Retrieves the column painter for the given column. Only visible columns have a painter

Parameters:
column - Column
Returns:
painter or null

assignColumnPainter

protected void assignColumnPainter(ColumnDesignModel column,
                                   ColumnPainter painter)
Assigns a column painter to a specific column

Parameters:
column - Column
painter - The CollumnPainter for this column

getFrameTitle

protected FrameTitle getFrameTitle()
Creates the Title for the Frame

Returns:
Frame Title or null

doBeforeCreate

protected void doBeforeCreate()
Description copied from class: ControlPainter
This template method gets called before element creation

Overrides:
doBeforeCreate in class ControlPainter
See Also:
ControlPainter.doBeforeCreate()

doCreateElement

protected org.apache.ecs.ConcreteElement doCreateElement()
Creates the HTML Code for the following Elements:

Specified by:
doCreateElement in class ControlPainter
Returns:
ConcreteElement

doAfterCreate

protected void doAfterCreate()
Description copied from class: ControlPainter
This template method gets called after element creation

Overrides:
doAfterCreate in class ControlPainter
See Also:
ControlPainter.doAfterCreate()

getDetailText

protected java.lang.String getDetailText()
Returns the detail text for the header The first element in the array is the resource key

Returns:
The detail text

getElementClass

public java.lang.String getElementClass(int type)
Description copied from class: ControlPainter
The method returns the HTML style class required for a list or treelist control.

Overrides:
getElementClass in class DefPainterBase
See Also:
ControlPainter.getElementClass(int)

doCreateScript

protected JavaScript doCreateScript()
Creates the Java Script Code which is needed by the control

Returns:
Java Script Code


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.