com.jstatcom.table
Class JSCAbstractDataTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by com.jstatcom.table.BorderTable
                      extended by com.jstatcom.table.JSCAbstractDataTable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.RowSorterListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable
Direct Known Subclasses:
JSCNArrayTable, JSCSArrayTable

public abstract class JSCAbstractDataTable
extends BorderTable

Abstract table to be subclassed by tables for data arrays, like JSCSArray and JSCNArray. Subclasses must provide implementations for setting the model according to the displayed data type. They should also overwrite createDefaultDataModel for a default model.

Author:
Markus Kraetzig
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.DropLocation, javax.swing.JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JSCAbstractDataTable()
          Default constructor.
 
Method Summary
 void addNotify()
          Overwrites supermethod to retrieve symbol table from component hierarchy if this table is displayed.
 void createDefaultColumnsFromModel()
          This method will create default columns for the table from the data model.
 javax.swing.table.TableCellRenderer getCellRenderer()
          Gets the renderer for the cells.
 int[] getIntSelectionIndex()
          Gets a vector with length getRowCount of zeros and ones representing the selection status for each row.
 JSCData getJSCData()
          Gets a reference (not a copy) to the data object displayed in this table.
 java.awt.event.MouseListener getMouseListener()
          Gets the mouse listener.
 int getRowSelectionMode()
          Gets the selection mode for table rows.
 java.lang.String getSymbolName()
          Gets the name of the symbol to display.
 java.lang.String getSymbolNameSelRows()
          Gets the symbol name for the data object with the index of selected rows.
 Scope getSymbolScope()
          Gets the current scope, which defines which symbol table to use ( local,global or upper).
 SymbolTable getSymbolTable()
          Gets the explicitely set symbol table used by this table to retrieve symbols by their name.
 javax.swing.JPopupMenu getTablePopup()
          Gets the RIGHT mouse popup for the table.
 boolean isEditable()
          Gets whether table is editable.
 void setCellRenderer(javax.swing.table.TableCellRenderer renderer)
          Sets the renderer for all cells.
 void setColEditable(boolean editable, int colIndex, boolean clearPreviousBefore)
          Sets a columns editable.
 void setEditable(boolean editable)
          Sets whether table is editable.
 void setJSCData(JSCData data)
          Sets the data object to be displayed in this table.
 void setModel(javax.swing.table.TableModel model)
          Overwrites supermethod to fire a "model" property change event.
abstract  void setModelForJSCData(JSCData data)
          Sets the table model for a data object.
abstract  void setModelForSymbolName(SymbolTable table, java.lang.String name)
          Sets the table model according to the symbol defined by table and name.
 void setMouseListener(java.awt.event.MouseListener listener)
          Sets the mouse listener.
 void setRowEditable(boolean editable, int rowIndex, boolean clearPreviousBefore)
          Sets a rows editable.
 void setRowSelectionMode(int newRowSelMode)
          Sets the selection mode for rows.
 void setSymbolName(java.lang.String symbolName)
          Sets the name of the symbol to display.
 void setSymbolNameSelRows(java.lang.String symbolNameSelRows)
          Sets the name of the symbol with the index of selected table rows.
 void setSymbolScope(Scope scope)
          Sets the symbol scope, which defines which symbol table to use ( local,global or upper).
 void setSymbolTable(SymbolTable table)
          Sets the symbol table used by this table to retrieve symbols by their name and the corresponding type for the table.
 void setTablePopup(javax.swing.JPopupMenu menu)
          Sets the RIGHT mouse popup for the table.
 void tableChanged(javax.swing.event.TableModelEvent e)
          Overwrites supermethod to configure ecnclosing scrollpane and update selection data.
 void updateUI()
          Notification from the UIManager that the L&F has changed.
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          Invoked when the list selection changes.
 
