Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Dynamically recreating Table and Tableviewer(I need to use the same form to show a series of tables.)
icon5.gif  Dynamically recreating Table and Tableviewer [message #495122] Tue, 03 November 2009 20:33
Ian Harac is currently offline Ian HaracFriend
Messages: 10
Registered: November 2009
Location: Southern Indiana
Junior Member


* Edit post
* Report this post
* Reply with quote

Dynamically recreating a Table/Tableviewer

Postby IanHarac » Tue Nov 03, 2009 8:21 am
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. (I did find a way to explicitly dispose of the table, but it didn't solve the problem of the new table not being visible on the form. I did verify that the new table was the table associated with the TableViewer, as well.)

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?

(Solutions involving hiding/showing columns, etc, are not viable, as this screen may be used dozens of times over the course of a working session and that would end up being a lot of clutter. The files I need to view can be very wide, as well, some over 3000 columns (yes, 3000), and others can be very small, so it would be extremely wasteful to just make a table big enough for the largest possible file and then hide, say, 2995 columns if they weren't needed.)

EDIT: I believe it is a rule that one always finds the answer right after one asks for help.

I was not calling layout() after adding deleting and re-creating the controls. (The original form code was generated via WindowBuilder, which is why the controls appeared properly when first created.)

[Updated on: Tue, 03 November 2009 20:48]

Report message to a moderator

Previous Topic:[Databinding] How can I use a DialogCellEditor with databinding?
Next Topic:Combining column- and table-level ILabelProviders
Goto Forum:
  


Current Time: Tue Sep 24 14:12:36 GMT 2024

Powered by FUDForum. Page generated in 0.02908 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top