jkteater
jkteater

Reputation: 1391

SWT Table and Tableviewer

First let me say that I do appreciate greatly everyone's suggestions and comments. This is the only source I have to learn this new stuff.

I have only recently learned java and swing. My current project is in Eclipse and I have to do it in SWT. As some of you may have noticed from my many other post, I am very new SWT and only started working with it this week. I am having issues understanding the the new layouts. Things like do you have extend a dialog type (TitleAreaDialog, TrayDialog) in your dialog class? Composites, when you create the parent composite, how do you add child composites to the parent. Once they are added to the parent, how do you setup the placements of them, other than one above the other.

But with my current schedule for this project the most important thing right now is to get the user data and populate a table and then show the table in a separate dialog class.
I can figure out how to add custom buttons such as "Delete Row", "Delete All Rows" later.

Creating a Table:

I have a singleton class that gathers users data and places it in a ArrayList. I need to be able to create a table from the data in the arraylist. If you can point me to some sample code on how to create a table from a arraylist or pseudo code it for me- that would be great!!

Creating a TableViewer:

I have to be able to display/edit the table in a separate dialog class.
I think I have to user a tableviewer to achieve this. Will someone please just code me a simple dialog class and show me how to setup the table viewer. Just a dialog with the Table displayed

Thanks for any help you can give me

OK - I have read over http://www.vogella.com/articles/EclipseJFaceTable/article.html. I have created code to fairly match his example but to my specifications.

If the TableViewer class (View.java) extends ViewPart do you add the view class to a dialog class? or does View.java become the dialog class?

Upvotes: 0

Views: 1572

Answers (1)

Baz
Baz

Reputation: 36884

Your questions are really improving, but you should google more before you ask new questions. I already linked many SWT resources in a different question of yours and you really should read them :)

Here is a really good tutorial by Vogella explaining how to use the Table in combination with TableViewer.

Basically, the TableViewer is responsible for displaying your data via the ContentProviders. Since you have an ArrayList you might want to try ArrayContentProvider.

Upvotes: 2

Related Questions