【问题标题】:Automatic row selection in NatTableNatTable 中的自动行选择
【发布时间】:2014-08-29 03:56:49
【问题描述】:

我想以编程方式选择 NatTable 中的某些行

NatTable example program 中有一些示例代码(在 Classic Examples -> Selection -> Get and set selected objects 下)使用 ISelectionProvider(在这种情况下为 org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider )。

ISelectionProvider selectionProvider = new RowSelectionProvider(gridLayer.getBodyLayer().getSelectionLayer(), bodyDataProvider, false);
selectionProvider.setSelection(new StructuredSelection(new Person[] { homer, smithers, nelson }));

我从另一个来源找到了一种更简单的选择行的方法:

natTable.doCommand(new SelectRowsCommand(ILayer layer, int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask));

有什么理由不使用第二种方法吗?

【问题讨论】:

    标签: eclipse selection nattable


    【解决方案1】:

    正如您已经提到的,第一种方法是使用 ISelectionProvider,它通常用于在 Eclipse 应用程序中的部件之间共享选择。

    第二种方法是 NatTable 默认值。在内部,选择提供程序也是如此。因此,如果您只关心以编程方式进行选择,则可以在没有选择提供程序的情况下使用它。

    【讨论】:

      猜你喜欢
      • 2016-09-21
      • 1970-01-01
      • 2020-04-07
      • 2020-02-18
      • 2021-12-05
      • 2019-12-17
      • 2016-11-29
      • 2017-03-23
      • 2014-05-03
      相关资源
      最近更新 更多