Package com.dassault_systemes.catjdialog

   
Class CATKeyTableModel

 
Class Hierarchy
java.lang.Object
  |
  +-com.dassault_systemes.catjdialog.CATCallbackSource
        |
        +-com.dassault_systemes.catjdialog.CATKeyTableModel
Class Location

Framework : CATJDialog

Module : CATJDialog

Class Description

public abstract class CATKeyTableModel

The key table model is the interface used to feed a table component with content.

Data Model: a JDialog pattern

When using a tree or a table component, the application has to provide a data model object, that is in charge of feeding the component with presentation data.

This design allows JDialog to request presentation data only when rendering the tree or table component to the Graphical User Interface (GUI), and to forget it right after that.

The Key: a common language between JDialog and the application

The key table model identifies table rows with a key (that is a string identifier).
At render time, the model is asked for presentation data and keys.
When an event occurs on the GUI, the source table row(s) or table cell(s) is (are) identified with its (their) key(s).

Example: a Table with a CATKeyTableModel and a controller listening to cell selection notifications

How to choose the key?

Basically, the key should contain enough information for the application to identify clearly the related data. Example: a Table that shows a database query result
If a row presented in the table corresponds to a database n-uplet, then the key should obviously be the database table key.
If a table row corresponds to a combination of database n-uplets, then the key should be a combination (concatenation) of the required database tables keys.

CATTable methods related to the key table model

See the CAA technical article "Writing Stateless Controllers" for a stateless design sample.

   All Implemented Interfaces:
CATRequestListener
See Also:
com.dassault_systemes.catjdialog.CATTable
Field Summary
public static final int ALIGN_CENTER
Column alignment: center
public static final int ALIGN_LEFT
Column alignment: left
public static final int ALIGN_RIGHT
Column alignment: right
public static final int LINKTARGET_CURRENTFRAME
Link Target: opens the link in the current frame
public static final int LINKTARGET_NAMEDFRAME
Link Target: opens the link in a window with a named specified by getLinkTargetFrame()
public static final int LINKTARGET_NEWWINDOW
Link Target: opens the link in a new window
public static final int LINKTARGET_PARENTFRAME
Link Target: opens the link in the parent frame
public static final int LINKTARGET_TOPFRAME
Link Target: opens the link in the top frame
public static final int STATE3_CHECKED
tCHECK3STATE cell state: checked
public static final int STATE3_UNCHECKED
tCHECK3STATE cell state: unchecked
public static final int STATE3_UNDEFINED
tCHECK3STATE cell state: undefined
public static final int tACTIONLINK
cell type: is an action link (that is an internal link)
public static final int tCHECK
cell type: has a checkbox
public static final int tCHECK3STATE
cell type: has a 3 states checkbox
public static final int tEDITABLE
cell type: is editable
public static final int tIMAGE
cell type: has an image
public static final int tLINK
cell type: is an external link (web link to an outer URL)
public static final int tRADIO
cell type: has a radio-button
public static final int TRUNCATE_CELL_POPUP_POLICY
Cell Truncate Policy: truncate cell (add '...') and show full cell text into a popup
public static final int TRUNCATE_ROW_POPUP_POLICY
Cell Truncate Policy: truncate cell (add '...') and show full row text into a popup
public static final int TRUNCATE_USER_POLICY
Cell Truncate Policy: use user preference
public static final int tSTRING
cell type: simple text
public static final int WRAP_POLICY
Cell Truncate Policy: wrap cell text if wider than defined

Constructor Summary
CATKeyTableModel()

