public class SortableAndSearchableTable extends MekaTable implements SortableTable, SearchableTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintModeJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
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_SORTCOL
the key for the sort column setting.
|
static String |
KEY_SORTORDER
the key for the sort oder.
|
protected SortableAndSearchableWrapperTableModel |
m_Model
the sortable/searchable model.
|
protected boolean |
m_SortNewTableModel
whether to automatically sort table models that get set via setModel.
|
protected boolean |
m_UseOptimalColumnWidths
whether to automatically set optimal column widths.
|
m_TableHelperAUTO_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, tableHeaderlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
SortableAndSearchableTable()
Constructs a default
SortedBaseTable that is initialized with a default
data model, a default column model, and a default selection
model. |
SortableAndSearchableTable(int numRows,
int numColumns)
Constructs a
SortedBaseTable with numRows
and numColumns of empty cells using
DefaultTableModel. |
SortableAndSearchableTable(Object[][] rowData,
Object[] columnNames)
Constructs a
SortedBaseTable to display the values in the two dimensional array,
rowData, with column names, columnNames. |
SortableAndSearchableTable(TableModel dm)
Constructs a
SortedBaseTable that is initialized with
dm as the data model, a default column model,
and a default selection model. |
SortableAndSearchableTable(TableModel dm,
TableColumnModel cm)
Constructs a
SortedBaseTable that is initialized with
dm as the data model, cm
as the column model, and a default selection model. |
SortableAndSearchableTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
Constructs a
SortedBaseTable that is initialized with
dm as the data model, cm as the
column model, and sm as the selection model. |
SortableAndSearchableTable(Vector rowData,
Vector columnNames)
Constructs a
SortedBaseTable to display the values in the
Vector of Vectors, rowData,
with column names, columnNames. |
| Modifier and Type | Method and Description |
|---|---|
protected Hashtable<String,Object> |
backupModelSettings(TableModel model)
Backs up the settings from the old model.
|
int |
getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents.
|
int |
getActualRowCount()
Returns the actual row count in the model.
|
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.
|
boolean |
getUseOptimalColumnWidths()
Returns whether to automatically set optimal column widths.
|
protected void |
initGUI()
Initializes some GUI-related things.
|
protected boolean |
initialSortNewTableModel()
Returns the initial setting of whether to sort new models.
|
protected boolean |
initialUseOptimalColumnWidths()
Returns the initial setting of whether to set optimal column widths.
|
boolean |
isAscending()
Returns whether sorting is ascending or not.
|
boolean |
isRegExpSearch()
Returns whether the last search was a regular expression based one.
|
boolean |
isSorted()
returns whether the table was sorted.
|
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 |
setModel(TableModel model)
Sets the model to display - only
getTableModelClass(). |
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 |
setUseOptimalColumnWidhts(boolean value)
Sets whether to automatically set optimal column widths.
|
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.
|
copyToClipboard, getTableHelper, scrollColumnToVisible, scrollRowToVisible, setOptimalColumnWidth, setOptimalColumnWidth, showCelladdColumn, 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, getSelectedRow, getSelectedRowCount, getSelectedRows, 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, selectAll, 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, valueChangedaddAncestorListener, 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, updateadd, 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, validateTreeaction, 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, 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, transferFocusBackward, transferFocusUpCyclepublic static final String KEY_SORTCOL
public static final String KEY_SORTORDER
public static final String KEY_SEARCHSTRING
public static final String KEY_SEARCHREGEXP
protected SortableAndSearchableWrapperTableModel m_Model
protected boolean m_UseOptimalColumnWidths
protected boolean m_SortNewTableModel
public SortableAndSearchableTable()
SortedBaseTable that is initialized with a default
data model, a default column model, and a default selection
model.public SortableAndSearchableTable(int numRows,
int numColumns)
SortedBaseTable with numRows
and numColumns of empty cells using
DefaultTableModel. The columns will have
names of the form "A", "B", "C", etc.numRows - the number of rows the table holdsnumColumns - the number of columns the table holdspublic SortableAndSearchableTable(Object[][] rowData, Object[] columnNames)
SortedBaseTable 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.
rowData - the data for the new tablecolumnNames - names of each columnpublic SortableAndSearchableTable(Vector rowData, Vector columnNames)
SortedBaseTable to display the values in the
Vector of Vectors, rowData,
with column names, columnNames. The
Vectors contained in rowData
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);
rowData - the data for the new tablecolumnNames - names of each columnpublic SortableAndSearchableTable(TableModel dm)
SortedBaseTable that is initialized with
dm as the data model, a default column model,
and a default selection model.dm - the data model for the tablepublic SortableAndSearchableTable(TableModel dm, TableColumnModel cm)
SortedBaseTable that is initialized with
dm as the data model, cm
as the column model, and a default selection model.dm - the data model for the tablecm - the column model for the tablepublic SortableAndSearchableTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
SortedBaseTable that is initialized with
dm as the data model, cm as the
column model, and sm as the selection model.
If any of the parameters are null this method
will initialize the table with the corresponding default model.
The autoCreateColumnsFromModel flag is set to false
if cm is non-null, otherwise it is set to true
and the column model is populated with suitable
TableColumns for the columns in dm.dm - the data model for the tablecm - the column model for the tablesm - the row selection model for the tableprotected boolean initialUseOptimalColumnWidths()
public void setUseOptimalColumnWidhts(boolean value)
value - if true then optimal column widths are usedpublic boolean getUseOptimalColumnWidths()
protected boolean initialSortNewTableModel()
public void setSortNewTableModel(boolean value)
value - if true then new models get sortedpublic boolean getSortNewTableModel()
protected void initGUI()
protected Class getTableModelClass()
protected Hashtable<String,Object> backupModelSettings(TableModel model)
model - the old model (the model stored within the SortedModel)protected void restoreModelSettings(TableModel model, Hashtable<String,Object> settings)
model - the new model (the model stored within the SortedModel)settings - the old settings, null if no settings were availablepublic void setModel(TableModel model)
getTableModelClass().public void setUnsortedModel(TableModel value)
setUnsortedModel in interface SortableTablevalue - the base modelpublic void setUnsortedModel(TableModel value, boolean restoreSorting)
value - the base modelrestoreSorting - whether to restore the sortingpublic TableModel getUnsortedModel()
getUnsortedModel in interface SortableTablepublic int getActualRow(int visibleRow)
getActualRow in interface SearchableTablevisibleRow - the displayed row to retrieve the original row forpublic int getDisplayRow(int internalRow)
internalRow - the row in the actual modelpublic boolean isSorted()
isSorted in interface SortableTablepublic int getSortColumn()
getSortColumn in interface SortableTablepublic boolean isAscending()
isAscending in interface SortableTableisSorted(),
getSortColumn()public void sort(int columnIndex)
sort in interface SortableTablecolumnIndex - the column to sort overpublic void sort(int columnIndex,
boolean ascending)
sort in interface SortableTablecolumnIndex - the column to sort overascending - ascending if true, otherwise descendingpublic int getActualRowCount()
getActualRowCount in interface SearchableTablepublic void search(String searchString, boolean regexp)
search in interface SearchableTablesearchString - the string to search forregexp - whether to perform regular expression matching
or just plain string comparisonpublic String getSeachString()
getSeachString in interface SearchableTablepublic boolean isRegExpSearch()
isRegExpSearch in interface SearchableTableCopyright © 2017. All Rights Reserved.