I have been trying to do what I thought would be easy, but it turns out to be very difficult, or I'm missing something very obvious, despite a lot of Google searches.
I have a form with a table. I want the viewer to open a file (such as a CSV file, though it's not relevant), and the table shows the user what's in the file. Then they can open a different file.
The first part works. The second...
Since each file has a different structure (column names, column types), I have to redo the table each time.
I can't (that I can tell) delete columns from a table in SWT.
I can't (that I can tell) set the table associated with a TableViewer.
So I try to recreate the TableViewer/Table combo.
However, this results in a blank table on the screen. It appears the table associated with the viewer is being covered up/not drawn, and even using MoveAbove() doesn't help. Looking at the getChildren() stack, it seems the table that is created by the call to new TableViewer() is never disposed, i.e, if I call it three times, I will see three Tables as children. Explictly disposing it via:
Table t=myTableViewer.getTable();
t.dispose();
Doesn't seem to work either.
What is the optimal way to dynamically create and view tables using SWT? This is such a common procedure in programming that I can't believe it's giving me such difficulty.
Is the problem that the other controls are still "connected" via the layoutData? Is there a way to "detach" a control?