Method Summary
public int get3State(String iKey, int iColumn)
Returns the state of the specified 3 state checkbox cell (default state is STATE3_UNCHECKED).
public String getAdvancedFilterEditor(int iColumn)
Returns the Advanced filter editor for the given column.
public abstract String getCell(String iKey, int iColumn)
Returns the text label of the specified cell.
public int getCellTruncatePolicy(CATTable iTable)
Returns the cell truncate policy to apply to the specified table.
public int getColumnAlignment(int iColumn)
Returns the alignment type for the specified column (default is ALIGN_LEFT).
public abstract int getColumnCount()
Returns the number of columns the table should display.
public abstract String getColumnTitle(int iColumn)
Returns a column title.
public int getColumnWidth(int iColumn)
Returns the column width (in characters).
public boolean getEnable(String iKey, int iColumn)
Determines whether the specified cell is enabled or not (default is true).
public String getImage(String iKey, int iColumn)
Returns the image URL of the specified cell (default is null).
public String getImageTooltip(String iKey, int iColumn)
Return the image tooltip of the specified cell (default is null).
public abstract int getKeyCount()
Returns the total number of keys (each key is displayed in a table row).
public abstract void getKeys(int iOffset, String[] oKeys)
To get a bunch of keys starting from an offset.
public int getLevel(String iKey, int iColumn)
Returns the text level of the specified cell (default level is 0).
public String getLink(String iKey, int iColumn)
Returns the web link URL of the specified cell (default is null).
public int getLinkTarget(String iKey, int iCol)
Returns the link target window of the specified cell (default is LINKTARGET_CURRENTFRAME).
public String getLinkTargetFrame(String iKey, int iCol)
Returns the link target window name of the specified cell (default is LINKTARGET_CURRENTFRAME).
public boolean getState(String iKey, int iColumn)
Returns the check/radio state of the specified cell (default state is false).
public String getTablePrefsRepository(CATTable iTable)
Returns the repository name for the table preferences (default is null).
public String getTooltip(String iKey, int iColumn)
Returns the tooltip of the image of the specified cell (default is null).
public int getType(String iKey, int iColumn)
Returns the type of the specified cell.
public void giveDisplayedColumns(CATTable iTable, int[] iColumns)
Performance optimization call.
public boolean isColumnFilterable(int iColumn)
Determines whether if this column is filterable or not.
public boolean isColumnSortable(int iColumn)
Determines whether the specified column is sortable or not.
public boolean isListExportable()
Determines whether the table content should be exportable (to an Excel spreadsheet).
public void refreshContent()
Call this method to request a refresh of the display because the content of the list has changed.
public void setCell(String iKey, int iCol, String iText)
Warns the table model that the specified cell was edited.


Field Detail

ALIGN_CENTER

    public static final int ALIGN_CENTER
Column alignment: center


ALIGN_LEFT

    public static final int ALIGN_LEFT
Column alignment: left


ALIGN_RIGHT

    public static final int ALIGN_RIGHT
Column alignment: right


LINKTARGET_CURRENTFRAME

    public static final int LINKTARGET_CURRENTFRAME
Link Target: opens the link in the current frame


LINKTARGET_NAMEDFRAME

    public static final int LINKTARGET_NAMEDFRAME
Link Target: opens the link in a window with a named specified by getLinkTargetFrame()


LINKTARGET_NEWWINDOW

    public static final int LINKTARGET_NEWWINDOW
Link Target: opens the link in a new window


LINKTARGET_PARENTFRAME

    public static final int LINKTARGET_PARENTFRAME
Link Target: opens the link in the parent frame


LINKTARGET_TOPFRAME

    public static final int LINKTARGET_TOPFRAME
Link Target: opens the link in the top frame


STATE3_CHECKED

    public static final int STATE3_CHECKED
tCHECK3STATE cell state: checked


STATE3_UNCHECKED

    public static final int STATE3_UNCHECKED
tCHECK3STATE cell state: unchecked


STATE3_UNDEFINED

    public static final int STATE3_UNDEFINED
tCHECK3STATE cell state: undefined


tACTIONLINK

    public static final int tACTIONLINK
cell type: is an action link (that is an internal link)

See Also:
CATTable#getActionLinkNotification()

tCHECK

    public static final int tCHECK
cell type: has a checkbox


tCHECK3STATE

    public static final int tCHECK3STATE
cell type: has a 3 states checkbox


tEDITABLE

    public static final int tEDITABLE
cell type: is editable


tIMAGE

    public static final int tIMAGE
cell type: has an image


tLINK

    public static final int tLINK
cell type: is an external link (web link to an outer URL)


tRADIO

    public static final int tRADIO
cell type: has a radio-button


TRUNCATE_CELL_POPUP_POLICY

    public static final int TRUNCATE_CELL_POPUP_POLICY
Cell Truncate Policy: truncate cell (add '...') and show full cell text into a popup


