net.sf.dc.console
Class TablePanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bynet.sf.dc.console.DataCrowPanel
                      extended bynet.sf.dc.console.TablePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
SQLPanel, TableInsertPanel, TableSearchPanel

public abstract class TablePanel
extends DataCrowPanel

Base panel for all panels which contain a JTable This class facilities most of the functions needed to fill / clear / update tables. It also provides a popup menu for the table and action buttons.

Since:
1.3
Version:
DC0.50
Author:
Robert-Jan van der Waals
See Also:
Serialized Form

Nested Class Summary
 class TablePanel.AddRowAction
          Adds an empty row to the table
 class TablePanel.ClearButtonAction
          Clears the table
 class TablePanel.CreatePdfReport
          Opens the PDF creation dialog
 class TablePanel.FieldSelectorAction
          Opens the hidden / visible fields selector dialog
 class TablePanel.OpenRecordAction
          Opens a record
 class TablePanel.PopupMenu
          Menu shown when the user performs a right click on a table.
 class TablePanel.RemoveRowAction
          Removes a row (or multiple rows) from the table
 class TablePanel.TableActionsPanel
          Panel which holds all buttons and their actions for tables.
 class TablePanel.UpdateAllAction
          Opens the dialog for updating all the values of one (or more) columns in the UI table
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.util.Hashtable cache
           
protected  int moduleIndex
           
protected  TablePanel.TableActionsPanel panelTableActions
           
protected  TablePanel.PopupMenu popupMenu
           
protected  javax.swing.JTable table
           
protected  net.sf.dc.console.TablePanel.TableValueChangedAction tableChangeListener
           
protected  DCTableModel tableModel
           
protected  net.sf.dc.console.TablePanel.TableMouseListener tableMouseListener
           
protected  java.util.Vector vColumns
           
protected  java.util.Vector vHiddenColumns
           
 
Fields inherited from class net.sf.dc.console.DataCrowPanel
labelStatus
 
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
TablePanel(int module)
           
 
Method Summary
 void addRow(java.util.LinkedList data)
          Adds the datacrow objects to the table
 void cancelEdit()
          Tries to apply the current editing of the table cell.
 void clearTable()
          Clear the table of all values
 void createPdfReport()
          Creates a PDF report.
 void fillTable(java.util.LinkedList data)
          Fills the table with the specified values
protected  DCModule getModule()
          Retrieves the module to which this panel belongs
 int getRowNumberWithID(java.lang.String ID)
          Returns the row number of the record with the given ID (product object ID; ie.
 java.lang.Object[] getValuesAtRow(int rowNumber, boolean hidden)
          Returns all the values at the give row
 void openRecord()
          Opens a record form for the selected record 1) Cancel all edits.
 void removeHiddenFields(int[] hiddenColumns)
          External use.
 void removeRows(int[] rows)
          Remove the rows from the table with the given indices
 void setRequiredFields(DCObject o)
          Creates a visual representation (different header) of the required fields
 void startAmazonUpdate()
          Starts the Amazon internet update.
 void startFieldSelector()
          Opens the fields selector dialog and applies the hidden fields on the table.
 void startIMDBUpdate()
          Starts the IMDB internet update.
 void updateRow(java.lang.String ID, java.lang.Object[] values)
          Updates the row with the given ID with the data (values)
 void updateRowAt(int rowNumber, java.lang.Object[] rowData, boolean overWrite, int[] fieldIndices)
          Updates a row at the given rownumber.
 
Methods inherited from class net.sf.dc.console.DataCrowPanel
setBackground, setStatus
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

tableModel

protected final DCTableModel tableModel

table

protected javax.swing.JTable table

panelTableActions

protected TablePanel.TableActionsPanel panelTableActions

popupMenu

protected TablePanel.PopupMenu popupMenu

cache

protected final java.util.Hashtable cache

tableChangeListener

protected final net.sf.dc.console.TablePanel.TableValueChangedAction tableChangeListener

tableMouseListener

protected final net.sf.dc.console.TablePanel.TableMouseListener tableMouseListener

vHiddenColumns

protected java.util.Vector vHiddenColumns

vColumns

protected java.util.Vector vColumns

moduleIndex

protected int moduleIndex
Constructor Detail

TablePanel

public TablePanel(int module)
Method Detail

cancelEdit

public void cancelEdit()
Tries to apply the current editing of the table cell. If the current value cannot be applied, the editing is simply cancelled (changes are discarded)


getModule

protected DCModule getModule()
Retrieves the module to which this panel belongs


startFieldSelector

public void startFieldSelector()
Opens the fields selector dialog and applies the hidden fields on the table. Also the hidden fields setting is set for the current module.


removeHiddenFields

public void removeHiddenFields(int[] hiddenColumns)
External use. All columns to be removed are still visible in the table. The columns are retrieved, stored in a Vector and then removed from the view

Parameters:
hiddenColumns - The model indices of the columns

fillTable

public void fillTable(java.util.LinkedList data)
Fills the table with the specified values

Parameters:
data - list containing the rows of data to be displayed

getRowNumberWithID

public int getRowNumberWithID(java.lang.String ID)
Returns the row number of the record with the given ID (product object ID; ie. the value of Software._ID)

Parameters:
ID -

updateRow

public void updateRow(java.lang.String ID,
                      java.lang.Object[] values)
Updates the row with the given ID with the data (values)

Parameters:
ID - the ID (Product Object ID)
values - the new values

getValuesAtRow

public java.lang.Object[] getValuesAtRow(int rowNumber,
                                         boolean hidden)
Returns all the values at the give row

Parameters:
rowNumber - the UI row number
hidden - indicates if values of hidden fields should also be returned

addRow

public void addRow(java.util.LinkedList data)
Adds the datacrow objects to the table


clearTable

public void clearTable()
Clear the table of all values


updateRowAt

public void updateRowAt(int rowNumber,
                        java.lang.Object[] rowData,
                        boolean overWrite,
                        int[] fieldIndices)
Updates a row at the given rownumber. If indicated this will update existing data.

Parameters:
rowNumber - UI row to be updated
rowData - the data to be written to the row
overWrite - indicates of existing data should be overwritten
fieldIndices - the field indices (communicates directly to the column indices)

startAmazonUpdate

public void startAmazonUpdate()
Starts the Amazon internet update. Th ejob is run in a seperate thread


startIMDBUpdate

public void startIMDBUpdate()
Starts the IMDB internet update. The job is run in a seperate thread


openRecord

public void openRecord()
Opens a record form for the selected record 1) Cancel all edits. When in the middle of updating a cell, the new value will be applied 2) Create a representation of the row. Values of hidden fields are also retrieved 3) Retrieve the olf values from the cache 4) Check for each value if it has been changed and if so, update it


removeRows

public void removeRows(int[] rows)
Remove the rows from the table with the given indices


setRequiredFields

public void setRequiredFields(DCObject o)
Creates a visual representation (different header) of the required fields

Parameters:
o - data crow object (used as a reference)

createPdfReport

public void createPdfReport()
Creates a PDF report. All visible fields are reported on. A file browser is opened in which the user can indicate where the pdf file should be stored.