JIDE 3.5.15

com.jidesoft.combobox
Class TableComboBoxSearchable

java.lang.Object
  extended by com.jidesoft.swing.Searchable
      extended by com.jidesoft.combobox.AbstractComboBoxSearchable
          extended by com.jidesoft.combobox.TableComboBoxSearchable
All Implemented Interfaces:
PropertyChangeListener, EventListener, ListDataListener, PopupMenuListener

public class TableComboBoxSearchable
extends AbstractComboBoxSearchable

TableComboBoxSearchable is an concrete implementation of Searchable that enables the search function in TableComboBox.

It's very simple to use it. Assuming you have a TableComboBox, all you need to do is to call

 TableComboBox tableComboBox = ....;
 TableComboBoxSearchable searchable = new TableComboBoxSearchable(tableComboBox);
 
Now the TableComboBox will have the search function.

The TableComboBoxSearchable will use the TableComboBox Converter to convert the elements to strings to search for.

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
TableComboBoxSearchable(TableComboBox tableComboBox)
           
 
Method Summary
protected  void addTableSelection(JTable table, int rowIndex, int columnIndex, boolean incremental)
          Selects the cell at the specified row and column index.
protected  Object getElementAt(int row)
          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 in the component.
protected  boolean isColumnSelectionAllowed(JTable table)
          Is the column selection allowed?
protected  boolean isRowSelectionAllowed(JTable table)
          Is the row selection allowed?
 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.
 
Methods inherited from class com.jidesoft.combobox.AbstractComboBoxSearchable
contentsChanged, convertElementToString, getComboBox, intervalAdded, intervalRemoved, isShowPopupDuringSearching, popupMenuCanceled, popupMenuWillBecomeInvisible, popupMenuWillBecomeVisible, propertyChange, setShowPopupDuringSearching, uninstallListeners
 
Methods inherited from class com.jidesoft.swing.Searchable
addPropertyChangeListener, addSearchableListener, adjustSelectedIndex, cancelHighlightAll, compare, compare, convertToString, createComponentListener, createFocusListener, createKeyListener, createSearchPopup, findAll, findFirst, findFromCursor, findLast, findNext, findPrevious, firePropertyChangeEvent, fireSearchableEvent, getBackground, getComponent, getCurrentIndex, getCursor, getElementAtAsString, getForeground, getMismatchForeground, getPopupLocation, getPopupLocationRelativeTo, getPopupTimeout, getResourceString, getSearchable, getSearchableListeners, getSearchableProvider, getSearchingDelay, getSearchingText, getSearchLabel, getWildcardSupport, hidePopup, highlightAll, installListeners, isActivateKey, isCaseSensitive, isCountMatch, isDeactivateKey, isFindFirstKey, isFindLastKey, isFindNextKey, isFindPreviousKey, isFromStart, isHeavyweightComponentEnabled, isHideSearchPopupOnEvent, isIncrementalSelectKey, isNavigationKey, isPopupVisible, isProcessModelChangeEvent, isRepeats, isReverseOrder, isSearchableListenerInstalled, isSelectAllKey, isWildcardEnabled, keyTypedOrPressed, removePropertyChangeListener, removeSearchableListener, reverseFindFromCursor, searchingTextEmpty, select, setBackground, setCaseSensitive, setCountMatch, setCursor, setCursor, setForeground, setFromStart, setHeavyweightComponentEnabled, setHideSearchPopupOnEvent, setMismatchForeground, setPopupLocation, setPopupLocationRelativeTo, setPopupTimeout, setProcessModelChangeEvent, setRepeats, setReverseOrder, setSearchableProvider, setSearchingDelay, setSearchLabel, setWildcardEnabled, setWildcardSupport, showPopup, textChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableComboBoxSearchable

public TableComboBoxSearchable(TableComboBox tableComboBox)
Method Detail

setSelectedIndex

protected void setSelectedIndex(int index,
                                boolean incremental)
Description copied from class: Searchable
Sets the selected index. The concrete implementation should call methods on the component to select the element at the specified index. The incremental flag is used to do multiple select. 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.

Specified by:
setSelectedIndex in class Searchable
Parameters:
index - the index to be selected
incremental - 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.

getElementAt

protected Object getElementAt(int row)
Description copied from class: Searchable
Gets the element at the specified index. The element could be any data structure that internally used in the component. The convertElementToString method will give you a chance to convert the element to string which is used to compare with the string that user types in.

Specified by:
getElementAt in class Searchable
Parameters:
row - the index
Returns:
the element at the specified index.

getElementCount

protected int getElementCount()
Description copied from class: Searchable
Gets the total element count in the component. Different concrete implementation could have different interpretation of the count. This is totally OK as long as it's consistent in all the methods. For example, the index parameter in other methods should be always a valid value within the total count.

Specified by:
getElementCount in class Searchable
Returns:
the total element count.

getSelectedIndex

protected int getSelectedIndex()
Description copied from class: Searchable
Gets the selected index in the component. The concrete implementation should call methods on the component to retrieve the current selected index. If the component supports multiple selection, it's OK just return the index of the first selection.

Here are some examples. In the case of JList, the index is the row index. In the case of JTree, the index is the row index too. In the case of JTable, depending on the selection mode, the index could be row index (in row selection mode), could be column index (in column selection mode) or could the cell index (in cell selection mode).

Specified by:
getSelectedIndex in class Searchable
Returns:
the selected index.

addTableSelection

protected void addTableSelection(JTable table,
                                 int rowIndex,
                                 int columnIndex,
                                 boolean incremental)
Selects the cell at the specified row and column index. If incremental is true, the previous selection will not be cleared. This method will use 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.

Parameters:
table - the table
rowIndex - the row index of the cell.
columnIndex - the column index of the cell
incremental - false to clear all previous selection. True to keep the previous selection.

isColumnSelectionAllowed

protected boolean isColumnSelectionAllowed(JTable table)
Is the column selection allowed?

Parameters:
table - the table.
Returns:
true if the table is the column selection.

isRowSelectionAllowed

protected boolean isRowSelectionAllowed(JTable table)
Is the row selection allowed?

Parameters:
table - the table.
Returns:
true if the table is the row selection.

getSearchColumnIndices

public int[] getSearchColumnIndices()
Gets the indexes of the column to be searched.

Returns:
the indexes of the column to be searched.

getMainIndex

public int getMainIndex()
Gets the index of the column to be searched.

Returns:
the index of the column to be searched.

setSearchColumnIndices

public void setSearchColumnIndices(int[] columnIndices)
Sets the main indexes. Main indexes are the columns index which you want to be searched.

Parameters:
columnIndices - the index of the columns to be searched. If empty, all columns will be searched. If null, TableComboBox#getValueColumnIndex() will be searched.

setMainIndex

public void setMainIndex(int mainIndex)
Sets the main index. Main index is the column index which you want to be searched.

Parameters:
mainIndex - the index of the column to be searched. If -1, all columns will be searched.

JIDE 3.5.15