TRUNCATE_ROW_POPUP_POLICY

    public static final int TRUNCATE_ROW_POPUP_POLICY
Cell Truncate Policy: truncate cell (add '...') and show full row text into a popup


TRUNCATE_USER_POLICY

    public static final int TRUNCATE_USER_POLICY
Cell Truncate Policy: use user preference


tSTRING

    public static final int tSTRING
cell type: simple text


WRAP_POLICY

    public static final int WRAP_POLICY
Cell Truncate Policy: wrap cell text if wider than defined


Constructor Detail

CATKeyTableModel

    CATKeyTableModel()


Method Detail

get3State

    public int get3State(String iKey, int iColumn)

Returns the state of the specified 3 state checkbox cell (default state is STATE3_UNCHECKED).

This method is called for tCHECK3STATE cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The cell state (STATE3_UNCHECKED, STATE3_CHECKED or STATE3_UNDEFINED).

getAdvancedFilterEditor

    public String getAdvancedFilterEditor(int iColumn)

Returns the Advanced filter editor for the given column.

This method only applies to filterable columns. It returns the advanced editor command name (may be null). A null value unsets the advanced editor (filter is only editable through a basic textfield). A non-null value shows an "advanced filter" button that launches the given JDialog command when pressed.

Parameters:
iColumn
A column index.
Return:
The JDialog command name for the advanced filter editor.

getCell

    public abstract String getCell(String iKey, int iColumn)

Returns the text label of the specified cell.

This method is called for every cell type.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The cell text that will be displayed.

getCellTruncatePolicy

    public int getCellTruncatePolicy(CATTable iTable)

Returns the cell truncate policy to apply to the specified table. Default value is TRUNCATE_USER_POLICY.

This setting has an effect only in non-null sized columns.

Parameters:
iTable
The related CATTable component.
Return:
The truncate policy (TRUNCATE_CELL_POPUP_POLICY, TRUNCATE_ROW_POPUP_POLICY, WRAP_POLICY or TRUNCATE_USER_POLICY).

getColumnAlignment

    public int getColumnAlignment(int iColumn)

Returns the alignment type for the specified column (default is ALIGN_LEFT).

This parameter aligns text in the column.

Parameters:
iColumn
A column index.
Return:
The column alignment (ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT).

getColumnCount

    public abstract int getColumnCount()

Returns the number of columns the table should display.

Return:
The number of columns.

getColumnTitle

    public abstract String getColumnTitle(int iColumn)

Returns a column title.

Parameters:
iColumn
A column index.
Return:
The column's title that will be displayed.

getColumnWidth

    public int getColumnWidth(int iColumn)

Returns the column width (in characters).

A negative value means a fixed width column,
A null value means unconstained column width
A positive value means minimum column width, assuming it will spread on extra space (divided evenly among all positive width columns).
Default value is 0 (unconstained column width).
Every non-null value will cause wide cells to be "truncated". The truncate behavior is defined by getCellTruncatePolicy().

Parameters:
iColumn
A column index.
Return:
The column width (in characters).
See Also:
#getCellTruncatePolicy(CATTable)

getEnable

    public boolean getEnable(String iKey, int iColumn)

Determines whether the specified cell is enabled or not (default is true).

This method is called for tCHECK, tRADIO, tLINK and tACTIONLINK cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The cell enablement.

getImage

    public String getImage(String iKey, int iColumn)

Returns the image URL of the specified cell (default is null).

This method is called for tIMAGE cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
Either a relative path from the resources/graphic directory of the runtime view, or an absolute URL to the image.

getImageTooltip

    public String getImageTooltip(String iKey, int iColumn)

Return the image tooltip of the specified cell (default is null).

This method is called for tIMAGE cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The tooltip text to display over the cell image (null value means "no tooltip").

getKeyCount

    public abstract int getKeyCount()

Returns the total number of keys (each key is displayed in a table row).

Return:
The total number of keys.

getKeys

    public abstract void getKeys(int iOffset, String[] oKeys)

To get a bunch of keys starting from an offset.

The table component only displays a slice of data. This method retreives only a slice.

Parameters:
iOffset
The keys offset (that is the first key index to show).
oKeys
This is an output parameter: an empty array of keys that the table model is expected to fill.

