开发者

eclipse rcp: why ViewerCell and ViewerRow do not have method to get row index?

ViewerCe开发者_开发百科ll class has a method getColumnIndex, why not provide a method to return row index? This really confuses me. Please give me some explanation about this.


You can use table.getItems().indexOf(cell.getElement()) (+/-).

The reason for this is found in virtual tables. For these you cannot easily find the row index...


My solution is here (extend TableViewer and add this method to your parent class):

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