swingwtx.swing
Class JTable

java.lang.Object
  extended byswingwt.awt.Component
      extended byswingwt.awt.Container
          extended byswingwtx.swing.JComponent
              extended byswingwtx.swing.JTable
All Implemented Interfaces:
CellEditorListener, java.util.EventListener, ImageObserver, ListSelectionListener, MenuContainer, TableColumnModelListener, TableModelListener

public class JTable
extends JComponent
implements TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener


Nested Class Summary
 
Nested classes inherited from class swingwtx.swing.JComponent
JComponent.InternalFrameSelectionListener
 
Field Summary
static int AUTO_RESIZE_ALL_COLUMNS
           
static int AUTO_RESIZE_LAST_COLUMN
           
static int AUTO_RESIZE_NEXT_COLUMN
           
static int AUTO_RESIZE_OFF
           
static int AUTO_RESIZE_SUBSEQUENT_COLUMNS
           
protected  TableCellEditor cellEditor
           
protected  boolean cellSelectionEnabled
          Whether cell selection (and thus cell editing) is enabled
protected  TableColumnModel columnModel
           
protected  boolean columnSelection
           
protected  int editingColumn
          Cache of values for current cell editor
protected  Component editingComponent
           
protected  TableCellEditor editingEditor
           
protected  int editingRow
           
protected  JTableHeader header
           
protected  ListSelectionModel listSelectionModel
           
protected  Dimension pIntercell
           
protected  boolean pLines
          Cache - whether to show grid lines
protected  org.eclipse.swt.widgets.Table ppeer
           
protected  int pRowHeight
           
protected  int pSelCol
           
protected  int pSelRow
           
protected  boolean rowSelection
           
protected  org.eclipse.swt.custom.TableCursor swtCursor
          The SWT table cursor
protected  org.eclipse.swt.custom.TableEditor swtEditor
          The SWT table editor
protected  boolean tableDrawnOnce
          Whether the table has been displayed yet.
protected  boolean useFastVirtualTables
          Whether or not to use SWT's fast virtual tables
 
Fields inherited from class swingwtx.swing.JComponent
accessibleContext, actionMap, ancestorInputMap, border, clientProperties, descendantHasPeer, focusInputMap, internalFrameAdapter, internalFrameParent, opaque, propertyChangeListeners, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, windowInputMap
 
Fields inherited from class swingwt.awt.Container
composite, comps, containerListeners, layout, queuedValidateRequest
 
Fields inherited from class swingwt.awt.Component
actionCommand, actionListeners, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListeners, componentName, consumeAvailableHeight, consumeAvailableWidth, focusable, focusListeners, graphicsConfig, inputMethodListeners, isUserSetFont, keyListeners, layoutModifier, LEFT_ALIGNMENT, LOCK, mouseListeners, mouseMotionListeners, mouseWheelListeners, parent, pBackground, pCursor, pDoubleBuffered, peer, pEnabled, pFont, pForeground, pLayoutData, pLocation, pMaxSize, pMinSize, pPrefSize, pSize, pToolTipText, pVisible, RIGHT_ALIGNMENT, swingWTDefaultActionEventAdapter, swingWTEventAdapter, TOP_ALIGNMENT
 
Fields inherited from interface swingwt.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JTable()
           
JTable(int numRows, int numCols)
           
JTable(java.lang.Object[][] rowData, java.lang.Object[] columnNames)
           
JTable(TableModel dm)
           
JTable(TableModel dm, TableColumnModel columnModel)
           
JTable(TableModel dm, TableColumnModel columnModel, ListSelectionModel selectionModel)
           
