at.spardat.xma.mdl.table
Class TableWMClient

java.lang.Object
  extended byat.spardat.xma.mdl.WModel
      extended byat.spardat.xma.mdl.table.TableBaseWM
          extended byat.spardat.xma.mdl.table.TableWM
              extended byat.spardat.xma.mdl.table.TableWMClient
All Implemented Interfaces:
Descriptive, ISelectable, ITableWM, ITableWMClient, IWModelClient, Synchronization, Transactional

public class TableWMClient
extends TableWM
implements ITableWMClient

The implementation of a TableWM widget model implementation at the client side.


Field Summary
protected  XMATableColumn[] columns_
          Specifies column information.
 
Fields inherited from class at.spardat.xma.mdl.table.TableWM
updateCount_
 
Fields inherited from class at.spardat.xma.mdl.table.TableBaseWM
columnCount_, isAtServer_
 
Fields inherited from class at.spardat.xma.mdl.WModel
S_NULL
 
Fields inherited from interface at.spardat.xma.mdl.table.ITableWMClient
S_NON_SORTABLE
 
Fields inherited from interface at.spardat.xma.mdl.table.ITableWM
S_LAST, S_MULTI_SELECT, S_ONE_WAY
 
Constructor Summary
TableWMClient(short id, Page pm, int columnCount, int style)
          Constructor.
 
Method Summary
 XMATableColumn getColumn(int i)
          Returns the column at the provided zero based index.
 at.spardat.enterprise.fmt.IFmt getFormatter(int columnIndex)
          Returns the formatter set for the column at index columnIndex or null if none has been set.
 int getSortingColumn()
          Returns the index of the column sorting the table or -1 if the table is not sorted by any column.
static TableRow getTableRowFor(java.lang.Object uiTableItem)
          Returns the model's TableRow to the given TableItem.
 UIDelegateClient getUIDelegate()
          Returns the attached UIDelegateClient.
 boolean handle(ModelChangeEvent event)
          All events that might change a WidgetModel are executed via this method.
 boolean hasSortIndicator()
          Shows if this table shows a sort indicator at the sorting column's header.
 boolean isEditable()
          Returns true if this model's widget may be modified by the end-user.
 boolean isEnabled()
          Returns true, if this model's widget is enabled.
 boolean isSortable(int columnIndex)
          Returns true if the column at index columnIndex may be sorted.
 boolean isSortingColumnAscending()
          Shows if the sorted column sorts ascending (1 click) or descening(2 clicks).
 boolean isVisible(int columnIndex)
          Returns the visibility state of a particular column.
 void selectByUIIndex(int index)
          Selects the row at a provided index in the UI-control (SWT-table) associated with this widget-model.
 void setEditable(boolean what)
          Sets the editable-state of this models's widget.
 void setEnabled(boolean what)
          Sets the enabled-state of this model's widget.
 void setFormatter(int columnIndex, at.spardat.enterprise.fmt.IFmt formatter)
          Sets the formatter to use for column at index columnIndex.
 void setSortable(int columnIndex, boolean what)
          Sets the property if the column at index columnIndex may be sorted by the user or not.
 void setSortIndicator(boolean showSortIndicator)
          If this method is set to true than a sort indicator (a small up or down arrow) is shown at the column's header, which sorts the table.
 void setVisible(int columnIndex, boolean what)
          Sets the property whether the column at index columnIndex is visible or not.
 void sort(int columnIndex)
          Sorts the table contents on the UI using a particular column as sort order column.
 void sortNatural()
          Displays the rows in their natural order, i.e., as inserted in the table model.
 
Methods inherited from class at.spardat.xma.mdl.table.TableWM
add, changed, cleanUpAfterServerEvent, clear, commit, containsKey, describe, deselect, deselectAll, equalsCS, estimateMemory, externalize, getRow, getRow, getSelected, getSelection, getSelectionCount, indexOf, internalize, internalRemoveRows, isMultiSelect, isOneWay, isSelected, isStrict, randomlyChange, removeRow, removeRow, rollback, select, selectByModelIndex, size
 
Methods inherited from class at.spardat.xma.mdl.table.TableBaseWM
getColumnCount, getPage
 
