开发者

How to use TableViewer in WindowBuilderPro?

开发者 https://www.devze.com 2023-03-26 13:15 出处:网络
I have to create a table in my wizard page and I want to create it using TableViewer. I\'m using WindowBuilderPro for designing my wizard page. The TableViewer control is a开发者_开发问答vailable in t

I have to create a table in my wizard page and I want to create it using TableViewer. I'm using WindowBuilderPro for designing my wizard page. The TableViewer control is a开发者_开发问答vailable in the palette of WindowBuilderPro but I'm not getting how to use it properly.

Has any body used the same?

Thanks a lot in advance!!


You have two ways of filling the TableViewer with contents (similar to TableViewers in JFace):

  1. You can define a content provider and a label provider manually. A content provider has to return a set of Objects, that represent each line of the table; while the TableLabelProvider translates the returned objects to texts in the columns. The content and label providers are to set in the Properties box on the left. In this case, the resulting code should look like the following snippets: http://wiki.eclipse.org/JFaceSnippets#Snippet001TableViewer or http://wiki.eclipse.org/JFaceSnippets#Snippet007FullSelection.

  2. On the other hand you could define JFace Data Bindings to fill the table with contents. In this case you have to define a corresponding binding, that returns the list of all contents; additionally you have to create a label provider, that works similar to the previous one.

There is also a way to fill the table content using a newer API then supported directly by WindowBuilder: you could create TableViewerColumns, and ColumnLabelProviders for each column, thus resulting in much nicer code for Label Providers (and also this API is newer, so it should be preferred for new JFace based code) - but in this case you have to create your code manually. See the JFace Table tutorial from Lars Vogel.

Additionally, if you don't know the JFace Viewer framework from before, I suggest reading the first few questions listed in the JFace FAQ to gain a better understanding of the ideas (and the tutorial from Lars Vogel is also nice for this reason).

0

精彩评论

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