JTable(java.util.Vector rowData, java.util.Vector columnNames)
           
 
Method Summary
 void addColumn(TableColumn tableColumn)
           
 void changeSelection(int row, int col, boolean toggle, boolean extend)
           
 void clearSelection()
           
 void columnAdded(TableColumnModelEvent e)
           
 void columnMarginChanged(ChangeEvent e)
           
 void columnMoved(TableColumnModelEvent e)
           
 void columnRemoved(TableColumnModelEvent e)
           
 void columnSelectionChanged(ListSelectionEvent e)
           
 int convertColumnIndexToModel(int index)
          SWT table columns aren't movable, so columnIndex == modelIndex
 void createDefaultColumnsFromModel()
           
protected  void createDefaultRenderers()
           
protected  void createTableCursor()
          Creates the table cursor and maps events to it
 void doLayout()
          Forces laying out of this container's child components again.
 void editingCanceled(ChangeEvent e)
          Callback when the editor is cancelled - need to regenerate the table cursor
 void editingStopped(ChangeEvent e)
          Callback when the editor is stopped - need to regenerate the table cursor and put any changes back into the model.
 int getAutoResizeMode()
          NOT IMPLEMENTED
 TableCellEditor getCellEditor()
           
 TableCellEditor getCellEditor(int row, int col)
           
 TableCellRenderer getCellRenderer(int row, int column)
           
 boolean getCellSelectionEnabled(boolean b)
           
 TableColumn getColumn(int index)
           
 TableColumn getColumn(java.lang.Object identifier)
           
 int getColumnCount()
           
 TableColumnModel getColumnModel()
           
 java.lang.String getColumnName(int index)
           
 boolean getColumnSelectionAllowed(boolean b)
           
 TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
           
 int getEditingColumn()
           
 int getEditingRow()
           
 Dimension getIntercellSpacing()
           
 TableModel getModel()
           
 int getRowCount()
           
 int getRowHeight()
           
 boolean getRowSelectionAllowed(boolean b)
           
 int getSelectedColumn()
          NOT IMPLEMENTED
 int getSelectedColumnCount()
          NOT IMPLEMENTED
 int[] getSelectedColumns()
          NOT IMPLEMENTED
 int getSelectedRow()
           
 int getSelectedRowCount()
           
 int[] getSelectedRows()
           
 Color getSelectionBackground()
          NOT IMPLEMENTED - HARD RETURNS A COLOUR VALUE
 Color getSelectionForeground()
          NOT IMPLEMENTED - HARD RETURNS A COLOUR VALUE
 ListSelectionModel getSelectionModel()
           
 boolean getShowGrid()
           
 boolean getShowHorizontalLines()
           
 boolean getShowVerticalLines()
           
 JTableHeader getTableHeader()
           
 java.lang.Object getValueAt(int row, int col)
           
 boolean isCellSelected(int row, int col)
           
 boolean isEditing()
           
 boolean isShowGrid()
           
 boolean isShowHorizontalLines()
           
 boolean isShowVerticalLines()
           
 Component prepareRenderer(TableCellRenderer renderer, int row, int column)
           
protected  void processCellEdit()
          Called back when the user selects a cell in the table to handle the editing
protected  void processColumnClick(int index)
          When a column is clicked by the user, this routine gets fired, which generates a mouse event for the thing and then sends it to the TableHeader mouseEvent listeners for dispatch to the user process
protected  void processListSelection()
          Called back when a row/cell is selected in the table to fire events on to user processes.
 void refreshTable()
          Forces a complete rebuild of the peer from the data model.
 void refreshTable(int rowFrom, int rowTo)
          Just like refreshTable(), except it does not generate the column headers and only updates the rows specified.
protected  void registerCursorSelectionEvents()
          Assigns events to the cursor for selection so that we can update the ListSelectionModel for this component.
