org.formaria.swt
Class Table

java.lang.Object
  extended by org.eclipse.swt.widgets.Table
      extended by org.formaria.swt.Table
All Implemented Interfaces:
RowSelector, ListenerHelper, ModelHolder, StyleComponent
Direct Known Subclasses:
EditTable

public class Table
extends org.eclipse.swt.widgets.Table
implements ModelHolder, StyleComponent, RowSelector, ListenerHelper

Provides a simple read-only tables/grid component.

Copyright (c) Formaria Ltd.,
License: see license.txt $Revision: 2.7 $


Field Summary
protected  org.eclipse.swt.graphics.Color colorSWTBg
           
protected  org.eclipse.swt.graphics.Color colorSWTFg
           
protected  HandlerInvoker invoker
           
protected  DataModel model
           
protected  boolean updateModelSelection
           
protected  boolean usesDatabase
           
 
Constructor Summary
Table(java.lang.Object parent)
          Create a new table
 
Method Summary
 void addHandler(java.lang.Object page, java.lang.String handlerType, java.lang.String methodName)
          Add an event handler response method to a component such that the page's response method is invoked when the event occurs
 void addListener()
          Add a listener
static int charLength(java.lang.String text)
          Get the width of a string
protected  void checkSubclass()
          Suppress the subclassing exception
 void databaseRefill()
          Refill from the database
 DataModel getModel()
          Get the underlying model.
 int getSelectedRow()
          Get the row selection index
 java.lang.String getToolTip()
          Get the tooltip text
 java.lang.String getValueAt(int rowIndex, int columnIndex)
          Get the value of the indexes
 void refill()
          Refill the table
 void setBorderStyle(java.lang.String style)
          Set the style of the border
 void setDataModel(DataModel xmodel)
          Set the DataModel which we will be generating the table from
 void setDisplayAttributes()
          Set the display attributes
 void setInteractiveTable(boolean state)
          Set the user interaction state
 void setSelectedRow(int idx)
          Sets the indexof the selected row
 void setSelectedStyle(java.lang.String style)
          Set the style of the selected row
 void setSelectionMode(java.lang.String value)
           
 void setStyle(java.lang.String style)
          Set the style of the header data
 void setToolTip(java.lang.String text)
          Set the tooltip text
 void setUpdateModelSelection(boolean doUpdate)
          Tie the model selection to this table's selection
 void staticRefill()
          Refill from static elements
 void update()
          implemented from ModelHolder interface
 void updateWidthColumn(int index)
          Update the width of a column
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected DataModel model

updateModelSelection

protected boolean updateModelSelection

invoker

protected HandlerInvoker invoker

colorSWTFg

protected org.eclipse.swt.graphics.Color colorSWTFg

colorSWTBg

protected org.eclipse.swt.graphics.Color colorSWTBg

usesDatabase

protected boolean usesDatabase
Constructor Detail

Table

public Table(java.lang.Object parent)
Create a new table

Parameters:
parent - parent object
Method Detail

checkSubclass

protected void checkSubclass()
Suppress the subclassing exception


addListener

public void addListener()
Add a listener


charLength

public static int charLength(java.lang.String text)
Get the width of a string

Parameters:
text - the text
Returns:
the width

setDisplayAttributes

public void setDisplayAttributes()
Set the display attributes


setToolTip

public void setToolTip(java.lang.String text)
Set the tooltip text

Parameters:
text - the new text

getToolTip

public java.lang.String getToolTip()
Get the tooltip text

Returns:
the existing text if any

setSelectedStyle

public void setSelectedStyle(java.lang.String style)
Set the style of the selected row

Parameters:
style - Style

setBorderStyle

public void setBorderStyle(java.lang.String style)
Set the style of the border

Parameters:
style - Style

setInteractiveTable

public void setInteractiveTable(boolean state)
Set the user interaction state

Parameters:
state - true for an user interactive table.

setUpdateModelSelection

public void setUpdateModelSelection(boolean doUpdate)
Tie the model selection to this table's selection

Parameters:
doUpdate - true to tie the selections together, false to ignore

setSelectionMode

public void setSelectionMode(java.lang.String value)

setStyle

public void setStyle(java.lang.String style)
Set the style of the header data

Specified by:
setStyle in interface StyleComponent
Parameters:
style - Style

setSelectedRow

public void setSelectedRow(int idx)
Sets the indexof the selected row

Specified by:
setSelectedRow in interface RowSelector
Parameters:
idx - the new selected row

getSelectedRow

public int getSelectedRow()
Get the row selection index

Specified by:
getSelectedRow in interface RowSelector
Returns:
the current row selection index (zero based)

addHandler

public void addHandler(java.lang.Object page,
                       java.lang.String handlerType,
                       java.lang.String methodName)
                throws java.lang.NoSuchMethodException
Add an event handler response method to a component such that the page's response method is invoked when the event occurs

Specified by:
addHandler in interface ListenerHelper
Parameters:
page - the page containing the method
handlerType - the type of event handler
methodName - the method to invoke
Throws:
java.lang.NoSuchMethodException - cannot add the handler

setDataModel

public void setDataModel(DataModel xmodel)
Set the DataModel which we will be generating the table from

Specified by:
setDataModel in interface ModelHolder
Parameters:
xmodel - The DataModel of data

update

public void update()
implemented from ModelHolder interface

Specified by:
update in interface ModelHolder

getModel

public DataModel getModel()
Get the underlying model.

Returns:
the model

refill

public void refill()
Refill the table


databaseRefill

public void databaseRefill()
Refill from the database


getValueAt

public java.lang.String getValueAt(int rowIndex,
                                   int columnIndex)
Get the value of the indexes

Parameters:
rowIndex - row index
columnIndex - column index
Returns:
the value

staticRefill

public void staticRefill()
Refill from static elements


updateWidthColumn

public void updateWidthColumn(int index)
Update the width of a column

Parameters:
index - index of the column