Methods inherited from class at.spardat.xma.mdl.WModel
getId, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface at.spardat.xma.mdl.table.ITableWM
clear, containsKey, getColumnCount, getRow, getRow, indexOf, isOneWay, removeRow, removeRow, selectByModelIndex, size
 
Methods inherited from interface at.spardat.xma.mdl.ISelectable
deselect, deselectAll, getSelected, getSelection, getSelectionCount, isMultiSelect, isSelected, isStrict, select
 

Field Detail

columns_

protected XMATableColumn[] columns_
Specifies column information.

Constructor Detail

TableWMClient

public TableWMClient(short id,
                     Page pm,
                     int columnCount,
                     int style)
Constructor. Dont forget to call setFormatter if the table does not merley contain Strings.

Parameters:
id - uniquely identifies the model within its page
pm - the enclosing page model this widget model belongs to.
columnCount - the number of columns this table has
style - bit or combination of the style constants S_* of this class and its superclass.
Method Detail

setFormatter

public void setFormatter(int columnIndex,
                         at.spardat.enterprise.fmt.IFmt formatter)
Sets the formatter to use for column at index columnIndex.

Specified by:
setFormatter in interface ITableWMClient
Parameters:
columnIndex - the zero based index of the column
formatter - the IFmt object determining the string layout of a column cell.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if columnIndex not valid.

setSortable

public void setSortable(int columnIndex,
                        boolean what)
Sets the property if the column at index columnIndex may be sorted by the user or not. If this method is not called for a particular column, the value defaults to true.

Specified by:
setSortable in interface ITableWMClient
Parameters:
columnIndex - the zero based index of the column
what - false if sorting of the column should be supressed, true otherwise.

isSortable

public boolean isSortable(int columnIndex)
Returns true if the column at index columnIndex may be sorted.

Specified by:
isSortable in interface ITableWMClient

sort

public void sort(int columnIndex)
Sorts the table contents on the UI using a particular column as sort order column. Note that this method does not sort the widget model. The model stays completely unchanged. It merely changes the permutation of rows on the UI. If you are working with zero based indexes on the table model, this indexes may no longer correspond with the rows rank you see in the UI table. E.g., selecting the first row in the table model will not select the first row in the UI table.

The table won't be sorted if any of the following is true:


getFormatter

public at.spardat.enterprise.fmt.IFmt getFormatter(int columnIndex)
Returns the formatter set for the column at index columnIndex or null if none has been set.

Specified by:
getFormatter in interface ITableWMClient

setVisible

public void setVisible(int columnIndex,
                       boolean what)
Sets the property whether the column at index columnIndex is visible or not. This property defaults to true, i.e., if this method is never called, the column is visible on the UI.

Parameters:
columnIndex - zero based index of the column
what - true indicates that the column should be visible.

isVisible

public boolean isVisible(int columnIndex)
Returns the visibility state of a particular column.

Specified by:
isVisible in interface ITableWMClient
Parameters:
columnIndex - zero based index of the column
Returns:
true if visible, false otherwise

getUIDelegate

public UIDelegateClient getUIDelegate()
Description copied from interface: IWModelClient
Returns the attached UIDelegateClient.

Specified by:
getUIDelegate in interface IWModelClient
Returns:
the UIDelegateClient which never is null.
See Also:
IWModelClient.getUIDelegate()

handle

public boolean handle(ModelChangeEvent event)
Description copied from class: WModel
All events that might change a WidgetModel are executed via this method.

Overrides:
handle in class TableWM
See Also:
WModel.handle(at.spardat.xma.mdl.ModelChangeEvent)

getColumn

public XMATableColumn getColumn(int i)
Returns the column at the provided zero based index.

Specified by:
getColumn in interface ITableWMClient
Parameters:
i - zero based index indentifying a column
Returns:
a TableColumn object describing the column
Throws:
ArrayIndexOutOfBounds - if i greater equal getColumnCount or less than zero.

selectByUIIndex

public void selectByUIIndex(int index)
Description copied from interface: ITableWMClient
Selects the row at a provided index in the UI-control (SWT-table) associated with this widget-model. If index is less than zero or greater or equal to size(), this method does nothing.

