Search code examples
javaswtnattable

Remove items from NatCombo


I am developing an eclipse plugin where I have a NatCombo (dropdown box) inside the NatTable. I need to dynamically change the combo box filter dropdown menu. I can set Items to my combo box using natCombo.setItems() method (where I can add my filtered list of filters).

However I could not find a method that removes items instead, or that empties the previous items in the combo box before I add new items. I can only add indefinitely Items to my combo box drop drown menu.

Is there a method to remove items? Can I implement one? If so how exactly could I?


Solution

  • I don't know your use case and whether you are using one of our default editor implementations or created your own. But there are basically two answers, dependent on your use case:

    1. You want to provide dynamic content to a combobox - this is done via IComboBoxDataProvider and explained in our FAQ https://www.eclipse.org/nattable/documentation.php?page=faq
    2. You want to filter the content of an opened combobox - this is not supported in versions <= 1.3.0 but will be added with NatTable 1.4.0 which is on its way while writing this answer. The snapshot is already available if you want to give it a try.