jsky.catalog.gui
Class TableDisplay

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jsky.catalog.gui.TableDisplay
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, QueryResultDisplay, PrintableWithDialog, SaveableAsHTML, Storeable

public class TableDisplay
extends javax.swing.JPanel
implements QueryResultDisplay, PrintableWithDialog, SaveableAsHTML, Storeable

This widget displays the contents of a TableQueryResult in a JTable and implements scrolling, editing, searching and sorting methods.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableDisplay()
          Initialize an empty table.
TableDisplay(QueryResultDisplay queryResultDisplay)
          Create an empty TableDisplay (Call setModel to set the data to display).
TableDisplay(TableQueryResult tableQueryResult)
          Create an empty TableDisplay (Call setModel to set the data to display).
TableDisplay(TableQueryResult tableQueryResult, QueryResultDisplay queryResultDisplay)
          Create a TableDisplay for viewing the given table data.
 
Method Summary
 void deselectRow(int row)
          Deselect the given table row.
 QueryResultDisplay getQueryResultDisplay()
          Return the object used to display query results (when following links)
 javax.swing.JScrollPane getScrollPane()
          Return the JScrollPane used to scroll the table
 boolean[] getShow()
          Return an array specifying which columns to show, if defined, otherwise null.
 SortedJTable getTable()
          Return the widget used to display the table.
 TableQueryResult getTableQueryResult()
          Return the current table query result (same as the table model).
protected  int initColumnSizes(javax.swing.JTable table, boolean[] show)
           
static void main(java.lang.String[] args)
          test main
 void print()
          Display a print dialog to print the contents of this object.
 void print(java.lang.String title)
          Display a print dialog to print the contents of this object with the specified table title.
 void resize()
          Called when the table is resized
 boolean restoreSettings(java.lang.Object obj)
          Restore the settings previously stored.
 void saveAsHTML(java.lang.String filename)
          Save the table to the given filename in HTML format
 void selectRow(int row)
          Select the given table row.
protected  void setColumnRenderers()
          Set up any required JTable renderers, so that the values in the query result are displayed correctly by the JTable.
 void setModel(TableQueryResult tableQueryResult)
          Set the data to display in the table.
 void setQueryResult(QueryResult queryResult)
          If the given query result is a table, display it, otherwise do nothing.
 void setQueryResultDisplay(QueryResultDisplay q)
          Set the object used to display query results (when following links)
 void setShow(boolean[] show)
          Set an array specifying which columns to show (or null, for default)
 java.lang.Object storeSettings()
          Store the current settings in a serializable object and return the object.
 void update()
          Update the table after the model has changed.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, 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, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, 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, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableDisplay

public TableDisplay(TableQueryResult tableQueryResult,
                    QueryResultDisplay queryResultDisplay)
Create a TableDisplay for viewing the given table data.

Parameters:
tableQueryResult - the table to use.
queryResultDisplay - used to display any query results (resulting from following links)

TableDisplay

public TableDisplay(TableQueryResult tableQueryResult)
Create an empty TableDisplay (Call setModel to set the data to display).

Parameters:
tableQueryResult - the table to use.

TableDisplay

public TableDisplay(QueryResultDisplay queryResultDisplay)
Create an empty TableDisplay (Call setModel to set the data to display).

Parameters:
queryResultDisplay - used to display any query results (resulting from following links)

TableDisplay

public TableDisplay()
Initialize an empty table. Call setModel() to set the data to display, and setQueryResultDisplay to set the display class to use when following links.

Method Detail

getTable

public SortedJTable getTable()
Return the widget used to display the table.


getScrollPane

public javax.swing.JScrollPane getScrollPane()
Return the JScrollPane used to scroll the table


setQueryResultDisplay

public void setQueryResultDisplay(QueryResultDisplay q)
Set the object used to display query results (when following links)


getQueryResultDisplay

public QueryResultDisplay getQueryResultDisplay()
Return the object used to display query results (when following links)


setQueryResult

public void setQueryResult(QueryResult queryResult)
If the given query result is a table, display it, otherwise do nothing.

Specified by:
setQueryResult in interface QueryResultDisplay

getTableQueryResult

public TableQueryResult getTableQueryResult()
Return the current table query result (same as the table model).


setModel

public void setModel(TableQueryResult tableQueryResult)
Set the data to display in the table.


update

public void update()
Update the table after the model has changed.


initColumnSizes

protected int initColumnSizes(javax.swing.JTable table,
                              boolean[] show)

setColumnRenderers

protected void setColumnRenderers()
Set up any required JTable renderers, so that the values in the query result are displayed correctly by the JTable. This is needed, for example, if a certain column should contain a button or other widget instead of the default text item, or if a value needs special formatting.


print

public void print(java.lang.String title)
           throws java.awt.print.PrinterException
Display a print dialog to print the contents of this object with the specified table title.

Throws:
java.awt.print.PrinterException

print

public void print()
           throws java.awt.print.PrinterException
Display a print dialog to print the contents of this object.

Specified by:
print in interface PrintableWithDialog
Throws:
java.awt.print.PrinterException

resize

public void resize()
Called when the table is resized


selectRow

public void selectRow(int row)
Select the given table row.

Parameters:
row - the index of the row (0 is the first row)

deselectRow

public void deselectRow(int row)
Deselect the given table row.

Parameters:
row - the index of the row (0 is the first row)

getShow

public boolean[] getShow()
Return an array specifying which columns to show, if defined, otherwise null.


setShow

public void setShow(boolean[] show)
Set an array specifying which columns to show (or null, for default)


saveAsHTML

public void saveAsHTML(java.lang.String filename)
                throws java.io.IOException
Save the table to the given filename in HTML format

Specified by:
saveAsHTML in interface SaveableAsHTML
Throws:
java.io.IOException

storeSettings

public java.lang.Object storeSettings()
Store the current settings in a serializable object and return the object.

Specified by:
storeSettings in interface Storeable

restoreSettings

public boolean restoreSettings(java.lang.Object obj)
Restore the settings previously stored.

Specified by:
restoreSettings in interface Storeable

main

public static void main(java.lang.String[] args)
test main