How to Implement a text field for Filtering the elements in the Combo-viewer

Is it possible to add a text field to JFace combo-viewer so that the elements can be filtered out by keyboard input like org.eclipse.ui.dialogs.FilteredTree?


You can’t really add anything to the ComboViewer but you can do this using a separate Text field.

Add a ViewerFilter to the ComboViewer using the addFilter method. This filter should use the current value of the Text field to filter the combo contents.

Add a ModifyListener to the Text field which will be notified each time the text is changed. In the listener you can refresh the combo viewer so that the viewer filter is run again.

Leave a Reply

Your email address will not be published. Required fields are marked *