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
int ALIGN_LEFT
int ALIGN_CENTER
int ALIGN_RIGHT
int tSTRING
int tIMAGE
int tCHECK
int tLINK
int tRADIO
int tEDITABLE
int tCHECK3STATE
int tACTIONLINK
int STATE3_UNCHECKED
int STATE3_CHECKED
int STATE3_UNDEFINED
int LINKTARGET_CURRENTFRAME
int LINKTARGET_TOPFRAME
int LINKTARGET_PARENTFRAME
int LINKTARGET_NEWWINDOW
int LINKTARGET_NAMEDFRAME
int TRUNCATE_CELL_POPUP_POLICY
int TRUNCATE_ROW_POPUP_POLICY
int WRAP_POLICY
int TRUNCATE_USER_POLICY

Constructor Summary
CATKeyTableModel()

Method Summary
int getColumnCount()
String getColumnTitle(int iColumn)
int getColumnWidth(int iColumn)
boolean isColumnSortable(int iColumn)
boolean isColumnFilterable(int iColumn)
String getAdvancedFilterEditor(int iColumn)
int getColumnAlignment(int iColumn)
int getKeyCount()
void getKeys(int iOffset, String[] oKeys)
int getType(String iKey, int iColumn)
String getCell(String iKey, int iColumn)
int getLevel(String iKey, int iColumn)
boolean getEnable(String iKey, int iColumn)
boolean getState(String iKey, int iColumn)
int get3State(String iKey, int iColumn)
String getImage(String iKey, int iColumn)
String getTooltip(String iKey, int iColumn)
String getImageTooltip(String iKey, int iColumn)
String getLink(String iKey, int iColumn)
int getLinkTarget(String iKey, int iCol)
String getLinkTargetFrame(String iKey, int iCol)
void setCell(String iKey, int iCol, String iText)
void refreshContent()
String getTablePrefsRepository(CATTable iTable)
int getCellTruncatePolicy(CATTable iTable)
void giveDisplayedColumns(CATTable iTable, int[] iColumns)
boolean isListExportable()


Field Detail

ALIGN_LEFT

    int ALIGN_LEFT
Column alignment: left


ALIGN_CENTER

    int ALIGN_CENTER
Column alignment: center


ALIGN_RIGHT

    int ALIGN_RIGHT
Column alignment: right


tSTRING

    int tSTRING
cell type: simple text


tIMAGE

    int tIMAGE
cell type: has an image


tCHECK

    int tCHECK
cell type: has a checkbox


tLINK

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


tRADIO

    int tRADIO
cell type: has a radio-button


tEDITABLE

    int tEDITABLE
cell type: is editable


tCHECK3STATE

    int tCHECK3STATE
cell type: has a 3 states checkbox


tACTIONLINK

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


STATE3_UNCHECKED

    int STATE3_UNCHECKED
tCHECK3STATE cell state: unchecked


STATE3_CHECKED

    int STATE3_CHECKED
tCHECK3STATE cell state: checked


STATE3_UNDEFINED

    int STATE3_UNDEFINED
tCHECK3STATE cell state: undefined


LINKTARGET_CURRENTFRAME

    int LINKTARGET_CURRENTFRAME
Link Target: opens the link in the current frame


LINKTARGET_TOPFRAME

    int LINKTARGET_TOPFRAME
Link Target: opens the link in the top frame


LINKTARGET_PARENTFRAME

    int LINKTARGET_PARENTFRAME
Link Target: opens the link in the parent frame


LINKTARGET_NEWWINDOW

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


LINKTARGET_NAMEDFRAME

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


TRUNCATE_CELL_POPUP_POLICY

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


TRUNCATE_ROW_POPUP_POLICY

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


WRAP_POLICY

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


TRUNCATE_USER_POLICY

    int TRUNCATE_USER_POLICY
Cell Truncate Policy: use user preference


Constructor Detail

CATKeyTableModel

    CATKeyTableModel()


Method Detail

getColumnCount

    int getColumnCount()

Returns the number of columns the table should display.

Returns:
The number of columns.

getColumnTitle

    String getColumnTitle(int iColumn)

Returns a column title.

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

getColumnWidth

    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.
Returns:
The column width (in characters).
See Also:
#getCellTruncatePolicy(CATTable)

isColumnSortable

    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.
Returns:
true if the column is sortable, false otherwise.
See Also:
CATTable#getLastSort()
CATTable#getSortHistory()
CATTable#getColumnSortNotification()

isColumnFilterable

    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.
Returns:
true if the column is filterable, false otherwise.
See Also:
CATTable#getFilter()

getAdvancedFilterEditor

    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.
Returns:
The JDialog command name for the advanced filter editor.

getColumnAlignment

    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.
Returns:
The column alignment (ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT).

getKeyCount

    int getKeyCount()

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

Returns:
The total number of keys.

getKeys

    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.

getType

    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.
Returns:
The cell type (a combination of tSTRING, tIMAGE, tCHECK, tLINK, ...)

getCell

    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.
Returns:
The cell text that will be displayed.

getLevel

    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.
Returns:
The text level (0: default aspect, 1: title level, for subtitle level, ...).

getEnable

    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.
Returns:
The cell enablement.

getState

    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.
Returns:
The state (true is "on", false is "off").

get3State

    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.
Returns:
The cell state (STATE3_UNCHECKED, STATE3_CHECKED or STATE3_UNDEFINED).

getImage

    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.
Returns:
Either a relative path from the resources/graphic directory of the runtime view, or an absolute URL to the image.

getTooltip

    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.
Returns:
String of the Tooltip.

getImageTooltip

    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.
Returns:
The tooltip text to display over the cell image (null value means "no tooltip").

getLink

    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.
Returns:
The link URL.

getLinkTarget

    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.
Returns:
The link target window (LINKTARGET_CURRENTFRAME, LINKTARGET_TOPFRAME, LINKTARGET_PARENTFRAME, LINKTARGET_NEWWINDOW, LINKTARGET_NAMEDFRAME).

getLinkTargetFrame

    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.
Returns:
The link target window name.

setCell

    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.

refreshContent

    void refreshContent()

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


getTablePrefsRepository

    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.
Returns:
The repository name.

getCellTruncatePolicy

    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.
Returns:
The truncate policy (TRUNCATE_CELL_POPUP_POLICY, TRUNCATE_ROW_POPUP_POLICY, WRAP_POLICY or TRUNCATE_USER_POLICY).

giveDisplayedColumns

    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.

isListExportable

    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.

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


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