Class RowSelectionProvider<T>

java.lang.Object
org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider<T>
Type Parameters:
T - The type of objects provided by the IRowDataProvider
All Implemented Interfaces:
org.eclipse.jface.viewers.ISelectionProvider, ILayerListener
Direct Known Subclasses:
RowPostSelectionProvider

public class RowSelectionProvider<T> extends Object implements org.eclipse.jface.viewers.ISelectionProvider, ILayerListener
Implementation of ISelectionProvider to add support for JFace selection handling.
  • Constructor Details

    • RowSelectionProvider

      public RowSelectionProvider(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider)
      Create a RowSelectionProvider that only handles fully selected rows and only fires SelectionChangedEvents if the row selection changes.
      Parameters:
      selectionLayer - The SelectionLayer this ISelectionProvider should be connected to.
      rowDataProvider - The IRowDataProvider that should be used to access the selected row data.
    • RowSelectionProvider

      public RowSelectionProvider(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider, boolean fullySelectedRowsOnly)
      Create a RowSelectionProvider that only fires SelectionChangedEvents if the row selection changes.
      Parameters:
      selectionLayer - The SelectionLayer this ISelectionProvider should be connected to.
      rowDataProvider - The IRowDataProvider that should be used to access the selected row data.
      fullySelectedRowsOnly - Flag to determine if only fully selected rows should be used to populate the selection or if any selection should be populated.
    • RowSelectionProvider

      public RowSelectionProvider(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider, boolean fullySelectedRowsOnly, boolean handleSameRowSelection)
      Create a RowSelectionProvider configured with the given parameters.
      Parameters:
      selectionLayer - The SelectionLayer this ISelectionProvider should be connected to.
      rowDataProvider - The IRowDataProvider that should be used to access the selected row data.
      fullySelectedRowsOnly - Flag to determine if only fully selected rows should be used to populate the selection or if any selection should be populated.
      handleSameRowSelection - Flag to configure whether only SelectionChangedEvents should be fired if the row selection changes or even if you just select another column.
  • Method Details

    • updateSelectionProvider

      public void updateSelectionProvider(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider)
      Updates this RowSelectionProvider so it handles the selection of another SelectionLayer and IRowDataProvider.

      This method was introduced to add support for multiple selection provider within one part. As replacing the selection provider during the lifetime of a part is not properly supported by the workbench, this implementation adds the possibility to exchange the control that serves as selection provider by exchanging the references in the selection provider itself.

      Parameters:
      selectionLayer - The SelectionLayer this ISelectionProvider should be connected to.
      rowDataProvider - The IRowDataProvider that should be used to access the selected row data.
    • addSelectionChangedListener

      public void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
      Specified by:
      addSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
    • getSelection

      public org.eclipse.jface.viewers.ISelection getSelection()
      Specified by:
      getSelection in interface org.eclipse.jface.viewers.ISelectionProvider
    • removeSelectionChangedListener

      public void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
      Specified by:
      removeSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
    • setSelection

      public void setSelection(org.eclipse.jface.viewers.ISelection selection)
      Specified by:
      setSelection in interface org.eclipse.jface.viewers.ISelectionProvider
    • handleLayerEvent

      public void handleLayerEvent(ILayerEvent event)
      Description copied from interface: ILayerListener
      Handle an event notification from an ILayer
      Specified by:
      handleLayerEvent in interface ILayerListener
      Parameters:
      event - the event
    • setAddSelectionOnSet

      public void setAddSelectionOnSet(boolean addSelectionOnSet)
      Configure whether setSelection() should add or set the selection.

      This was added for convenience because the initial code always added the selection on setSelection() by creating a SelectRowsCommand with the withControlMask set to true. Looking at the specification, setSelection() is used to set the new selection. So the default here is now to set instead of add. But for convenience to older code that relied on the add behaviour it is now possible to change it back to adding.

      Parameters:
      addSelectionOnSet - true to add the selection on calling setSelection() The default is false to behave like specified in RowSelectionProvider
    • setProcessColumnSelection

      public void setProcessColumnSelection(boolean processColumnSelection)
      Configure whether column selections should start row selection processing or not.

      This is necessary to handle issues with huge datasets. Dependent on different configurations, selecting a column can cause the selection of all rows in a table, which would then lead to populate the whole dataset as selection via this provider. Setting the processColumnSelection flag to false will skip processing to avoid such issues.

      Parameters:
      processColumnSelection - true to process row selection in case of column selections (default) false to skip processing in case of column selections to avoid issues on large datasets.