Methods inherited from class com.jstatcom.table.BorderTable
columnAtPoint, getCellRect, getColumnWidth, getMaximumColumnWidth, getMaximumSize, getMinimumColumnWidth, getMinimumSize, getPreferredSize, isDynamicColumnWidth, maxCellLength, rowAtPoint, setBorder, setColumnWidth, setDynamicColumnWidth, setIntercellSpacing, setMaximumColumnWidth, setMinimumColumnWidth, sizeColumnsToFit
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, prepareEditor, prepareRenderer, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sorterChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSCAbstractDataTable

public JSCAbstractDataTable()
Default constructor. The dynamicColumnWidth property is set to true.

Method Detail

setColEditable

public void setColEditable(boolean editable,
                           int colIndex,
                           boolean clearPreviousBefore)
Sets a columns editable.

Parameters:
editable -
colIndex -
clearPreviousBefore - clear previous editable states

setRowEditable

public void setRowEditable(boolean editable,
                           int rowIndex,
                           boolean clearPreviousBefore)
Sets a rows editable.

Parameters:
editable -
rowIndex -
clearPreviousBefore - clear previous editable states

isEditable

public boolean isEditable()
Gets whether table is editable. Default is false.

Returns:
true if editable

setEditable

public void setEditable(boolean editable)
Sets whether table is editable. Default is false.

Parameters:
editable - true if editable

getSymbolName

public java.lang.String getSymbolName()
Gets the name of the symbol to display. The symbol is retrieved from the symbol table of the given scope.

Returns:
name of the symbol

setSymbolName

public void setSymbolName(java.lang.String symbolName)
Sets the name of the symbol to display. The symbol is retrieved from the symbol table of the given scope.

Parameters:
symbolName - symbol name
Throws:
java.lang.IllegalArgumentException - if symbolName is invalid

getSymbolScope

public Scope getSymbolScope()
Gets the current scope, which defines which symbol table to use ( local,global or upper).

Returns:
symbol scope

setSymbolScope

public void setSymbolScope(Scope scope)
Sets the symbol scope, which defines which symbol table to use ( local,global or upper). This also sets a previously set symbol table to null.

Parameters:
scope - the symbol scope
Throws:
java.lang.IllegalArgumentException - if (scope == null)

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.

Reimplementation of superclass method.

Overrides:
updateUI in class javax.swing.JTable
See Also:
JComponent.updateUI()

getMouseListener

public java.awt.event.MouseListener getMouseListener()
Gets the mouse listener. Can be used to change table values by clicking on it. Default is null.

Returns:
a mouse listener

setMouseListener

public void setMouseListener(java.awt.event.MouseListener listener)
Sets the mouse listener. Can be used to change table values by clicking on it. Default is null. An enumeration of mouse listeners is given in JSCMouseListenerTypes.

Parameters:
listener - a mouse listener

getCellRenderer

public javax.swing.table.TableCellRenderer getCellRenderer()
Gets the renderer for the cells. The default is JSCCellRendererTypes.DEFAULT.

Returns:
cell renderer that is used for all cells

setCellRenderer

public void setCellRenderer(javax.swing.table.TableCellRenderer renderer)
Sets the renderer for all cells. The default is JSCCellRendererTypes.DEFAULT.

Parameters:
renderer - a cell renderer

getTablePopup

public javax.swing.JPopupMenu getTablePopup()
Gets the RIGHT mouse popup for the table.

Returns:
a popup menu

setTablePopup

public void setTablePopup(javax.swing.JPopupMenu menu)
Sets the RIGHT mouse popup for the table. An enumeration of popups can be found in JSCPopupTypes.

Parameters:
menu - a popup menu

getJSCData

public JSCData getJSCData()
Gets a reference (not a copy) to the data object displayed in this table. If the underlying table model is not of type JSCAbstractTableModel,null is returned.

Usage note:
The returned data is a reference to the underlying JSCData object only until a new data object has been set. It should be used read only. Changes that should not affect this table must be made on a copy of the returned object.

Returns:
table data

setJSCData

public void setJSCData(JSCData data)
Sets the data object to be displayed in this table. If this is set, then the symbol name be set to null. If data == null, then the table will be cleared and display zero rows and zero columns.

