org.bibalex.daf.commongui.controls
Class ExternalIDsTable

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 org.bibalex.daf.commongui.controls.ExternalIDsTable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable

public class ExternalIDsTable
extends javax.swing.JTable

A custom table that extends JTable to display External IDs of a job.
The table consist of 3 columns: 'Type', 'Value' and 'Is Default'.
The table is either editable or not.

The table provides customs editors and rendereres for columns:
'Type' column has a JComboBox editor.
'Is Default' column has a JCheckBox renderer and editor.

Author:
Shehab.Kamal
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
private  ExternalID[] fillingInfo
          Holds the ExternalID[] that was used to fill this JTable.
private  int isDefaultColumn
           
private  boolean isEditable
          Determines whether the Table is editable or not.
private  int typeColumn
           
private  javax.swing.JComboBox typeCombo
          The JComboBox used to edit the type column.
private  java.lang.String UNKNOWN_TYPE
           
private  int valueColumn
           
 
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
ExternalIDsTable(boolean isEditable)
          Creates a new instance of ExternalIDsTable.
 
Method Summary
 void fill(ExternalID[] information)
          Fills in the table with the given FileLevelInfo[].
Note: All the values will be displayed even if they are not consistent, e.g.
 void fill(java.lang.String[] information)
          Fills in the table with the given String[].
 javax.swing.table.TableCellEditor getCellEditor(int row, int col)
          Gets the editor for the given cell.
 java.lang.Class<?> getColumnClass(int column)
          Gets the Class of the given column.
 ExternalID[] getData(Holder<java.lang.Boolean> rowsSkipped)
          Converts the valid rows of the table into an array of ExternalID.
private  boolean getDefault(javax.swing.table.DefaultTableModel model, int row)
          Gets the isDefault value.
private  int getIndex(javax.swing.JComboBox combo, java.lang.String value)
          Gets the index of the given value.
private  javax.swing.table.TableCellEditor getTypeCellEditor(java.lang.Object cellValue)
          Gets the CellEditor used to edit the Type column.
private  javax.swing.JComboBox getTypeComboBox()
          Gets a JComboBox that contains all the types of the external IDs.
private  int getTypeID(javax.swing.table.DefaultTableModel model, int row)
          Gets the ID of the given type.
private  java.lang.String getTypeName(int typeID)
          Gets the name of the given type.
private  java.lang.String getValue(javax.swing.table.DefaultTableModel model, int row)
          Gets the Comment value.
 boolean isCellEditable(int row, int column)
          Determine whether the cell at the specified row and column is editable or not.
private  boolean typeExists(java.lang.String type)
          Determines wheter the given type exists in the database or not.
 
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, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, 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, 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, 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, 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

typeColumn

private int typeColumn

valueColumn

private int valueColumn

isDefaultColumn

private int isDefaultColumn

UNKNOWN_TYPE

private final java.lang.String UNKNOWN_TYPE
See Also:
Constant Field Values

isEditable

private boolean isEditable
Determines whether the Table is editable or not.


typeCombo

private javax.swing.JComboBox typeCombo
The JComboBox used to edit the type column.


fillingInfo

private ExternalID[] fillingInfo
Holds the ExternalID[] that was used to fill this JTable.

Constructor Detail

ExternalIDsTable

public ExternalIDsTable(boolean isEditable)
                 throws java.lang.InstantiationException
Creates a new instance of ExternalIDsTable.

Parameters:
isEditable - Whether the table is editable or not.
Throws:
java.lang.InstantiationException - If the database couldn't be queried.
Method Detail

getTypeComboBox

private javax.swing.JComboBox getTypeComboBox()
                                       throws java.lang.InstantiationException
Gets a JComboBox that contains all the types of the external IDs.

Returns:
A JComboBox holding all the external ID types
Throws:
java.lang.InstantiationException - If the database couldn't be queried.

getColumnClass

public java.lang.Class<?> getColumnClass(int column)
Gets the Class of the given column.

Overrides:
getColumnClass in class javax.swing.JTable
Parameters:
column - The column to get its Class.
Returns:
The Class of the column.

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Determine whether the cell at the specified row and column is editable or not.

Overrides:
isCellEditable in class javax.swing.JTable
Parameters:
row - The row of the cell in question.
column - The column of the cell in question.
Returns:
True if the cell identified by the given row and column is eitable otherwise false.

getCellEditor

public javax.swing.table.TableCellEditor getCellEditor(int row,
                                                       int col)
Gets the editor for the given cell.

Overrides:
getCellEditor in class javax.swing.JTable
Parameters:
row - The row to get its editor.
col - The columns to get its editor.
Returns:
The editor of the cell.

getTypeCellEditor

private javax.swing.table.TableCellEditor getTypeCellEditor(java.lang.Object cellValue)
Gets the CellEditor used to edit the Type column.

Parameters:
cellValue - The current value of the cell.
Returns:
The CellEditor used to edit the Type column.

getIndex

private int getIndex(javax.swing.JComboBox combo,
                     java.lang.String value)
Gets the index of the given value.

Parameters:
combo - The JComboBox to search for the value in.
value - The value to search for.
Returns:
The index of the given value or -1.

fill

public void fill(java.lang.String[] information)
Fills in the table with the given String[].

Parameters:
information - An array holding the type and the ID on the form Type=ID.
The first entry is NOT assumed to be the default one.

typeExists

private boolean typeExists(java.lang.String type)
Determines wheter the given type exists in the database or not.

Parameters:
type - the type to search for.
Returns:
True if the type exists oterwise false.

fill

public void fill(ExternalID[] information)
Fills in the table with the given FileLevelInfo[].
Note: All the values will be displayed even if they are not consistent, e.g. Type ID doesn't correspond to an ExternalIDType.

Parameters:
information - An ExternalID[] to fill the table with.

getTypeName

private java.lang.String getTypeName(int typeID)
Gets the name of the given type.

Parameters:
typeID - The ID of the type.
Returns:
The name of the type.

getData

public ExternalID[] getData(Holder<java.lang.Boolean> rowsSkipped)
Converts the valid rows of the table into an array of ExternalID. A valid row is one that has all its values present and in a correct format.

Parameters:
rowsSkipped - Whether 1 or more rows have been skipped while converting the table to an Array.
Returns:
An ExternalID[] holding the valid rows of the table. If there is no valid rows an empty array is returned.

getValue

private java.lang.String getValue(javax.swing.table.DefaultTableModel model,
                                  int row)
Gets the Comment value.

Parameters:
model - The model to extract data from.
row - The row to retrieve its data.
Returns:
A String representing the value at model.getValueAt(row, 0).

getTypeID

private int getTypeID(javax.swing.table.DefaultTableModel model,
                      int row)
               throws java.security.InvalidParameterException
Gets the ID of the given type.

Parameters:
model - The model to extract data from.
row - The row to retrieve its data.
Returns:
The ID of the type.
Throws:
java.security.InvalidParameterException - If the given type name doesn't correspond to a phase.
java.lang.NumberFormatException - If the type ID couldn't be parsed.

getDefault

private boolean getDefault(javax.swing.table.DefaultTableModel model,
                           int row)
Gets the isDefault value.

Parameters:
model - The model to extract data from.
row - The row to retrieve its data.
Returns:
A boolean representing the value at model.getValueAt(row, 2).