net.xoetrope.deprecated.swing
Class XTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by net.xoetrope.swing.XScrollPane
                      extended by net.xoetrope.deprecated.swing.XTable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.ScrollPaneConstants, XRowSelector, XStyleComponent, XAttributedComponent, XHashCode, XModelHolder

public class XTable
extends XScrollPane
implements XAttributedComponent, XModelHolder, java.awt.ItemSelectable, XStyleComponent, XHashCode, XRowSelector

Provides a simple read-only tables/grid component.

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JScrollPane
javax.swing.JScrollPane.AccessibleJScrollPane, javax.swing.JScrollPane.ScrollBar
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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 javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
XTable()
          Create a new table
 
Method Summary
 void addItemListener(java.awt.event.ItemListener l)
          Adds the specified item listener to receive item events from this list.
 void addMouseListener(java.awt.event.MouseListener l)
          Add a mouse listener
 void addNotify()
          Creates the scroll pane's peer and sizes the child element.
 void checkSize()
          Recalculate and check the size of the content
 void first()
          Move to the first row
 long getComponentHashCode()
          Get the hash code to be used by the event handler for this component
 java.awt.Container getComponentPanel()
          Get the container that holds the components
 java.lang.String getContent()
          Set the model's name
 java.lang.String getFieldValue(int fieldIdx)
          Gets a field value as a string from the currently selected row
 java.lang.String getFieldValue(int rowIdx, int fieldIdx)
          Gets a field value as a string from the specified row
 XModel getModel()
          Get the underlying model.
 java.lang.Object[] getSelectedObjects()
          Returns the selected items on the list in an array of objects.
 int getSelectedRow()
          Get the index of the selected row
 java.lang.Object getValue(int fieldIdx)
          Gets a field value object from the currently selected row
 java.lang.Object getValue(int rowIdx, int fieldIdx)
          Gets a field value object from the specified row
 boolean isInteractiveTable()
          Check the if the table is interactive
 void last()
          Move to the last row
 void next()
          Move to the next row
 void prev()
          Move to the previous row
 void removeItemListener(java.awt.event.ItemListener l)
          Removes the specified item listener so that it no longer receives item events from this list.
 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 setBounds(int x, int y, int w, int h)
          Sets the bounds for this component
 void setColWidth(int fieldIdx, int w)
          Set the table column width;
 void setComponentAt(int col, java.lang.String className)
          Set the type of component for a column
 void setHeaderStyle(java.lang.String style)
          Set the style of the header data
 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 setStyle(java.lang.String style)
          Set the general style of the XTable
 void setUpdateModelSelection(boolean doUpdate)
          Tie the model selection to this table's selection
 void update()
          implemented from XModelHolder interface
 
Methods inherited from class net.xoetrope.swing.XScrollPane
add, setNextHorzScrollPanePolicy, setNextScrollPanePolicy, setNextVertScrollPanePolicy
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XTable

public XTable()
Create a new table

Method Detail

update

public void update()
implemented from XModelHolder interface

Specified by:
update in interface XModelHolder

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

getModel

public XModel getModel()
Get the underlying model.

Returns:
the model

checkSize

public void checkSize()
Recalculate and check the size of the content


getComponentPanel

public java.awt.Container getComponentPanel()
Get the container that holds the components

Returns:
the viewport pane

setComponentAt

public void setComponentAt(int col,
                           java.lang.String className)
Set the type of component for a column

Parameters:
col - the field index
className - the class name

getContent

public java.lang.String getContent()
Set the model's name

Returns:
the name

addNotify

public void addNotify()
Creates the scroll pane's peer and sizes the child element.

Overrides:
addNotify in class javax.swing.JComponent

setStyle

public void setStyle(java.lang.String style)
Set the general style of the XTable

Specified by:
setStyle in interface XStyleComponent
Parameters:
style - XStyle

setHeaderStyle

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

Parameters:
style - XStyle

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

isInteractiveTable

public boolean isInteractiveTable()
Check the if the table is interactive

Returns:
true if the table supports user interaction

setInteractiveTable

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

Parameters:
state - true for an user interactive table.

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 index of the selected row

Specified by:
getSelectedRow in interface XRowSelector
Returns:
the index of the selected row

first

public void first()
Move to the first row


prev

public void prev()
Move to the previous row


next

public void next()
Move to the next row


last

public void last()
Move to the last row


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

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Sets the bounds for this component

Overrides:
setBounds in class java.awt.Component
Parameters:
x - x/left
y - y/top
w - width
h - height

setColWidth

public void setColWidth(int fieldIdx,
                        int w)
Set the table column width;

Parameters:
fieldIdx - the field index
w - the new column width

setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component. Currently this handles the attributes
  1. headingStyle, value=the table header style
  2. selectionStyle, value=the selected row style
  3. interactive, value=true|false
  4. updateModel, value=true|false update the underlying model selection (the selected row)

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

getValue

public java.lang.Object getValue(int fieldIdx)
Gets a field value object from the currently selected row

Parameters:
fieldIdx - the field offset
Returns:
the value

getValue

public java.lang.Object getValue(int rowIdx,
                                 int fieldIdx)
Gets a field value object from the specified row

Parameters:
rowIdx - the row offset
fieldIdx - the field offset
Returns:
the value

getFieldValue

public java.lang.String getFieldValue(int fieldIdx)
Gets a field value as a string from the currently selected row

Parameters:
fieldIdx - the field offset
Returns:
the value

getFieldValue

public java.lang.String getFieldValue(int rowIdx,
                                      int fieldIdx)
Gets a field value as a string from the specified row

Parameters:
rowIdx - the row offset
fieldIdx - the field offset
Returns:
the value

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Adds the specified item listener to receive item events from this list. Item events are sent in response to user input, but not in response to calls to select or deselect. If listener l is null, no exception is thrown and no action is performed.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
l - the item listener
Since:
JDK1.1
See Also:
ItemEvent, ItemListener

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes the specified item listener so that it no longer receives item events from this list. If listener l is null, no exception is thrown and no action is performed.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
l - the item listener
Since:
JDK1.1
See Also:
ItemEvent, ItemListener

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Returns the selected items on the list in an array of objects.

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
the selected item/row
See Also:
ItemSelectable

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Add a mouse listener

Overrides:
addMouseListener in class java.awt.Component
Parameters:
l - the new mouse listener

getComponentHashCode

public long getComponentHashCode()
Get the hash code to be used by the event handler for this component

Specified by:
getComponentHashCode in interface XHashCode
Returns:
the hash code