net.sf.dc.console.components.tables
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.tables.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.9
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(boolean readonly, boolean caching)
          Initializes a very simple table
DcTable(DCModule module, boolean readonly, boolean caching)
          Initializes a table for a specific module
 
Method Summary
 void addObject(DcObject dco)
           
 void addObject(DcObject dco, boolean setSelected)
           
 void addObjects(java.util.Collection objects)
           
 void addRow(java.lang.Object[] row)
           
 void addRowToCache(int row, int column)
          Add a changed row to the cache.
 void applyDefinitions()
           
 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.Collection objects)
          Fills the table with the specified values
 DcObject[] getChangedObjects()
          Retrieve all changed objects.
 int[] getChangedObjectsIndices()
          Retrieves the rownumbers of all changed objects
 int getColumnIndexForField(int field)
           
 DcObject getDCObject(int row)
           
 DcObject[] getDCObjects()
          Returns all Data Crow Objects currently persisting in the (UI) table
 DCModule getModuleForRow(int row)
           
 java.lang.String getObjectID(int row)
           
 int getRowNumberWithID(java.lang.String ID)
          Returns the row number of the item 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)
 void ignoreEdit(boolean b)
          Ignores the current edit action of a cell
 boolean isReadOnly()
          Indicates if the table data can be edited
 void moveRowDown()
           
 void moveRowUp()
           
 boolean noChanges()
          Indicates if changes have been made to the data of the table
 void openUpdateAllDialog()
          Opens the Update All dialog
 void removeFields(int[] fields)
          All columns to be removed are still visible in the table.
 void removeFromCache(java.lang.String sID)
          Removes the object with the given ID from the cache (unmark as changed)
 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 resetTable()
          Adds all the columns to the table (hidden and visible fields)
 void setColumnCount(int count)
          Sets the amount of columns to be displayed
 void setRowCount(int count)
          Sets the amount of rows to be displayed
 void setSelectedRow(int row)
          Tries to programmatically set the selected row in the table.
 void updateRow(java.lang.String ID, DcObject dco)
          Updates the row with the given ID with the data (values)
 void updateRowAt(int row, DcObject dco, boolean overwrite, boolean allowDeletes, boolean mark)
          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(boolean readonly,
               boolean caching)
Initializes a very simple table


DcTable

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

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

getColumnIndexForField

public int getColumnIndexForField(int field)

addObject

public void addObject(DcObject dco)

addObject

public void addObject(DcObject dco,
                      boolean setSelected)

addObjects

public void addObjects(java.util.Collection objects)

updateRow

public void updateRow(java.lang.String ID,
                      DcObject dco)
Updates the row with the given ID with the data (values)

Parameters:
ID - the ID (Product Object ID)

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


ignoreEdit

public void ignoreEdit(boolean b)
Ignores the current edit action of a cell

Parameters:
b -

applyHeaders

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


moveRowDown

public void moveRowDown()

moveRowUp

public void moveRowUp()

removeFields

public void removeFields(int[] fields)
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


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

getDCObjects

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


getDCObject

public DcObject getDCObject(int row)

getModuleForRow

public DCModule getModuleForRow(int row)

getObjectID

public java.lang.String getObjectID(int row)

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


getValueAt

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


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 item 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(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

setSelectedRow

public void setSelectedRow(int row)
Tries to programmatically set the selected row in the table.

Parameters:
row - index

updateRowAt

public void updateRowAt(int row,
                        DcObject dco,
                        boolean overwrite,
                        boolean allowDeletes,
                        boolean mark)
Updates a row at the given rownumber. If indicated this will update existing data.


addRow

public void addRow(java.lang.Object[] row)

addRowToCache

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

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

fillTable

public void fillTable(java.util.Collection objects)
Fills the table with the specified values


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)


openUpdateAllDialog

public void openUpdateAllDialog()
Opens the Update All dialog


applyDefinitions

public void applyDefinitions()

resetTable

public void resetTable()
Adds all the columns to the table (hidden and visible fields)