I am creating a new project using SWT. I will have 3 or 4 different tables in the project. I am fairly new to SWT and I find myself asking should I be using just the Table
or should it be a TableViewer
.
I am wanting to learn some good guidelines on when to use just the Table
and when a TableViewer
is the best route.
- What is the benefit of using a
TableViewer
instead of aTable
? - Should all the tables have a
TableViewer
? - If I am working with data from the table, is just the
Table
the best way?
Just really wanting some clarity so as I create the project I do it the right way.
EDIT
I have created a Tablemodel
class that I am using for my first table. But the createColumns
method is specialized for that specific table.
Is it possible to have a template TableViewer
class?
Can I change the method to be more usable for different tables?
Here is a snippet of the method:
private void createColumns() {
String[] titles = { "ItemId", "RevId", "PRL", "Dataset Name", "EC Markup" };
int[] bounds = { 150, 150, 100, 150, 100 };
TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if(element instanceof AplotDataModel.AplotDatasetData)
return ((AplotDataModel.AplotDatasetData)element).getDataset().toString();
return super.getText(element);
}
});
col = createTableViewerColumn(titles[1], bounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if(element instanceof AplotDataModel.AplotDatasetData)
return ((AplotDataModel.AplotDatasetData)element).getRev().toString();
return super.getText(element);
}
});