butler.swing.record
Class RecordListTable

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 butler.swing.record.RecordListTable
All Implemented Interfaces:
RecordSelectionListener, java.awt.event.ActionListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ChangeListener, javax.swing.event.ListSelectionListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable

public class RecordListTable
extends javax.swing.JTable
implements java.awt.event.ActionListener, RecordSelectionListener, java.awt.event.WindowListener, javax.swing.event.ChangeListener

Editor component for a RecordList. This component allows the user to update, insert or delete records.
Column values will be edited with the appropiate ValueEditor.
Column from related records can also be shown.

Author:
Fredrik Bertilsson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable, 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.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
static java.lang.String DELETE_ACTION_COMMAND
           
static java.lang.String NEW_ACTION_COMMAND
           
static java.lang.String SAVE_ACTION_COMMAND
           
 
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, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
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
RecordListTable(DRecordListTable desc)
           
RecordListTable(Table tab)
          Creates a RecordListTable
RecordListTable(Table tab, boolean editable, boolean multipleSelection)
          Creates a RecordListTable
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addChangeListener(javax.swing.event.ChangeListener listener)
           
 void addColumn(Column col)
          Deprecated. Use RecordTable descriptor
 void addColumn(DefaultTableColumn column)
          Deprecated. Use RecordTable descriptor
 void addColumn(ForeignKey fk, Column col)
          Deprecated. Use RecordTable descriptor
 Record addRecord()
          Adds a new (empty) record to this table.
 void addRecordListSelected(RecordList recList)
          Adds the given records to the already existing _recList.
 void addRecordSelectionListener(RecordSelectionListener listener)
           
 void addRecordSelectionListener(RecordSelectionListener listener, boolean doubleClick)
           
 void addSelectedRecord(Record rec)
           
 void clearColumns()
           
 void clearTable()
           
 DRecordListTable getDescriptor()
           
 int getIndex(Record rec)
           
 Record getRecord(int row)
           
 RecordList getRecordList()
           
 RecordListTableModel getRecordListTableModel()
           
 SaveAction getSaveAction()
           
 Table getTable()
           
 void init()
           
 void init(DRecordListTable desc)
           
 boolean isDirty()
           
 void recordListSelected(RecordList recList)
          Populates this RecordListTable with the given RecordList.
 void recordSelected(Record rec)
           
 void save()
           
 void setDatatype(Column col, Datatype datatype)
           
 void setDefaultValue(Column col, java.lang.Object value)
           
 void setEditable(boolean flag)
           
 void setInsertable(boolean flag)
           
 void stateChanged(javax.swing.event.ChangeEvent e)
          Updates a row in the table.
 void stopEditing()
           
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
           
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, 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
 

Field Detail

SAVE_ACTION_COMMAND

public static final java.lang.String SAVE_ACTION_COMMAND
See Also:
Constant Field Values

NEW_ACTION_COMMAND

public static final java.lang.String NEW_ACTION_COMMAND
See Also:
Constant Field Values

DELETE_ACTION_COMMAND

public static final java.lang.String DELETE_ACTION_COMMAND
See Also:
Constant Field Values
Constructor Detail

RecordListTable

public RecordListTable(Table tab)
                throws java.lang.Exception
Creates a RecordListTable

Parameters:
tab - Table to which the records belongs.
Throws:
java.lang.Exception

RecordListTable

public RecordListTable(Table tab,
                       boolean editable,
                       boolean multipleSelection)
                throws java.lang.Exception
Creates a RecordListTable

Parameters:
tab - Table to which the records belongs.
editable - Flag that tells if the records is editable.
multipleSelection - Flag that tells if multiple selection is allowed.
Throws:
java.lang.Exception

RecordListTable

public RecordListTable(DRecordListTable desc)
                throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

init

public void init(DRecordListTable desc)
          throws java.lang.Exception
Throws:
java.lang.Exception

init

public void init()
          throws java.lang.Exception
Throws:
java.lang.Exception

getTable

public Table getTable()

clearTable

public void clearTable()
                throws java.lang.Exception
Throws:
java.lang.Exception

setEditable

public void setEditable(boolean flag)

setInsertable

public void setInsertable(boolean flag)

getDescriptor

public DRecordListTable getDescriptor()

addColumn

public void addColumn(DefaultTableColumn column)
               throws java.lang.Exception
Deprecated. Use RecordTable descriptor

Adds a column to this table.

Throws:
java.lang.Exception

addColumn

public void addColumn(Column col)
               throws java.lang.Exception
Deprecated. Use RecordTable descriptor

Adds a column to this table.

Throws:
java.lang.Exception

addColumn

public void addColumn(ForeignKey fk,
                      Column col)
               throws java.lang.Exception
Deprecated. Use RecordTable descriptor

Adds a column from a related table to this table.

Parameters:
fk - Foreign key for the relation. This main table for this RecordListTable must be the fktable in this foreign key. The related table is the pktable.
col - Column in the related table.
Throws:
java.lang.Exception

clearColumns

public void clearColumns()
                  throws java.lang.Exception
Throws:
java.lang.Exception

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)

addRecordListSelected

public void addRecordListSelected(RecordList recList)
                           throws java.lang.Exception
Adds the given records to the already existing _recList. Records that already exists will not be added.

Parameters:
recList - records to be added
Throws:
java.lang.Exception

recordListSelected

public void recordListSelected(RecordList recList)
                        throws java.lang.Exception
Populates this RecordListTable with the given RecordList.

Specified by:
recordListSelected in interface RecordSelectionListener
Throws:
java.lang.Exception

recordSelected

public void recordSelected(Record rec)
                    throws java.lang.Exception
Specified by:
recordSelected in interface RecordSelectionListener
Throws:
java.lang.Exception

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

addRecord

public Record addRecord()
                 throws java.lang.Exception
Adds a new (empty) record to this table.

Returns:
The created record.
Throws:
java.lang.Exception

save

public void save()
          throws java.lang.Exception
Throws:
java.lang.Exception

addRecordSelectionListener

public void addRecordSelectionListener(RecordSelectionListener listener,
                                       boolean doubleClick)

addRecordSelectionListener

public void addRecordSelectionListener(RecordSelectionListener listener)

getRecord

public Record getRecord(int row)

getRecordList

public RecordList getRecordList()

getIndex

public int getIndex(Record rec)
             throws java.lang.Exception
Throws:
java.lang.Exception

addSelectedRecord

public void addSelectedRecord(Record rec)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getRecordListTableModel

public RecordListTableModel getRecordListTableModel()

setDefaultValue

public void setDefaultValue(Column col,
                            java.lang.Object value)

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Updates a row in the table. The changed record should be the source in the change event.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

stopEditing

public void stopEditing()
                 throws java.lang.Exception
Throws:
java.lang.Exception

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

setDatatype

public void setDatatype(Column col,
                        Datatype datatype)
                 throws java.lang.Exception
Throws:
java.lang.Exception

isDirty

public boolean isDirty()

getSaveAction

public SaveAction getSaveAction()