Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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] by 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
Eclipse UserFriend
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
Eclipse UserFriend
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:Ctrl+1 key binding lost in 3.3 to 3.6 upgrade.
Next Topic:ControlDecoration intersects screen border
Goto Forum:
  


Current Time: Wed Jul 23 15:40:42 EDT 2025

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

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

Back to the top