protected  void registerTableListSelectionEvents()
          Assigns events to the table for selection
 void removeColumn(TableColumn tableColumn)
           
 void resizeAndRepaint()
           
 int rowAtPoint(Point p)
          NOT IMPLEMENTED
 void selectAll()
           
 void setAutoCreateColumnsFromModel(boolean b)
          NOT IMPLEMENTED - just override the column model produced - you won't even notice
 void setAutoResizeMode(int size)
          NOT IMPLEMENTED
 void setCellEditor(TableCellEditor cell)
           
 void setCellSelectionEnabled(boolean b)
           
 void setColumnModel(TableColumnModel model)
           
 void setColumnSelectionAllowed(boolean b)
          NOT IMPLEMENTED
 void setDefaultRenderer(java.lang.Class columnClass, TableCellRenderer tableCellRenderer)
           
 void setDirty(boolean b)
          Sets whether the model is dirty for forcing updates
 void setEditingColumn(int aColumn)
           
 void setEditingRow(int aRow)
           
 void setIntercellSpacing(Dimension d)
          NOT IMPLEMENTED
 void setModel(TableModel dm)
           
 void setModel(TableModel dm, boolean noRefresh)
           
 void setModelDirty(boolean b)
          Tells the table that it needs to redraw when refreshTable() is next called.
 void setRowHeight(int height)
          NOT IMPLEMENTED
 void setRowHeight(int row, int height)
          NOT IMPLEMENTED
 void setRowSelectionAllowed(boolean b)
          NOT IMPLEMENTED
 void setRowSelectionInterval(int first, int last)
           
 void setSelectionBackground(Color c)
          NOT IMPLEMENTED - MEANINGLESS TO PLATFORM TABLE
 void setSelectionForeground(Color c)
          NOT IMPLEMENTED - MEANINGLESS TO PLATFORM TABLE
 void setSelectionMode(int mode)
           
 void setSelectionModel(ListSelectionModel l)
           
 void setShowGrid(boolean b)
           
 void setShowHorizontalLines(boolean b)
           
 void setShowVerticalLines(boolean b)
           
 void setSwingWTParent(Container parent)
          Once a parent component receives an "add" call for a child, this being the child, this should be called to tell us to instantiate the peer and load in any cached properties.
 void setValueAt(java.lang.Object value, int row, int col)
           
 void showSelection()
          Scrolls the table to the selected row.
 void tableChanged(TableModelEvent e)
          Called by the model to let us know when things change.
 void valueChanged(ListSelectionEvent e)
           
 
Methods inherited from class swingwtx.swing.JComponent
add, add, add, add, add, addPropertyChangeListener, addPropertyChangeListener, checkInternalFrameChild, dispose, getAccessibleContext, getActionMap, getAutoscrolls, getBorder, getClientProperty, getInputMap, getInsets, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isValidateRoot, paint, paintBackground, paintChildren, paintComponent, paintImmediately, paintImmediately, putClientProperty, remove, remove, removePropertyChangeListener, removePropertyChangeListener, repaint, revalidate, scrollRectToVisible, setActionMap, setAutoscrolls, setBorder, setDoubleBuffered, setInputMap, setMargin, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled
 
Methods inherited from class swingwt.awt.Container
addComponentToLayout, addContainerListener, debug_showContainmentTree, doAdd, getComponent, getComponentCount, getComponentOrientation, getComponents, getComposite, getLayout, getMaximumSize, getMinimumSize, getParent, getPreferredSize, invalidate, minimumSize, preferredSize, processContainerEvent, processEvent, queuedValidate, removeAll, removeComponentFromCache, removeContainerListener, setLayout, setLayoutImpl, validate
 
