Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableViewer change column amount depending on Input
TableViewer change column amount depending on Input [message #664335] Fri, 08 April 2011 08:25 Go to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
Hi, I need to change the column amount of my table with the given Input.

I want to display the tabledata depending on the selected table. So the amoutn of columns need to be changed, and also I need to display the column in the header. But I don't really know how to.

Thanks in advance.
Re: TableViewer change column amount depending on Input [message #664362 is a reply to message #664335] Fri, 08 April 2011 10:44 Go to previous messageGo to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
Ok, solved this with an extra method which is called at cration of the Controls and everytime my Input is changed.

But this leads me to another question. All my values are written in the first column. How do I get the TableViewer to write the ResultSetData in the correct column.
In the ContentProvider i create an array which holds all values of the result set like this:

Column 1 | Column 2  | Column 3
--------------------------------
Value1.1 | Value 2.1 | Value 3.1
Value1.2 | Value 2.2 | Value 3.2
...


Then my array looks like this:
Value1.1, Value 2.1, Value 3.1, Value 1.2, Value 2.2, Value 3.2...

Is this correct or do I have to create an array for every column?


Edit: Ok, I see the problem is that the columIndex is alway 0 in the method getText from the TableLabelProvider....

[Updated on: Fri, 08 April 2011 10:55]

Report message to a moderator

Re: TableViewer change column amount depending on Input [message #664382 is a reply to message #664335] Fri, 08 April 2011 11:25 Go to previous messageGo to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
I'm not quite sure about the solution. It seems that after selecting another table the columns are beeing added.

It there no way to get a proper TableViewer for a SQL ResultSet where the amounts of columns could differ?
Re: TableViewer change column amount depending on Input [message #665019 is a reply to message #664382] Tue, 12 April 2011 16:54 Go to previous message
Johan Schulz is currently offline Johan Schulz
Messages: 20
Registered: November 2010
Junior Member
hi,

i had the same problem in a project without using jface and came along that the underlying SWT Table cannot handle different column sizes. At least it works if and only if you get more columns cause adding coumns is allowed and changing the header caption always works.

I used it with SWT.VIRTUAL and disposes all TableHeaders in the SWT.SetData event and recreate the new needed amount of headers. Maybe you have to rewrite much of the code in AbstractStructuredViewer to get this working with JFace but at least this solution works for me without JFace Smile

Good luck
Johan
Previous Topic:Expand Dialog to one direction by Button
Next Topic:FileFieldEditor Help
Goto Forum:
  


Current Time: Mon Sep 01 03:47:24 EDT 2014

Powered by FUDForum. Page generated in 0.02056 seconds