|
JIDE 3.5.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.jidesoft.swing.Searchable
com.jidesoft.swing.TableSearchable
public class TableSearchable
TableSearchable is an concrete implementation of Searchable that enables the search function in
JTable.
It's very simple to use it. Assuming you have a JTable, all you need to do is to call
Now the JTable will have the search function.
JTable table = ....;
TableSearchable searchable = new TableSearchable(table);
JTable table = ....;
TableSearchable searchable = new TableSearchable(table) {
protected String convertElementToString(Object object) {
...
}
};
Additional customization can be done on the base Searchable class such as background and foreground color,
keystrokes, case sensitivity,
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.jidesoft.swing.Searchable |
|---|
Searchable.SearchField, Searchable.SearchPopup |
| Field Summary |
|---|
| Fields inherited from class com.jidesoft.swing.Searchable |
|---|
_component, _componentListener, _focusListener, _keyListener, _matchCount, CLIENT_PROPERTY_SEARCHABLE, listenerList, PROPERTY_SEARCH_TEXT |
| Constructor Summary | |
|---|---|
TableSearchable(JTable table)
|
|
| Method Summary | |
|---|---|
protected void |
addTableSelection(JTable table,
int rowIndex,
int columnIndex,
boolean incremental)
Selects the cell at the specified row and column index. |
protected String |
convertElementToString(Object item)
Converts the element that returns from getElementAt() to string. |
protected Object |
getElementAt(int index)
Gets the element at the specified index. |
protected int |
getElementCount()
Gets the total element count in the component. |
int |
getMainIndex()
Gets the index of the column to be searched. |
int[] |
getSearchColumnIndices()
Gets the indexes of the column to be searched. |
protected int |
getSelectedIndex()
Gets the selected index. |
protected Object |
getValueAt(JTable table,
int rowIndex,
int columnIndex)
Get string value of the table. |
void |
installListeners()
Installs necessary listeners to the component. |
protected boolean |
isActivateKey(KeyEvent e)
Checks if the key in KeyEvent should activate the search popup. |
protected boolean |
isColumnSelectionAllowed(JTable table)
Is the column selection allowed? |
protected boolean |
isFindNextKey(KeyEvent e)
Checks if the key is used as a key to find the next occurrence. |
protected boolean |
isFindPreviousKey(KeyEvent e)
Checks if the key is used as a key to find the previous occurrence. |
protected boolean |
isRowSelectionAllowed(JTable table)
Is the row selection allowed? |
protected boolean |
isSearchSelectedRows()
Are we trying to search on multi-columns (but NOT all columns)? |
protected boolean |
isSelectedCellEditable()
Checks if the selected cell is editable. |
void |
propertyChange(PropertyChangeEvent evt)
|
void |
setMainIndex(int mainIndex)
Sets the main index. |
void |
setSearchColumnIndices(int[] columnIndices)
Sets the main indexes. |
protected void |
setSelectedIndex(int index,
boolean incremental)
Sets the selected index. |
void |
tableChanged(TableModelEvent e)
|
void |
uninstallListeners()
Uninstall the listeners that installed before. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TableSearchable(JTable table)
| Method Detail |
|---|
public void installListeners()
Searchable
installListeners in class Searchablepublic void uninstallListeners()
Searchable
uninstallListeners in class Searchable
protected void setSelectedIndex(int index,
boolean incremental)
Searchable
setSelectedIndex in class Searchableindex - the index to be selectedincremental - a flag to enable multiple selection. If the flag is true, the element at the index should be
added to current selection. If false, you should clear previous selection and then select the
element.
protected void addTableSelection(JTable table,
int rowIndex,
int columnIndex,
boolean incremental)
JTable.changeSelection(int,int,boolean,boolean) method to select the
cell if the row and column index is in the range and the cell was not selected. The last two parameters of
changeSelection is true and false respectively.
table - the tablerowIndex - the row index of the cell.columnIndex - the column index of the cellincremental - false to clear all previous selection. True to keep the previous selection.protected boolean isColumnSelectionAllowed(JTable table)
table - the table.
protected boolean isRowSelectionAllowed(JTable table)
table - the table.
protected boolean isSearchSelectedRows()
protected int getSelectedIndex()
getSelectedIndex in class Searchableprotected Object getElementAt(int index)
Searchable
getElementAt in class Searchableindex - the index
protected Object getValueAt(JTable table,
int rowIndex,
int columnIndex)
table - the JTablerowIndex - the row indexcolumnIndex - the column index
protected int getElementCount()
Searchable
getElementCount in class Searchableprotected String convertElementToString(Object item)
Searchable
convertElementToString in class Searchableitem - the element to be converted
public int[] getSearchColumnIndices()
public int getMainIndex()
public void setSearchColumnIndices(int[] columnIndices)
columnIndices - the index of the columns to be searched. If empty, all columns will be searched.public void setMainIndex(int mainIndex)
mainIndex - the index of the column to be searched. If -1, all columns will be searched.protected boolean isFindNextKey(KeyEvent e)
Searchable
isFindNextKey in class Searchablee - the key event
protected boolean isFindPreviousKey(KeyEvent e)
Searchable
isFindPreviousKey in class Searchablee - the key event
public void tableChanged(TableModelEvent e)
tableChanged in interface TableModelListenerpublic void propertyChange(PropertyChangeEvent evt)
propertyChange in interface PropertyChangeListenerprotected boolean isActivateKey(KeyEvent e)
Searchable
isActivateKey in class Searchablee - the key event
protected boolean isSelectedCellEditable()
|
JIDE 3.5.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||