Methods inherited from class swingwt.awt.Component
add, addActionListener, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, calculatePreferredSize, componentOnlyDispose, computePreferredSize, contains, contains, createImage, createListenerArrayFromVector, createVolatileImage, dispatchEvent, getActionCommand, getAlignmentX, getAlignmentY, getBackground, getBounds, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getListeners, getLocation, getLocationOnScreen, getName, getPeer, getPeerSize, getSize, getSize, getSWTPeer, getToolkit, getToolTipText, getTreeLock, getWidth, getX, getY, grabFocus, hasFocus, hasSetFont, hide, imageUpdate, inside, isEnabled, isFocusable, isMinimumSizeSet, isShowing, isVisible, processActionEvent, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, processTraverseEvent, registerActionEvents, registerComponentEvents, registerEvents, registerExtendedModifyEvents, registerFocusEvents, registerKeyEvents, registerModifyEvents, registerMouseEvents, registerPaintEvents, registerTraversalEvents, remove, removeActionListener, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, repaint, repaint, requestFocus, setActionCommand, setAlignmentX, setAlignmentY, setBackground, setBounds, setBounds, setCachedProperties, setComponentOrientation, setComponentRemoved, setCursor, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setFont, setForeground, setHeight, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setSize, setSize, setToolTipText, setVisible, setWidth, show, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTO_RESIZE_OFF

public static final int AUTO_RESIZE_OFF
See Also:
Constant Field Values

AUTO_RESIZE_NEXT_COLUMN

public static final int AUTO_RESIZE_NEXT_COLUMN
See Also:
Constant Field Values

AUTO_RESIZE_SUBSEQUENT_COLUMNS

public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS
See Also:
Constant Field Values

AUTO_RESIZE_LAST_COLUMN

public static final int AUTO_RESIZE_LAST_COLUMN
See Also:
Constant Field Values

AUTO_RESIZE_ALL_COLUMNS

public static final int AUTO_RESIZE_ALL_COLUMNS
See Also:
Constant Field Values

ppeer

protected org.eclipse.swt.widgets.Table ppeer

header

protected JTableHeader header

columnModel

protected TableColumnModel columnModel

listSelectionModel

protected ListSelectionModel listSelectionModel

cellEditor

protected TableCellEditor cellEditor

pRowHeight

protected int pRowHeight

pIntercell

protected Dimension pIntercell

pLines

protected boolean pLines
Cache - whether to show grid lines


pSelRow

protected int pSelRow

pSelCol

protected int pSelCol

editingColumn

protected int editingColumn
Cache of values for current cell editor


editingRow

protected int editingRow

editingEditor

protected TableCellEditor editingEditor

editingComponent

protected Component editingComponent

cellSelectionEnabled

protected boolean cellSelectionEnabled
Whether cell selection (and thus cell editing) is enabled


swtEditor

protected org.eclipse.swt.custom.TableEditor swtEditor
The SWT table editor


swtCursor

protected org.eclipse.swt.custom.TableCursor swtCursor
The SWT table cursor


useFastVirtualTables

protected boolean useFastVirtualTables
Whether or not to use SWT's fast virtual tables


tableDrawnOnce

protected boolean tableDrawnOnce
Whether the table has been displayed yet. If it has then we force a redraw when setSwingWTParent is called since it must mean it has been removed from a container and redrawn. This is used in conjunction with modelDirty to make sure we only fill the table from the model when we need to.


rowSelection

protected boolean rowSelection

columnSelection

protected boolean columnSelection
Constructor Detail

JTable

public JTable()

JTable

public JTable(int numRows,
              int numCols)

JTable

public JTable(java.lang.Object[][] rowData,
              java.lang.Object[] columnNames)

JTable

public JTable(java.util.Vector rowData,
              java.util.Vector columnNames)

JTable

public JTable(TableModel dm)

JTable

public JTable(TableModel dm,
              TableColumnModel columnModel)

JTable

public JTable(TableModel dm,
              TableColumnModel columnModel,
              ListSelectionModel selectionModel)
Method Detail

getModel

public TableModel getModel()

setModel

public void setModel(TableModel dm,
                     boolean noRefresh)

setModel

public void setModel(TableModel dm)

clearSelection

public void clearSelection()

doLayout

public void doLayout()
Description copied from class: Container
Forces laying out of this container's child components again.

Overrides:
doLayout in class Container

getColumnCount

public int getColumnCount()

getColumnName

public java.lang.String getColumnName(int index)

getColumn

