Class GlazedListsFilterRowComboBoxDataProvider<T>

java.lang.Object
org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterRowComboBoxDataProvider<T>
org.eclipse.nebula.widgets.nattable.extension.glazedlists.filterrow.GlazedListsFilterRowComboBoxDataProvider<T>
All Implemented Interfaces:
ca.odell.glazedlists.event.ListEventListener<T>, EventListener, ILayerCommandHandler<UpdateDataCommand>, IComboBoxDataProvider, ILayerListener

public class GlazedListsFilterRowComboBoxDataProvider<T> extends FilterRowComboBoxDataProvider<T> implements ca.odell.glazedlists.event.ListEventListener<T>
Special implementation of FilterRowComboBoxDataProvider that performs FilterRowComboUpdateEvents if the underlying list is changed.

This implementation is necessary for a special case. If a filter is applied and a new row is added to the data model, the FilterList won't show the new row because the current applied filter is not aware of the new values. This is because of the inverse filter logic in then Excel like filter row. As the FilterList doesn't show the new value, there is no ListEvent fired further, so the FilterRowComboBoxDataProvider is not informed about the structural change.

This implementation solves this issue by listening to the wrapped source EventList of the FilterList instead of the NatTable IStructuralChangeEvent.

  • Constructor Details

    • GlazedListsFilterRowComboBoxDataProvider

      public GlazedListsFilterRowComboBoxDataProvider(ILayer bodyLayer, Collection<T> baseCollection, IColumnAccessor<T> columnAccessor)
      Parameters:
      bodyLayer - A layer in the body region. Usually the DataLayer or a layer that is responsible for list event handling. Needed to register ourself as listener for data changes.
      baseCollection - The base collection used to collect the unique values from. This need to be a collection that is not filtered, otherwise after modifications the content of the filter row combo boxes will only contain the current visible (not filtered) elements.
      columnAccessor - The IColumnAccessor to be able to read the values out of the base collection objects.
    • GlazedListsFilterRowComboBoxDataProvider

      public GlazedListsFilterRowComboBoxDataProvider(ILayer bodyLayer, Collection<T> baseCollection, IColumnAccessor<T> columnAccessor, boolean lazy)
      Parameters:
      bodyLayer - A layer in the body region. Usually the DataLayer or a layer that is responsible for list event handling. Needed to register ourself as listener for data changes.
      baseCollection - The base collection used to collect the unique values from. This need to be a collection that is not filtered, otherwise after modifications the content of the filter row combo boxes will only contain the current visible (not filtered) elements.
      columnAccessor - The IColumnAccessor to be able to read the values out of the base collection objects.
      lazy - true to configure this FilterRowComboBoxDataProvider should load the combobox values lazily, false to pre-build the value cache.
      Since:
      1.4
  • Method Details

    • listChanged

      public void listChanged(ca.odell.glazedlists.event.ListEvent<T> listChanges)
      Specified by:
      listChanged in interface ca.odell.glazedlists.event.ListEventListener<T>
    • handleLayerEvent

      public void handleLayerEvent(ILayerEvent event)
      Description copied from interface: ILayerListener
      Handle an event notification from an ILayer
      Specified by:
      handleLayerEvent in interface ILayerListener
      Overrides:
      handleLayerEvent in class FilterRowComboBoxDataProvider<T>
      Parameters:
      event - the event
    • dispose

      public void dispose()
      Description copied from class: FilterRowComboBoxDataProvider
      Cleanup acquired resources.
      Overrides:
      dispose in class FilterRowComboBoxDataProvider<T>
    • isDisposed

      public boolean isDisposed()
      Returns:
      true if this layer was terminated, false if it is still active.
      Since:
      2.1
    • activate

      public void activate()
      Activates the handling of GlazedLists events. By activating on receiving GlazedLists change events, there will be NatTable events fired to indicate that re-rendering is necessary.

      This is usually necessary to perform huge updates of the data model to avoid concurrency issues. By default the GlazedListsFilterRowComboBoxDataProvider is activated. You can deactivate it prior performing bulk updates and activate it again after the update is finished for a better event handling.

      Since:
      2.1
    • deactivate

      public void deactivate()
      Deactivates the handling of GlazedLists events. By deactivating there will be no NatTable events fired on GlazedLists change events.

      This is usually necessary to perform huge updates of the data model to avoid concurrency issues. By default the GlazedListsFilterRowComboBoxDataProvider is activated. You can deactivate it prior performing bulk updates and activate it again after the update is finished for a better event handling.

      Since:
      2.1
    • isActive

      public boolean isActive()
      Returns:
      Whether this GlazedListsFilterRowComboBoxDataProvider will propagate ListEvents into NatTable or not.
      Since:
      2.1
    • discardEventsToProcess

      public void discardEventsToProcess()
      This method can be used to discard event processing.

      It is useful in cases scenarios where list changes are tracked while the handling is deactivated. By default list changes are also tracked while the handling is deactivated, so automatically a refresh is triggered on activation. For cases where a custom event is fired for updates, it could make sense to discard the events to process to avoid that a full refresh event is triggered.

      Since:
      2.1
    • collectValues

      protected List<?> collectValues(Collection<T> collection, int columnIndex)
      Description copied from class: FilterRowComboBoxDataProvider
      Iterates over all rows of the given collection and collects the distinct values for the given column index.
      Overrides:
      collectValues in class FilterRowComboBoxDataProvider<T>
      Parameters:
      collection - The collection out of which the distinct values should be collected.
      columnIndex - The column index for which the values should be collected
      Returns:
      List of all distinct values that are contained in the given collection for the given column.