getLevel

    public int getLevel(String iKey, int iColumn)

Returns the text level of the specified cell (default level is 0).

This method is called for every cell type.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The text level (0: default aspect, 1: title level, for subtitle level, ...).

getLink

    public String getLink(String iKey, int iColumn)

Returns the web link URL of the specified cell (default is null).

This method is called for tLINK cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The link URL.

getLinkTarget

    public int getLinkTarget(String iKey, int iCol)

Returns the link target window of the specified cell (default is LINKTARGET_CURRENTFRAME).

This method is called for tLINK cell types, and defines the link target window.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The link target window (LINKTARGET_CURRENTFRAME, LINKTARGET_TOPFRAME, LINKTARGET_PARENTFRAME, LINKTARGET_NEWWINDOW, LINKTARGET_NAMEDFRAME).

getLinkTargetFrame

    public String getLinkTargetFrame(String iKey, int iCol)

Returns the link target window name of the specified cell (default is LINKTARGET_CURRENTFRAME).

This method is called for tLINK cell types, that declared a link target LINKTARGET_NAMEDFRAME.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The link target window name.

getState

    public boolean getState(String iKey, int iColumn)

Returns the check/radio state of the specified cell (default state is false).

This method is called for tCHECK and tRADIO cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The state (true is "on", false is "off").

getTablePrefsRepository

    public String getTablePrefsRepository(CATTable iTable)

Returns the repository name for the table preferences (default is null).

When returning a non-null repository name for the table activates a "preferences" link that gives access to customization: reordering, showing/hiding columns and modifying their width.
Possible formats for preferences repository names are:

  1. the table model class name,
  2. or the widget path

Parameters:
iTable
The related CATTable component.
Return:
The repository name.

getTooltip

    public String getTooltip(String iKey, int iColumn)

Returns the tooltip of the image of the specified cell (default is null).

This method is called for tIMAGE cell types.

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
String of the Tooltip.

getType

    public int getType(String iKey, int iColumn)

Returns the type of the specified cell. Default is tSTRING (simple text cell).

Parameters:
iKey
A row's key.
iColumn
A column's index.
Return:
The cell type (a combination of tSTRING, tIMAGE, tCHECK, tLINK, ...)

giveDisplayedColumns

    public void giveDisplayedColumns(CATTable iTable, int[] iColumns)

Performance optimization call.

This method is called once per request before rendering the table.
It passes to the model the displayed columns, so that the database query may be optimized.
This method is called before getKeys().

Parameters:
iTable
The CATTable component that is going to be displayed.
iColumns
The set of columns that will be rendered.

isColumnFilterable

    public boolean isColumnFilterable(int iColumn)

Determines whether if this column is filterable or not.

Defining a column as filterable will display a filter button in the column title, and will have the table component manage the filter requests from the user.

Parameters:
iColumn
A column index.
Return:
true if the column is filterable, false otherwise.
See Also:
CATTable#getFilter()

isColumnSortable

    public boolean isColumnSortable(int iColumn)

Determines whether the specified column is sortable or not. Default is false (not sortable).

Defining a column as sortale will display sort button in the column title, and will have the table component manage the sort requests from the user.

Parameters:
iColumn
A column index.
Return:
true if the column is sortable, false otherwise.
See Also:
CATTable#getLastSort()
CATTable#getSortHistory()
CATTable#getColumnSortNotification()

isListExportable

    public boolean isListExportable()

Determines whether the table content should be exportable (to an Excel spreadsheet). Default is false.

Override this method to add an "export" link in the table that will automatically manage the export to a spreadsheet file.

Return:
true if this table should an "export" link; false otherwise.

refreshContent

    public void refreshContent()

Call this method to request a refresh of the display because the content of the list has changed.


setCell

    public void setCell(String iKey, int iCol, String iText)

Warns the table model that the specified cell was edited.

This method is called for tEDITABLE cell types, when the user edits its value.
Override this method to handle cell editions at the table model level. Overwise you can handle it though the CATTable 'CellChanged' Notification.

Parameters:
iKey
A row's key.
iColumn
A column's index.
iText
The new cell text.


Copyright © 2000, Dassault Systèmes. All rights reserved