public TableColumn getColumn(java.lang.Object identifier)

getColumn

public TableColumn getColumn(int index)

getRowCount

public int getRowCount()

getSelectedColumn

public int getSelectedColumn()
NOT IMPLEMENTED


getSelectedColumnCount

public int getSelectedColumnCount()
NOT IMPLEMENTED


getSelectedColumns

public int[] getSelectedColumns()
NOT IMPLEMENTED


setRowSelectionInterval

public void setRowSelectionInterval(int first,
                                    int last)

getSelectedRow

public int getSelectedRow()

getSelectedRowCount

public int getSelectedRowCount()

getSelectedRows

public int[] getSelectedRows()

getShowHorizontalLines

public boolean getShowHorizontalLines()

isShowHorizontalLines

public boolean isShowHorizontalLines()

getShowVerticalLines

public boolean getShowVerticalLines()

isShowVerticalLines

public boolean isShowVerticalLines()

getShowGrid

public boolean getShowGrid()

isShowGrid

public boolean isShowGrid()

setShowHorizontalLines

public void setShowHorizontalLines(boolean b)

setShowVerticalLines

public void setShowVerticalLines(boolean b)

setShowGrid

public void setShowGrid(boolean b)

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)

resizeAndRepaint

public void resizeAndRepaint()

selectAll

public void selectAll()

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)

getColumnModel

public TableColumnModel getColumnModel()

setAutoCreateColumnsFromModel

public void setAutoCreateColumnsFromModel(boolean b)
NOT IMPLEMENTED - just override the column model produced - you won't even notice


setColumnModel

public void setColumnModel(TableColumnModel model)

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()

addColumn

public void addColumn(TableColumn tableColumn)

setRowSelectionAllowed

public void setRowSelectionAllowed(boolean b)
NOT IMPLEMENTED


setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean b)
NOT IMPLEMENTED


getRowSelectionAllowed

public boolean getRowSelectionAllowed(boolean b)

setCellSelectionEnabled

public void setCellSelectionEnabled(boolean b)

getCellSelectionEnabled

public boolean getCellSelectionEnabled(boolean b)

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed(boolean b)

getSelectionBackground

public Color getSelectionBackground()
NOT IMPLEMENTED - HARD RETURNS A COLOUR VALUE


getSelectionForeground

public Color getSelectionForeground()
NOT IMPLEMENTED - HARD RETURNS A COLOUR VALUE


setSelectionBackground

public void setSelectionBackground(Color c)
NOT IMPLEMENTED - MEANINGLESS TO PLATFORM TABLE


setSelectionForeground

public void setSelectionForeground(Color c)
NOT IMPLEMENTED - MEANINGLESS TO PLATFORM TABLE


setIntercellSpacing

public void setIntercellSpacing(Dimension d)
NOT IMPLEMENTED


getIntercellSpacing

public Dimension getIntercellSpacing()

getRowHeight

public int getRowHeight()

setRowHeight

public void setRowHeight(int height)
NOT IMPLEMENTED


setRowHeight

public void setRowHeight(int row,
                         int height)
NOT IMPLEMENTED


rowAtPoint

public int rowAtPoint(Point p)
NOT IMPLEMENTED


getAutoResizeMode

public int getAutoResizeMode()
NOT IMPLEMENTED


setAutoResizeMode

public void setAutoResizeMode(int size)
NOT IMPLEMENTED


getSelectionModel

public ListSelectionModel getSelectionModel()

setSelectionModel

public void setSelectionModel(ListSelectionModel l)

setSelectionMode

public void setSelectionMode(int mode)

setDefaultRenderer

public void setDefaultRenderer(java.lang.Class columnClass,
                               TableCellRenderer tableCellRenderer)

getDefaultRenderer

public TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)

createDefaultRenderers

protected void createDefaultRenderers()

prepareRenderer

public Component prepareRenderer(TableCellRenderer renderer,
                                 int row,
                                 int column)

