Package adams.gui.core
Class SortableAndSearchableTable
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTable
-
- adams.gui.core.BaseTable
-
- adams.gui.core.SortableAndSearchableTable
-
- All Implemented Interfaces:
SpreadSheetSupporter
,SearchableTable
,SortableTable
,TableWithColumnFilters
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,CellEditorListener
,ListSelectionListener
,RowSorterListener
,TableColumnModelListener
,TableModelListener
,Scrollable
- Direct Known Subclasses:
InformativeStatisticFactory.Table
,InstancesTable
,InstanceTable
,ReportFactory.Table
,SpreadSheetTable
,XYSequenceTable
public class SortableAndSearchableTable extends BaseTable implements SortableTable, SearchableTable, TableWithColumnFilters
A specialized JTable that allows double-clicking on header for resizing to optimal width, as well as being searchable and sortable.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.gui.core.BaseTable
BaseTable.ColumnWidthApproach
-
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_COLWIDTH
the key for the column width.static String
KEY_SEARCHREGEXP
the key for the regular expression search flag.static String
KEY_SEARCHSTRING
the key for the search string.static String
KEY_SORTCASESENSITIVE
the key for case-sensitive.static String
KEY_SORTCOL
the key for the sort column setting.static String
KEY_SORTORDER
the key for the sort order.protected SortableAndSearchableWrapperTableModel
m_Model
the sortable/searchable model.protected boolean
m_SortNewTableModel
whether to automatically sort table models that get set via setModel.-
Fields inherited from class adams.gui.core.BaseTable
m_CellPopupMenuListeners, m_ColumnWidthApproach, m_FileChooser, m_HeaderPopupMenuListeners, m_MaxColumnOptimalColumnWidthCalc, m_MaxColumnOptimalHeaderWidthCalc, m_RemoveItemsListeners, m_ShowSimpleCellPopupMenu, m_ShowSimpleHeaderPopupMenu, m_SimpleCellPopupMenuListener, m_SimpleHeaderPopupMenuListener, m_TableHelper, m_TooManyColumnsDefaultWidth
-
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
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
accessibleContext, 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
Constructors Constructor Description SortableAndSearchableTable()
Constructs a defaultSortedBaseTable
that is initialized with a default data model, a default column model, and a default selection model.SortableAndSearchableTable(int numRows, int numColumns)
Constructs aSortedBaseTable
withnumRows
andnumColumns
of empty cells usingDefaultTableModel
.SortableAndSearchableTable(Object[][] rowData, Object[] columnNames)
Constructs aSortedBaseTable
to display the values in the two dimensional array,rowData
, with column names,columnNames
.SortableAndSearchableTable(Vector rowData, Vector columnNames)
Constructs aSortedBaseTable
to display the values in theVector
ofVectors
,rowData
, with column names,columnNames
.SortableAndSearchableTable(TableModel dm)
Constructs aSortedBaseTable
that is initialized withdm
as the data model, a default column model, and a default selection model.SortableAndSearchableTable(TableModel dm, TableColumnModel cm)
Constructs aSortedBaseTable
that is initialized withdm
as the data model,cm
as the column model, and a default selection model.SortableAndSearchableTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Constructs aSortedBaseTable
that is initialized withdm
as the data model,cm
as the column model, andsm
as the selection model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>
backupModelSettings(TableModel model)
Backs up the settings from the old model.protected void
finishInit()
Finishes the initialization.int
getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents.int
getActualRowCount()
Returns the actual row count in the model.String
getColumnFilter(int column)
Returns the filter for the column.int
getDisplayRow(int internalRow)
Returns the "visible" row derived from row in the actual table model.String
getSeachString()
Returns the current search string.int
getSortColumn()
Returns the sort column.boolean
getSortNewTableModel()
Returns whether to sort new models.protected Class
getTableModelClass()
Returns the class of the table model that the models need to be derived from.TableModel
getUnsortedModel()
returns the underlying model, can be null.protected void
initGUI()
Initializes some GUI-related things.protected boolean
initialSortCaseSensitive()
Returns whether the initial sort is case-sensitive.protected boolean
initialSortNewTableModel()
Returns the initial setting of whether to sort new models.boolean
isAnyColumnFiltered()
Returns whether there is at least one filter active.boolean
isAscending()
Returns whether sorting is ascending or not.boolean
isCaseSensitive()
Returns whether the sorting is case-sensitive.boolean
isColumnFiltered(int column)
Returns the whether there is a filter active for the column.boolean
isColumnFilterRegExp(int column)
Returns the whether the filter for the column is a regular expression.boolean
isRegExpSearch()
Returns whether the last search was a regular expression based one.boolean
isSorted()
returns whether the table was sorted.void
removeAllColumnFilters()
Removes all column filtersvoid
removeColumnFilter(int column)
Removes any filter for the column.protected void
restoreModelSettings(TableModel model, Hashtable<String,Object> settings)
Restores the settings previously backed up.void
search(String searchString, boolean regexp)
Performs a search for the given string.void
setCaseSensitive(boolean value)
Sets whether the sorting is case-sensitive.void
setColumnFilter(int column, String filter, boolean isRegExp)
Sets the filter for the column.void
setModel(TableModel model)
Sets the model to display - onlygetTableModelClass()
.void
setSortNewTableModel(boolean value)
Sets whether to sort new models.void
setUnsortedModel(TableModel value)
Sets the base model to use.void
setUnsortedModel(TableModel value, boolean restoreSorting)
Sets the base model to use.void
sort(int columnIndex)
sorts the table over the given column (ascending).void
sort(int columnIndex, boolean ascending)
sorts the table over the given column, either ascending or descending.-
Methods inherited from class adams.gui.core.BaseTable
adaptiveOptimalColumnWidth, addCellPopupMenuListener, addHeaderPopupMenuListener, addRemoveItemsListener, copyToClipboard, createSimpleCellPopupMenu, createSimpleHeaderPopupMenu, enterColumnWidth, getColumnWidthApproach, getColumnWidths, getFileChooser, getMaxColumnOptimalColumnWidthCalc, getMaxColumnOptimalHeaderWidthCalc, getSelectedRow, getSelectedRows, getShowSimpleCellPopupMenu, getShowSimpleHeaderPopupMenu, getTableHelper, getTooManyColumnsDefaultWidth, initialUseOptimalColumnWidths, invertRowSelection, invertSelection, modelToSpreadSheet, notifyCellPopupMenuListener, notifyHeaderPopupMenuListener, notifyRemoveItemsListeners, removeCellPopupMenuListener, removeHeaderPopupMenuListener, removeRemoveItemsListener, saveAs, scrollColumnToVisible, scrollRowToVisible, selectAll, selectionRowToModelRow, selectNone, setColumnWidth, setColumnWidth, setColumnWidthApproach, setColumnWidths, setColumnWidths, setColumnWidths, setMaxColumnOptimalColumnWidthCalc, setMaxColumnOptimalHeaderWidthCalc, setOptimalColumnWidth, setOptimalColumnWidth, setOptimalColumnWidthBounded, setOptimalColumnWidthBounded, setOptimalColumnWidths, setOptimalColumnWidthsBounded, setOptimalHeaderWidth, setOptimalHeaderWidth, setSelectedRow, setSelectedRows, setShowSimpleCellPopupMenu, setShowSimpleHeaderPopupMenu, setShowSimplePopupMenus, setTooManyColumnsDefaultWidth, showCell, showSimpleCellPopupMenu, showSimpleHeaderPopupMenu, toSpreadSheet, toSpreadSheet, toSpreadSheet
-
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRowCount, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, 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, getBaseline, getBaselineResizeBehavior, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
KEY_COLWIDTH
public static final String KEY_COLWIDTH
the key for the column width.- See Also:
- Constant Field Values
-
KEY_SORTCOL
public static final String KEY_SORTCOL
the key for the sort column setting.- See Also:
- Constant Field Values
-
KEY_SORTORDER
public static final String KEY_SORTORDER
the key for the sort order.- See Also:
- Constant Field Values
-
KEY_SORTCASESENSITIVE
public static final String KEY_SORTCASESENSITIVE
the key for case-sensitive.- See Also:
- Constant Field Values
-
KEY_SEARCHSTRING
public static final String KEY_SEARCHSTRING
the key for the search string.- See Also:
- Constant Field Values
-
KEY_SEARCHREGEXP
public static final String KEY_SEARCHREGEXP
the key for the regular expression search flag.- See Also:
- Constant Field Values
-
m_Model
protected SortableAndSearchableWrapperTableModel m_Model
the sortable/searchable model.
-
m_SortNewTableModel
protected boolean m_SortNewTableModel
whether to automatically sort table models that get set via setModel.
-
-
Constructor Detail
-
SortableAndSearchableTable
public SortableAndSearchableTable()
Constructs a defaultSortedBaseTable
that is initialized with a default data model, a default column model, and a default selection model.
-
SortableAndSearchableTable
public SortableAndSearchableTable(int numRows, int numColumns)
Constructs aSortedBaseTable
withnumRows
andnumColumns
of empty cells usingDefaultTableModel
. The columns will have names of the form "A", "B", "C", etc.- Parameters:
numRows
- the number of rows the table holdsnumColumns
- the number of columns the table holds
-
SortableAndSearchableTable
public SortableAndSearchableTable(Object[][] rowData, Object[] columnNames)
Constructs aSortedBaseTable
to display the values in the two dimensional array,rowData
, with column names,columnNames
.rowData
is an array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:rowData[1][5];
All rows must be of the same length as
columnNames
.- Parameters:
rowData
- the data for the new tablecolumnNames
- names of each column
-
SortableAndSearchableTable
public SortableAndSearchableTable(Vector rowData, Vector columnNames)
Constructs aSortedBaseTable
to display the values in theVector
ofVectors
,rowData
, with column names,columnNames
. TheVectors
contained inrowData
should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:((Vector)rowData.elementAt(1)).elementAt(5);
- Parameters:
rowData
- the data for the new tablecolumnNames
- names of each column
-
SortableAndSearchableTable
public SortableAndSearchableTable(TableModel dm)
Constructs aSortedBaseTable
that is initialized withdm
as the data model, a default column model, and a default selection model.- Parameters:
dm
- the data model for the table
-
SortableAndSearchableTable
public SortableAndSearchableTable(TableModel dm, TableColumnModel cm)
Constructs aSortedBaseTable
that is initialized withdm
as the data model,cm
as the column model, and a default selection model.- Parameters:
dm
- the data model for the tablecm
- the column model for the table
-
SortableAndSearchableTable
public SortableAndSearchableTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Constructs aSortedBaseTable
that is initialized withdm
as the data model,cm
as the column model, andsm
as the selection model. If any of the parameters arenull
this method will initialize the table with the corresponding default model. TheautoCreateColumnsFromModel
flag is set to false ifcm
is non-null, otherwise it is set to true and the column model is populated with suitableTableColumns
for the columns indm
.- Parameters:
dm
- the data model for the tablecm
- the column model for the tablesm
- the row selection model for the table
-
-
Method Detail
-
initialSortNewTableModel
protected boolean initialSortNewTableModel()
Returns the initial setting of whether to sort new models. Default implementation returns "false".- Returns:
- true if new models need to be sorted
-
initialSortCaseSensitive
protected boolean initialSortCaseSensitive()
Returns whether the initial sort is case-sensitive.- Returns:
- true if case-sensitive
-
setSortNewTableModel
public void setSortNewTableModel(boolean value)
Sets whether to sort new models.- Parameters:
value
- if true then new models get sorted
-
getSortNewTableModel
public boolean getSortNewTableModel()
Returns whether to sort new models. Default implementation is initialized with "false".- Returns:
- true if new models get sorted
-
initGUI
protected void initGUI()
Initializes some GUI-related things.
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInit
in classBaseTable
-
getTableModelClass
protected Class getTableModelClass()
Returns the class of the table model that the models need to be derived from. The default implementation just returns TableModel.class- Returns:
- the class the models must be derived from
-
backupModelSettings
protected Hashtable<String,Object> backupModelSettings(TableModel model)
Backs up the settings from the old model.- Parameters:
model
- the old model (the model stored within the SortedModel)- Returns:
- the backed up settings
-
restoreModelSettings
protected void restoreModelSettings(TableModel model, Hashtable<String,Object> settings)
Restores the settings previously backed up.- Parameters:
model
- the new model (the model stored within the SortedModel)settings
- the old settings, null if no settings were available
-
setModel
public void setModel(TableModel model)
Sets the model to display - onlygetTableModelClass()
.
-
setUnsortedModel
public void setUnsortedModel(TableModel value)
Sets the base model to use. Discards any sorting.- Specified by:
setUnsortedModel
in interfaceSortableTable
- Parameters:
value
- the base model
-
setUnsortedModel
public void setUnsortedModel(TableModel value, boolean restoreSorting)
Sets the base model to use.- Parameters:
value
- the base modelrestoreSorting
- whether to restore the sorting
-
getUnsortedModel
public TableModel getUnsortedModel()
returns the underlying model, can be null.- Specified by:
getUnsortedModel
in interfaceSortableTable
- Returns:
- the current model
-
getActualRow
public int getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents. Useful for retrieving "non-visual" data that is also stored in a TableModel.- Specified by:
getActualRow
in interfaceSearchableTable
- Parameters:
visibleRow
- the displayed row to retrieve the original row for- Returns:
- the original row
-
getDisplayRow
public int getDisplayRow(int internalRow)
Returns the "visible" row derived from row in the actual table model.- Parameters:
internalRow
- the row in the actual model- Returns:
- the row in the sorted model, -1 in case of an error
-
isSorted
public boolean isSorted()
returns whether the table was sorted.- Specified by:
isSorted
in interfaceSortableTable
- Returns:
- true if the table was sorted
-
getSortColumn
public int getSortColumn()
Returns the sort column.- Specified by:
getSortColumn
in interfaceSortableTable
- Returns:
- the sort column
-
isAscending
public boolean isAscending()
Returns whether sorting is ascending or not.- Specified by:
isAscending
in interfaceSortableTable
- Returns:
- true if ascending
- See Also:
isSorted()
,getSortColumn()
-
setCaseSensitive
public void setCaseSensitive(boolean value)
Sets whether the sorting is case-sensitive.- Parameters:
value
- true if case-sensitive
-
isCaseSensitive
public boolean isCaseSensitive()
Returns whether the sorting is case-sensitive.- Returns:
- true if case-sensitive
-
sort
public void sort(int columnIndex)
sorts the table over the given column (ascending).- Specified by:
sort
in interfaceSortableTable
- Parameters:
columnIndex
- the column to sort over
-
sort
public void sort(int columnIndex, boolean ascending)
sorts the table over the given column, either ascending or descending.- Specified by:
sort
in interfaceSortableTable
- Parameters:
columnIndex
- the column to sort overascending
- ascending if true, otherwise descending
-
getActualRowCount
public int getActualRowCount()
Returns the actual row count in the model.- Specified by:
getActualRowCount
in interfaceSearchableTable
- Returns:
- the row count in the underlying data
-
search
public void search(String searchString, boolean regexp)
Performs a search for the given string. Limits the display of rows to ones containing the search string.- Specified by:
search
in interfaceSearchableTable
- Parameters:
searchString
- the string to search forregexp
- whether to perform regular expression matching or just plain string comparison
-
getSeachString
public String getSeachString()
Returns the current search string.- Specified by:
getSeachString
in interfaceSearchableTable
- Returns:
- the search string, null if not filtered
-
isRegExpSearch
public boolean isRegExpSearch()
Returns whether the last search was a regular expression based one.- Specified by:
isRegExpSearch
in interfaceSearchableTable
- Returns:
- true if last search was a reg exp one
-
setColumnFilter
public void setColumnFilter(int column, String filter, boolean isRegExp)
Sets the filter for the column.- Specified by:
setColumnFilter
in interfaceTableWithColumnFilters
- Parameters:
column
- the column to filterfilter
- the filter stringisRegExp
- whether the filter is a regular expression
-
getColumnFilter
public String getColumnFilter(int column)
Returns the filter for the column.- Specified by:
getColumnFilter
in interfaceTableWithColumnFilters
- Parameters:
column
- the column to query- Returns:
- the filter, null if none present
-
isColumnFilterRegExp
public boolean isColumnFilterRegExp(int column)
Returns the whether the filter for the column is a regular expression.- Specified by:
isColumnFilterRegExp
in interfaceTableWithColumnFilters
- Parameters:
column
- the column to query- Returns:
- true if filter set and regular expression
-
isColumnFiltered
public boolean isColumnFiltered(int column)
Returns the whether there is a filter active for the column.- Specified by:
isColumnFiltered
in interfaceTableWithColumnFilters
- Parameters:
column
- the column to query- Returns:
- true if a filter is active
-
isAnyColumnFiltered
public boolean isAnyColumnFiltered()
Returns whether there is at least one filter active.- Specified by:
isAnyColumnFiltered
in interfaceTableWithColumnFilters
- Returns:
- true if at least one filter is active
-
removeColumnFilter
public void removeColumnFilter(int column)
Removes any filter for the column.- Specified by:
removeColumnFilter
in interfaceTableWithColumnFilters
- Parameters:
column
- the column to update
-
removeAllColumnFilters
public void removeAllColumnFilters()
Removes all column filters- Specified by:
removeAllColumnFilters
in interfaceTableWithColumnFilters
-
-