org.fife.ui.search
Class FindInFilesTable

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTable
                  extended byorg.fife.ui.search.FindInFilesTable
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, org.fife.ui.search.ResultsComponent, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener
Direct Known Subclasses:
ReplaceInFilesTable

public class FindInFilesTable
extends javax.swing.JTable
implements org.fife.ui.search.ResultsComponent

The table used to display search results in a FindInFilesDialog.

Version:
1.0
Author:
Robert Futrell
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
FindInFilesTable()
          Constructor.
 
Method Summary
 void addMatchData(MatchData matchData, java.lang.String dirName)
          Adds data on a match to the table.
 void applyComponentOrientation(java.awt.ComponentOrientation o)
          Overridden to ensure the table's header and cells are also rendered correctly (RTL, LTR).
 void clear()
          Clears all match results from the table.
protected  java.util.Vector createMatchDataVector(java.lang.String fileName, MatchData data)
          Return the vector of data to display in the table for a match data instance.
protected  javax.swing.table.DefaultTableModel createTableModel(java.util.ResourceBundle msg)
          Returns the table model to use.
 javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
          Returns the renderer to use for the given cell.
 MatchData getMatchDataForRow(int row)
          Returns the match data displayed in the specified row.
 java.awt.Dimension getPreferredScrollableViewportSize()
          Returns the preferred size of this table.
 int getRowCount()
          Returns the number of rows displayed in this component.
 boolean getScrollableTracksViewportHeight()
          Overridden to ensure the table completely fills the JViewport it is sitting in.
 boolean getScrollableTracksViewportWidth()
          Overridden in a "hack" to ensure that the table's contents are always at least as large as the enclosing JScrollPane's viewport.
 int getSelectedRow()
          Returns the row selected, or -1 if none.
protected  void initColumnWidths()
          Initializes the column widths.
 boolean isCellEditable(int row, int column)
          This method always returns false, as match data is immutable.
 void prettyUp()
          Allows the results component to update its appearance after having lots of data added to it.
 void updateUI()
          Overridden to also update the UI of custom renderers.
 
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, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, 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, 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, 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

FindInFilesTable

public FindInFilesTable()
Constructor.

Method Detail

addMatchData

public void addMatchData(MatchData matchData,
                         java.lang.String dirName)
Adds data on a match to the table.

Specified by:
addMatchData in interface org.fife.ui.search.ResultsComponent
Parameters:
matchData - The data.
dirName - The "root directory" searching was done in. This is used so all file paths displayed in the table are abbreviated to be relative to this directory.
See Also:
clear()

applyComponentOrientation

public void applyComponentOrientation(java.awt.ComponentOrientation o)
Overridden to ensure the table's header and cells are also rendered correctly (RTL, LTR). For some reason, Swing doesn't take care of this by default.

Parameters:
o - The new component orientation.

clear

public void clear()
Clears all match results from the table.

Specified by:
clear in interface org.fife.ui.search.ResultsComponent
See Also:
addMatchData(MatchData, String)

createMatchDataVector

protected java.util.Vector createMatchDataVector(java.lang.String fileName,
                                                 MatchData data)
Return the vector of data to display in the table for a match data instance.

Parameters:
fileName - The (relative) filename.
data - The match data.
Returns:
The vector.

createTableModel

protected javax.swing.table.DefaultTableModel createTableModel(java.util.ResourceBundle msg)
Returns the table model to use.

Parameters:
msg - The resource bundle.
Returns:
The table model.

getCellRenderer

public javax.swing.table.TableCellRenderer getCellRenderer(int row,
                                                           int column)
Returns the renderer to use for the given cell.

Parameters:
row - The row of the cell.
column - The column of the cell.
Returns:
The renderer.

getMatchDataForRow

public MatchData getMatchDataForRow(int row)
Returns the match data displayed in the specified row.

Specified by:
getMatchDataForRow in interface org.fife.ui.search.ResultsComponent
Parameters:
row - The row.
Returns:
The match data.

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Returns the preferred size of this table.

Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable
Returns:
The preferred size of this table.

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Overridden to ensure the table completely fills the JViewport it is sitting in. Note in Java 6 this could be taken care of by the method JTable#setFillsViewportHeight(boolean).

Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Overridden in a "hack" to ensure that the table's contents are always at least as large as the enclosing JScrollPane's viewport.

Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable

initColumnWidths

protected void initColumnWidths()
Initializes the column widths.


isCellEditable

public boolean isCellEditable(int row,
                              int column)
This method always returns false, as match data is immutable.

Parameters:
row - The row of the cell.
column - The column of the cell.
Returns:
false always.

prettyUp

public void prettyUp()
Allows the results component to update its appearance after having lots of data added to it.

Specified by:
prettyUp in interface org.fife.ui.search.ResultsComponent

updateUI

public void updateUI()
Overridden to also update the UI of custom renderers.


getRowCount

public int getRowCount()
Returns the number of rows displayed in this component.

Returns:
The number of rows displayed.

getSelectedRow

public int getSelectedRow()
Returns the row selected, or -1 if none.

Returns:
The row selected.