Parameters:
data - to display

addNotify

public void addNotify()
Overwrites supermethod to retrieve symbol table from component hierarchy if this table is displayed.

Overrides:
addNotify in class javax.swing.JTable

setModel

public void setModel(javax.swing.table.TableModel model)
Overwrites supermethod to fire a "model" property change event.

Overrides:
setModel in class javax.swing.JTable
Parameters:
model - the new table model

getSymbolTable

public SymbolTable getSymbolTable()
Gets the explicitely set symbol table used by this table to retrieve symbols by their name. If non has been set before, null is returned.

Returns:
symbol table

setModelForJSCData

public abstract void setModelForJSCData(JSCData data)
Sets the table model for a data object. Implementations should throw an IllegalArgumentException if data is not of the correct type for the table. A null argument should be allowed for to make it possible to clear the table model. The method is called by setJSCData.

Parameters:
data - the new data for this table

setModelForSymbolName

public abstract void setModelForSymbolName(SymbolTable table,
                                           java.lang.String name)
Sets the table model according to the symbol defined by table and name. The type of the symbol to retrieve must be set by the implementing table. The method is called by setSymbolTable and setSymbolName.

The implementation should also handle null aguments. In this case, an empty model should be set.

Parameters:
table - the data table to retrieve the symbol from
name - the name of the symbol to get

setSymbolTable

public void setSymbolTable(SymbolTable table)
Sets the symbol table used by this table to retrieve symbols by their name and the corresponding type for the table. If table == null then the symbol will be retrieved from the symbol scope hierarchy.

Parameters:
table - a symbol table

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
This method will create default columns for the table from the data model.

This method will clear any exsiting columns before creating the new columns based on information from the model.

Overrides:
createDefaultColumnsFromModel in class BorderTable
See Also:
JTable.getAutoCreateColumnsFromModel()

setRowSelectionMode

public void setRowSelectionMode(int newRowSelMode)
Sets the selection mode for rows.

Parameters:
newRowSelMode - one of ListSelectionModel.SINGLE_SELECTION, ListSelectionModel.SINGLE_INTERVAL or ListSelectionModel.MULTIPLE_INTERVAL_SELECTION

getRowSelectionMode

public int getRowSelectionMode()
Gets the selection mode for table rows.

Returns:
one of ListSelectionModel.SINGLE_SELECTION, ListSelectionModel.SINGLE_INTERVAL or ListSelectionModel.MULTIPLE_INTERVAL_SELECTION

getSymbolNameSelRows

public java.lang.String getSymbolNameSelRows()
Gets the symbol name for the data object with the index of selected rows.

Returns:
the symbol name for the row selection index

setSymbolNameSelRows

public void setSymbolNameSelRows(java.lang.String symbolNameSelRows)
Sets the name of the symbol with the index of selected table rows. The contents of this data object are the results from the a call to getIntSelectionIndex. The symbol is updated everytime the table selection changes. Changes in this symbol do not change the selection in this table. The selection index will only be stored, if the symbol name is set and the symbol table has been set as well or can be retrieved for the symbol scope.

Parameters:
symbolNameSelRows - symbol name
Throws:
java.lang.IllegalArgumentException - if symbolNameSelRows is invalid

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Overwrites supermethod to configure ecnclosing scrollpane and update selection data. It fires a "columnWidth" property change event. The old value is always set to -1.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener
Overrides:
tableChanged in class BorderTable
Parameters:
e - the table model event

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Invoked when the list selection changes. Updates selection data.

Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
Overrides:
valueChanged in class javax.swing.JTable
Parameters:
e - the list selection event

getIntSelectionIndex

public int[] getIntSelectionIndex()
Gets a vector with length getRowCount of zeros and ones representing the selection status for each row. This is different from getSelectedRows which returns the selected indizes. In case of an empty selection, a zero vector with length getRowCount is returned.

Returns:
selection index for each row, 1 selects