net.xoetrope.swt
Class XTable

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.eclipse.swt.widgets.Table
                      extended by net.xoetrope.swt.XTable
All Implemented Interfaces:
XRowSelector, XListenerHelper, XStyleComponent, XAttributedComponent, XModelHolder, org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
XEditTable

public class XTable
extends org.eclipse.swt.widgets.Table
implements XAttributedComponent, XModelHolder, XStyleComponent, XRowSelector, XListenerHelper

Provides a simple read-only tables/grid component.

Copyright (c) Xoetrope Ltd., 1998-2004
License: see license.txt $Revision: 2.7 $


Field Summary
protected  org.eclipse.swt.graphics.Color colorSWTBg
           
protected  org.eclipse.swt.graphics.Color colorSWTFg
           
protected  XHandlerInvoker invoker
           
protected  XModel model
           
protected  boolean updateModelSelection
           
protected  boolean usesDatabase
           
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
XTable(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
 XModel getModel()
          Get the underlying model.
 int getSelectedRow()
          Get the row selection index
 java.lang.String getValueAt(int rowIndex, int columnIndex)
          Get the value of the indexes
 void refill()
          Refill the table
 int setAttribute(java.lang.String attribName, java.lang.Object attribValue)
          Set one or more attributes of the component.
 void setBorderStyle(java.lang.String style)
          Set the style of the border
 void setDisplayAttributes()
          Set the display attributes
 void setInteractiveTable(boolean state)
          Set the user interaction state
 void setModel(XModel xmodel)
          Set the XModel which we will be generating the table from
 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 setUpdateModelSelection(boolean doUpdate)
          Tie the model selection to this table's selection
 void staticRefill()
          Refill from static elements
 void update()
          implemented from XModelHolder interface
 void updateWidthColumn(int index)
          Update the width of a column
 
Methods inherited from class org.eclipse.swt.widgets.Table
addSelectionListener, clear, clear, clear, clearAll, computeSize, deselect, deselect, deselect, deselectAll, getColumn, getColumnCount, getColumnOrder, getColumns, getGridLineWidth, getHeaderHeight, getHeaderVisible, getItem, getItem, getItemCount, getItemHeight, getItems, getLinesVisible, getSelection, getSelectionCount, getSelectionIndex, getSelectionIndices, getSortColumn, getSortDirection, getTopIndex, indexOf, indexOf, isSelected, remove, remove, remove, removeAll, removeSelectionListener, select, select, select, selectAll, setColumnOrder, setFont, setHeaderVisible, setItemCount, setLinesVisible, setRedraw, setSelection, setSelection, setSelection, setSelection, setSelection, setSortColumn, setSortDirection, setTopIndex, showColumn, showItem, showSelection
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

model

protected XModel model

updateModelSelection

protected boolean updateModelSelection

invoker

protected XHandlerInvoker invoker

colorSWTFg

protected org.eclipse.swt.graphics.Color colorSWTFg

colorSWTBg

protected org.eclipse.swt.graphics.Color colorSWTBg

usesDatabase

protected boolean usesDatabase
Constructor Detail

XTable

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

Parameters:
parent - parent object
Method Detail

checkSubclass

protected void checkSubclass()
Suppress the subclassing exception

Overrides:
checkSubclass in class org.eclipse.swt.widgets.Table

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


setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component.

Specified by:
setAttribute in interface XAttributedComponent
Parameters:
attribName - the name of the attribute
attribValue - the value of the attribute
Returns:
0 for success, non zero for failure or to require some further action

setSelectedStyle

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

Parameters:
style - XStyle

setBorderStyle

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

Parameters:
style - XStyle

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 XStyleComponent
Parameters:
style - XStyle

setSelectedRow

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

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

getSelectedRow

public int getSelectedRow()
Get the row selection index

Specified by:
getSelectedRow in interface XRowSelector
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 XListenerHelper
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

setModel

public void setModel(XModel xmodel)
Set the XModel which we will be generating the table from

Specified by:
setModel in interface XModelHolder
Parameters:
xmodel - The XModel of data

update

public void update()
implemented from XModelHolder interface

Specified by:
update in interface XModelHolder
Overrides:
update in class org.eclipse.swt.widgets.Control

getModel

public XModel 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