isCellSelected

public boolean isCellSelected(int row,
                              int col)

setModelDirty

public void setModelDirty(boolean b)
Tells the table that it needs to redraw when refreshTable() is next called.


changeSelection

public void changeSelection(int row,
                            int col,
                            boolean toggle,
                            boolean extend)

showSelection

public void showSelection()
Scrolls the table to the selected row. This is not a Swing method


convertColumnIndexToModel

public int convertColumnIndexToModel(int index)
SWT table columns aren't movable, so columnIndex == modelIndex


getTableHeader

public JTableHeader getTableHeader()

setSwingWTParent

public void setSwingWTParent(Container parent)
                      throws java.lang.Exception
Once a parent component receives an "add" call for a child, this being the child, this should be called to tell us to instantiate the peer and load in any cached properties.

Overrides:
setSwingWTParent in class JComponent
Throws:
java.lang.Exception

setDirty

public void setDirty(boolean b)
Sets whether the model is dirty for forcing updates


refreshTable

public void refreshTable()
Forces a complete rebuild of the peer from the data model.


refreshTable

public void refreshTable(int rowFrom,
                         int rowTo)
Just like refreshTable(), except it does not generate the column headers and only updates the rows specified. This is used for change events from the model.


registerCursorSelectionEvents

protected void registerCursorSelectionEvents()
Assigns events to the cursor for selection so that we can update the ListSelectionModel for this component.


registerTableListSelectionEvents

protected void registerTableListSelectionEvents()
Assigns events to the table for selection


processListSelection

protected void processListSelection()
Called back when a row/cell is selected in the table to fire events on to user processes.


processCellEdit

protected void processCellEdit()
Called back when the user selects a cell in the table to handle the editing


editingCanceled

public void editingCanceled(ChangeEvent e)
Callback when the editor is cancelled - need to regenerate the table cursor

Specified by:
editingCanceled in interface CellEditorListener

editingStopped

public void editingStopped(ChangeEvent e)
Callback when the editor is stopped - need to regenerate the table cursor and put any changes back into the model.

Specified by:
editingStopped in interface CellEditorListener

processColumnClick

protected void processColumnClick(int index)
When a column is clicked by the user, this routine gets fired, which generates a mouse event for the thing and then sends it to the TableHeader mouseEvent listeners for dispatch to the user process


getCellEditor

public TableCellEditor getCellEditor()

getCellEditor

public TableCellEditor getCellEditor(int row,
                                     int col)

setCellEditor

public void setCellEditor(TableCellEditor cell)

getEditingColumn

public int getEditingColumn()

setEditingColumn

public void setEditingColumn(int aColumn)

getEditingRow

public int getEditingRow()

setEditingRow

public void setEditingRow(int aRow)

tableChanged

public void tableChanged(TableModelEvent e)
Called by the model to let us know when things change.

Specified by:
tableChanged in interface TableModelListener

valueChanged

public void valueChanged(ListSelectionEvent e)
Specified by:
valueChanged in interface ListSelectionListener

columnAdded

public void columnAdded(TableColumnModelEvent e)
Specified by:
columnAdded in interface TableColumnModelListener

columnMarginChanged

public void columnMarginChanged(ChangeEvent e)
Specified by:
columnMarginChanged in interface TableColumnModelListener

columnMoved

public void columnMoved(TableColumnModelEvent e)
Specified by:
columnMoved in interface TableColumnModelListener

columnRemoved

public void columnRemoved(TableColumnModelEvent e)
Specified by:
columnRemoved in interface TableColumnModelListener

columnSelectionChanged

public void columnSelectionChanged(ListSelectionEvent e)
Specified by:
columnSelectionChanged in interface TableColumnModelListener

createTableCursor

protected void createTableCursor()
Creates the table cursor and maps events to it


isEditing

public boolean isEditing()

removeColumn

public void removeColumn(TableColumn tableColumn)