com.limegroup.gnutella.gui.tables
Class LimeJTable

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTable
                  extended bycom.limegroup.gnutella.gui.tables.LimeJTable
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, JSortTable, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener

public final class LimeJTable
extends javax.swing.JTable
implements JSortTable

A specialized JTable for use with special Lime functions. 1) Allows the user to easily set a column as visible or invisible, rather than having to remove/add columns. It internally will remember where the column was and add/remove it as needed. 2) It remembers which column is sorted and whether the sort is ascending or descending. For use with adding arrows to the tableHeader. 3) Shows special tooltips for each row.

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
protected  java.util.Map _hiddenColumns
          The columns that are currently hidden.
protected  ColumnPreferenceHandler columnPreferences
          The preferences handler for the table columns.
protected  int pressedColumnIndex
          The index of the column that is currently pressed down.
protected  boolean sortedColumnAscending
          Whether or not the currently sorted column is sorted in ascending order.
protected  int sortedColumnIndex
          The index of the currently sorted column.
protected  TableSettings tableSettings
          The settings for this table.
 
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
LimeJTable()
          Same as JTable().
LimeJTable(DataLineModel dm)
          Same as JTable(DataLineModel)
 
Method Summary
 void createDefaultColumnsFromModel()
          Overrides JTable's default implementation in order to add LimeTableColumn columns.
 javax.swing.JToolTip createToolTip()
           
 java.awt.Color getBackgroundForRow(int row)
          Returns the color that a specific row will be.
 ColumnPreferenceHandler getColumnPreferenceHandler()
          Access the ColumnPreferenceHandler.
 java.util.Iterator getHiddenColumns()
          Returns an iterator of the removed columns.
 LimeTableColumn getLastRemovedColumn()
          Returns the last removed column.
 int getPressedColumnIndex()
          get the pressed header column
 int getSelectedRow()
          Override getSelectedRow to ensure that it exists in the table.
 int[] getSelectedRows()
          Overrided getSelectedRows to ensure that all selected rows exist in the table.
 int getSortedColumnIndex()
           
 TableSettings getTableSettings()
          Access the TableSettings.
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Sets the internal tooltip text for use with the next createToolTip.
 boolean isColumnVisible(java.lang.Object columnId)
          Determines whether or not a column is visible in this table.
 boolean isSortedColumnAscending()
          accessor function
 java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
          This overrides JTable.prepareRenderer so that we can stripe the rows as needed.
 void setColumnPreferenceHandler(ColumnPreferenceHandler handl)
          Set the ColumnPreferenceHandler
 void setColumnVisible(java.lang.Object columnId, boolean visible)
          Simple function that tucks away hidden columns for use later.
 void setPressedColumnIndex(int col)
          set the pressed header column.
 void setTableSettings(TableSettings settings)
          Set the TableSettings.
 void sortColumn(int index, boolean ascending)
          Tells the table that 'X' column is sorted.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, 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, getSelectedRowCount, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, 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, 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
 

Field Detail

_hiddenColumns

protected java.util.Map _hiddenColumns
The columns that are currently hidden.


sortedColumnIndex

protected int sortedColumnIndex
The index of the currently sorted column.


sortedColumnAscending

protected boolean sortedColumnAscending
Whether or not the currently sorted column is sorted in ascending order.


pressedColumnIndex

protected int pressedColumnIndex
The index of the column that is currently pressed down.


columnPreferences

protected ColumnPreferenceHandler columnPreferences
The preferences handler for the table columns.


tableSettings

protected TableSettings tableSettings
The settings for this table.

Constructor Detail

LimeJTable

public LimeJTable()
Same as JTable(). The table MUST have setModel called with a DataLineModel in order for this class to function properly.


LimeJTable

public LimeJTable(DataLineModel dm)
Same as JTable(DataLineModel)

Method Detail

getSelectedRow

public int getSelectedRow()
Override getSelectedRow to ensure that it exists in the table. This is necessary because of bug 4730055. See: http://developer.java.sun.com/developer/bugParade/bugs/4730055.html


getSelectedRows

public int[] getSelectedRows()
Overrided getSelectedRows to ensure that all selected rows exist in the table. This is necessary because of bug 4730055. See: http://developer.java.sun.com/developer/bugParade/bugs/4730055.html As a side effect, this implementation will return the rows in a sorted order. (Lowest first)


getColumnPreferenceHandler

public ColumnPreferenceHandler getColumnPreferenceHandler()
Access the ColumnPreferenceHandler.


setColumnPreferenceHandler

public void setColumnPreferenceHandler(ColumnPreferenceHandler handl)
Set the ColumnPreferenceHandler


getTableSettings

public TableSettings getTableSettings()
Access the TableSettings.


setTableSettings

public void setTableSettings(TableSettings settings)
Set the TableSettings.


setPressedColumnIndex

public void setPressedColumnIndex(int col)
set the pressed header column.

Parameters:
col - The MODEL index of the column

getPressedColumnIndex

public int getPressedColumnIndex()
get the pressed header column

Specified by:
getPressedColumnIndex in interface JSortTable
Returns:
the VIEW index of the pressed column.

getSortedColumnIndex

public int getSortedColumnIndex()
Specified by:
getSortedColumnIndex in interface JSortTable
Returns:
the VIEW index of the sorted column.

isSortedColumnAscending

public boolean isSortedColumnAscending()
accessor function

Specified by:
isSortedColumnAscending in interface JSortTable

sortColumn

public void sortColumn(int index,
                       boolean ascending)
Tells the table that 'X' column is sorted.

Parameters:
index - the MODEL index of the column
ascending - whether or not the sort is ascending

setColumnVisible

public void setColumnVisible(java.lang.Object columnId,
                             boolean visible)
                      throws LastColumnException
Simple function that tucks away hidden columns for use later. And it uses them later!

Throws:
LastColumnException

getHiddenColumns

public java.util.Iterator getHiddenColumns()
Returns an iterator of the removed columns.


getLastRemovedColumn

public LimeTableColumn getLastRemovedColumn()
Returns the last removed column.


isColumnVisible

public boolean isColumnVisible(java.lang.Object columnId)
Determines whether or not a column is visible in this table.


getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Sets the internal tooltip text for use with the next createToolTip.


createToolTip

public javax.swing.JToolTip createToolTip()
Returns:
The JToolTip returned is actually a JMultilineToolTip

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Overrides JTable's default implementation in order to add LimeTableColumn columns.


getBackgroundForRow

public java.awt.Color getBackgroundForRow(int row)
Returns the color that a specific row will be.


prepareRenderer

public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer,
                                          int row,
                                          int column)
This overrides JTable.prepareRenderer so that we can stripe the rows as needed.