Eclipse rcp EclipseRCP:为什么ViewerCell和ViewerRow没有获取行索引的方法?

Eclipse rcp EclipseRCP:为什么ViewerCell和ViewerRow没有获取行索引的方法?,eclipse-rcp,Eclipse Rcp,ViewerCell类有一个方法getColumnIndex,为什么不提供一个方法来返回行索引呢? 这真让我困惑。请给我一些解释。您可以使用table.getItems().indexOf(cell.getElement())(+/-) 原因可以在虚拟表中找到。对于这些,您无法轻松找到行索引 我的解决方案在这里(扩展TableViewer并将此方法添加到父类): public int getRowIndex(ViewerCell单元格){ YourRowType行=(YourRowType)单元

ViewerCell类有一个方法
getColumnIndex
,为什么不提供一个方法来返回行索引呢?
这真让我困惑。请给我一些解释。

您可以使用
table.getItems().indexOf(cell.getElement())
(+/-)

原因可以在虚拟表中找到。对于这些,您无法轻松找到行索引

我的解决方案在这里(扩展TableViewer并将此方法添加到父类):

public int getRowIndex(ViewerCell单元格){
YourRowType行=(YourRowType)单元格。getElement();
int结果=0;
对于(int i=0;i
public int getRowIndex(ViewerCell cell) {
    YourRowType row = (YourRowType) cell.getElement();
    int result = 0;
    for (int i = 0; i < this.doGetItemCount(); i++) {
        if (this.getElementAt(i).equals(row)) {
            result = i;
            break;
        }
    }
    return result;
}