Note that the UI must be constructed in order for this method to work.

Specified by:
selectByUIIndex in interface ITableWMClient
See Also:
ITableWMClient.selectByUIIndex(int)

isEditable

public boolean isEditable()
Description copied from interface: IWModelClient
Returns true if this model's widget may be modified by the end-user. Returns false, if the widget may not be edited, but the content of the widget should be readable and receive focus.

Specified by:
isEditable in interface IWModelClient
See Also:
IWModelClient.isEditable()

isEnabled

public boolean isEnabled()
Description copied from interface: IWModelClient
Returns true, if this model's widget is enabled. Returns false, if it is disabled. A disabled control is displayed in a greyed look and does not receive focus.

Specified by:
isEnabled in interface IWModelClient
See Also:
IWModelClient.isEnabled()

setEditable

public void setEditable(boolean what)
Description copied from interface: IWModelClient
Sets the editable-state of this models's widget. A widget which is not editable can not be modified by the end user. Unlike the disabled-state, its contents remains readable and still receives focus.

Usually, this method is called on all widget-models of a page to set the whole page to a read-only mode.

If this method is not called, the default is true.

Specified by:
setEditable in interface IWModelClient
Parameters:
what - true if the model's widget should be editable, false otherwise.
See Also:
IWModelClient.setEditable(boolean)

setEnabled

public void setEnabled(boolean what)
Description copied from interface: IWModelClient
Sets the enabled-state of this model's widget.

Specified by:
setEnabled in interface IWModelClient
Parameters:
what - the state to set.
See Also:
IWModelClient.setEnabled(boolean)

sortNatural

public void sortNatural()
Description copied from interface: ITableWMClient
Displays the rows in their natural order, i.e., as inserted in the table model. This method does not change the order in the model, just on the UI. It makes sure that the UI displays the rows in the same order as given by the model.

This method may be used to undo an earlier call to sort. Besides that, the user might have changed the sort order by klicking on the table headers.

Specified by:
sortNatural in interface ITableWMClient
See Also:
ITableWMClient.sortNatural()

getSortingColumn

public int getSortingColumn()
Description copied from interface: ITableWMClient
Returns the index of the column sorting the table or -1 if the table is not sorted by any column.

Specified by:
getSortingColumn in interface ITableWMClient
Returns:
The index of the column starting with 0 or -1 if no sort was done.
Since:
version_number
See Also:
ITableWMClient.getSortingColumn()

isSortingColumnAscending

public boolean isSortingColumnAscending()
Description copied from interface: ITableWMClient
Shows if the sorted column sorts ascending (1 click) or descening(2 clicks). If the sorted column index is -1, then a call to this method makes no sense.

Specified by:
isSortingColumnAscending in interface ITableWMClient
Returns:
true - ascending / false - descending
Since:
version_number
See Also:
ITableWMClient.isSortingColumnAscending()

hasSortIndicator

public boolean hasSortIndicator()
Description copied from interface: ITableWMClient
Shows if this table shows a sort indicator at the sorting column's header.

Specified by:
hasSortIndicator in interface ITableWMClient
See Also:
ITableWMClient.hasSortIndicator()

setSortIndicator

public void setSortIndicator(boolean showSortIndicator)
Description copied from interface: ITableWMClient
If this method is set to true than a sort indicator (a small up or down arrow) is shown at the column's header, which sorts the table.

Specified by:
setSortIndicator in interface ITableWMClient
Parameters:
showSortIndicator - true - show a sort indicator at the sorting column's header / false - no sort indicator is shown
See Also:
ITableWMClient.setSortIndicator(boolean)

getTableRowFor

public static TableRow getTableRowFor(java.lang.Object uiTableItem)
Returns the model's TableRow to the given TableItem. It returns the XMA TableRow that corresponds to the tree item of the underlying UI library. In the case of SWT, the argument must be an instance of class TableItem.

Parameters:
uiTableItem - SWT-TableItem if SWT is the UI-library you are using. Must not be null. The SWT-TableItem must not be disposed.
Returns:
TableRow for the given TableItem