|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.swing.Searchable com.jidesoft.grid.TableScrollPaneSearchable
public class TableScrollPaneSearchable
TableScrollPaneSearchable
is an concrete implementation of Searchable
that
enables the search function in TableScrollPane.
It's very simple to use it. Assuming you have a TableScrollPane,
all you need to do is to call
Now the TableScrollPane will have the search function.
TableScrollPane tableScrollPane = ....;
TableScrollPaneSearchable searchable = new TableScrollPaneSearchable(tableScrollPane);
TableScrollPane tableScrollPane = ....;
TableScrollPaneSearchable searchable = new TableScrollPaneSearchable(tableScrollPane) {
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 | |
---|---|
TableScrollPaneSearchable(TableScrollPane tableScrollPane)
|
Method Summary | |
---|---|
protected void |
addTableScrollPaneSelection(TableScrollPane tableScrollPane,
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 indices of the column to be searched. |
protected int |
getSelectedIndex()
Gets the selected index. |
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(TableScrollPane tableScrollPane)
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(TableScrollPane tableScrollPane)
Is the row selection allowed? |
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 indices of the column to be searched. |
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 TableScrollPaneSearchable(TableScrollPane tableScrollPane)
Method Detail |
---|
public void installListeners()
Searchable
installListeners
in class Searchable
public void uninstallListeners()
Searchable
uninstallListeners
in class Searchable
protected void setSelectedIndex(int index, boolean incremental)
Searchable
setSelectedIndex
in class Searchable
index
- 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 addTableScrollPaneSelection(TableScrollPane tableScrollPane, int rowIndex, int columnIndex, boolean incremental)
TableScrollPane.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.
tableScrollPane
- the TableScrollPanerowIndex
- 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(TableScrollPane tableScrollPane)
tableScrollPane
- the TableScrollPane.
protected boolean isRowSelectionAllowed(TableScrollPane tableScrollPane)
tableScrollPane
- the TableScrollPane.
protected int getSelectedIndex()
getSelectedIndex
in class Searchable
protected Object getElementAt(int index)
Searchable
getElementAt
in class Searchable
index
- the index
protected int getElementCount()
Searchable
getElementCount
in class Searchable
protected String convertElementToString(Object item)
Searchable
convertElementToString
in class Searchable
item
- the element to be converted
public int[] getSearchColumnIndices()
setSearchColumnIndices(int[])
public void setSearchColumnIndices(int[] columnIndices)
columnIndices
- the index of the columns to be searched. If empty, all columns will be searched.public int getMainIndex()
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 Searchable
e
- the key event
protected boolean isFindPreviousKey(KeyEvent e)
Searchable
isFindPreviousKey
in class Searchable
e
- the key event
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
protected boolean isActivateKey(KeyEvent e)
Searchable
isActivateKey
in class Searchable
e
- 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 |