开发者

Viewing a data matrix in Eclipse (RCP)

This is how I update my TableViewer that displays a list:

public void view(MyListClass list) {
    ViewerSupport.bind(
  开发者_运维问答      this,
        new WritableList(list, controller.theClass()),
        BeanProperties.values(controller.theClass(), controller.strings())
    );
}

controller is an instance of a class that encapsulates my glue code (it is a different class for the two listings; as is controller.theClass()). strings() is an array of property names. MyListClass descends from ArrayList<MyListEntryObject>. That works fine. But, I want to display a matrix of data. MyMatrixClass is a HashMap<Point, MyMatrixEntryObject>. This is what I've tried:

private void view(MyMatrixClass matrix) {
    columns(matrix.columns());

    List<WritableList> lists = new ArrayList<WritableList>(matrix.rows());

    for (MyEntityClass list : matrix.children())
        if (list instanceof MyListClass)
            lists.add(new WritableList((MyListClass) list, controller.theClass()));

    WritableList[] alists = lists.toArray(new WritableList[0]);

    MultiList mlist = new MultiList(alists);

    ViewerSupport.bind(
            this,
            mlist,
            BeanProperties.value(controller.theClass(), "value")
    );
}

This doesn't work. I get null argument popup errors. (Every data model class implements MyEntityClass. Class names have been altered due to this being a proprietary program I'm being employed to develop.)

Long story short, how do I use ViewerSupport and BeanProperties to display a matrix of data in a TableViewer?


As the JFace table viewer is line-based, you have to provide your matrix in a line-based way. You have to create a collection of the lines of the matrix, and then set this list as the input of the viewer. After that, you could create BeanProperties, that display the columns of the selected rows.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