net.sf.dc.console.components
Class DCTable

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTable
                  extended bynet.sf.dc.console.components.DCTable
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener

public class DCTable
extends javax.swing.JTable

Table implementation with caching of changed values. Can either be initialized as a simple table or a table for module (with all the correct components and headers)

Since:
1.4
Version:
1.50
Author:
Robert-Jan van der Waals
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable
 
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
 
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
DCTable()
          Initializes a very simple table
DCTable(DCModule module, boolean readonly)
          Initializes a table for a specific module
 
Method Summary
 void addRow(java.util.LinkedList data, boolean addUIRowID)
          Adds the datacrow objects to the table
 void addRow(java.lang.Object[] data)
          Adds a row to the table
 void addRowToCache(int row, int column)
          Add a changed row to the cache.
 void applyHeaders()
          (Re-) applies all headers
 void cancelEdit()
          Tries to apply the current editing of the table cell.
 void clearCache()
          Clears the cached objects
 void clearTable()
          Clear the table of all values.
 void fillTable(java.util.LinkedList data)
          Fills the table with the specified values
 DCObject getChangedObject(int index)
          Retrieve a changed object (to get the row indices, use getChangedObjectIndices)
 DCObject[] getChangedObjects()
          Retrieve all changed objects.
 int[] getChangedObjectsIndices()
          Retrieves the rownumbers of all changed objects
 DCObject getObjectForRow(int row, boolean hidden)
          Returns all the values at the give row
 DCObject getObjectFromCache(java.lang.String sID)
          Returns the object with the given ID from the cache
 DCObject[] getObjects()
          Returns all Data Crow Objects currently persisting in the (UI) table
 int getRowNumberWithID(java.lang.String ID)
          Returns the row number of the record with the given ID (product object ID; ie.
 java.lang.Object getValueAt(int row, int col, boolean hidden)
          Gets a value from the model (hidden or visible) or the table (always visible)
 boolean isReadOnly()
          Indicates if the table data can be edited
 boolean noChanges()
          Indicates if changes have been made to the data of the table
 void openFieldSelector()
          Opens the fields selector dialog and applies the hidden fields on the table.
 void openUpdateAllDialog()
          Opens the Update All dialog
 void removeFromCache(java.lang.String sID)
          Removes the object with the given ID from the cache (unmark as changed)
 void removeHiddenFields(int[] hiddenColumns)
          All columns to be removed are still visible in the table.
 void removeRow()
          Removes the selected or the last row from the UI table
 void removeRow(int row)
          Removes a row from the UI table
 void removeRows(int[] rows)
          Remove the rows from the table with the given indices
 void setColumnCount(int count)
          Sets the amount of columns to be displayed
 void setRequiredFields()
          Creates a visual representation (different header) of the required fields
 void setRowCount(int count)
          Sets the amount of rows to be displayed
 void setSelectedRow(int row)
           
 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)
          Updates a row at the given rownumber.
 
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, 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, 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, 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, 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, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, 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, 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
 

Constructor Detail

DCTable

public DCTable()
Initializes a very simple table


DCTable

public DCTable(DCModule module,
               boolean readonly)
Initializes a table for a specific module

Parameters:
module - the mocule for which this table is created
readonly - allow / block changes
Method Detail

isReadOnly

public boolean isReadOnly()
Indicates if the table data can be edited


noChanges

public boolean noChanges()
Indicates if changes have been made to the data of the table


applyHeaders

public void applyHeaders()
(Re-) applies all headers


removeHiddenFields

public void removeHiddenFields(int[] hiddenColumns)
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

clearCache

public void clearCache()
Clears the cached objects


removeFromCache

public void removeFromCache(java.lang.String sID)
Removes the object with the given ID from the cache (unmark as changed)

Parameters:
sID - object ID

getObjects

public DCObject[] getObjects()
Returns all Data Crow Objects currently persisting in the (UI) table


getObjectFromCache

public DCObject getObjectFromCache(java.lang.String sID)
Returns the object with the given ID from the cache

Parameters:
sID - Unique object ID

getObjectForRow

public DCObject getObjectForRow(int row,
                                boolean hidden)
Returns all the values at the give row

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

getChangedObjects

public DCObject[] getChangedObjects()
Retrieve all changed objects. Use with care, this could be heavy on the system when many rows have been changed. Consider using the method getChangedObjectsIndices


getChangedObjectsIndices

public int[] getChangedObjectsIndices()
Retrieves the rownumbers of all changed objects


getChangedObject

public DCObject getChangedObject(int index)
Retrieve a changed object (to get the row indices, use getChangedObjectIndices)

Parameters:
index - row index

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col,
                                   boolean hidden)
Gets a value from the model (hidden or visible) or the table (always visible)

Parameters:
row - row index
col - column index
hidden - get the value from the model or table

clearTable

public void clearTable()
Clear the table of all values. Clear the cache as well.


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 -

setColumnCount

public void setColumnCount(int count)
Sets the amount of columns to be displayed

Parameters:
count - columns amount

removeRows

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


removeRow

public void removeRow()
Removes the selected or the last row from the UI table


removeRow

public void removeRow(int row)
Removes a row from the UI table

Parameters:
row - row index

setRowCount

public void setRowCount(int count)
Sets the amount of rows to be displayed

Parameters:
count - rows amount

addRow

public void addRow(java.lang.Object[] data)
Adds a row to the table

Parameters:
data - values to be added

setSelectedRow

public void setSelectedRow(int row)

addRow

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

Parameters:
data - datacrow objects
addUIRowID - indicates whether a row ID should be displayed

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

updateRowAt

public void updateRowAt(int rowNumber,
                        java.lang.Object[] rowData,
                        boolean overWrite)
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

addRowToCache

public void addRowToCache(int row,
                          int column)
Add a changed row to the cache. Can also be used to force save records (add a unchanged row to the cache)

Parameters:
row - changed row number
column - changed column number

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

setRequiredFields

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


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)


openFieldSelector

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


openUpdateAllDialog

public void openUpdateAllDialog()
Opens the Update All dialog