Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [Databinding] TableViewer (rows vs columns)
[Databinding] TableViewer (rows vs columns) [message #649001] Mon, 17 January 2011 03:06 Go to next message
AJ  is currently offline AJ
Messages: 77
Registered: July 2009
Member
My model or class contains only 4 attributes so can I represent an instance of my class using a fix TableViewer where the name and values of the x, y, and z attributes are displayed as rows and the values of the attribute a are the columns?

public class MyModel {
String x;
String y;
String z;
String a;
....
.....
}

----------------------------
| a | C1 | C2 | C3 |
----------------------------
| x | A1 | A2 | A3 |
----------------------------
| y | B1 | B2 | B3 |
----------------------------
| z | Z1 | Z2 | Z3 |
----------------------------

[Updated on: Mon, 17 January 2011 12:42]

Report message to a moderator

Re: [Databinding] TableViewer (rows vs columns) [message #649915 is a reply to message #649001] Thu, 20 January 2011 18:24 Go to previous message
Carsten Habicht is currently offline Carsten Habicht
Messages: 14
Registered: January 2011
Junior Member
Does this mean, that your table grows to the right? Adding an object would mean that column C4 is created?
In this case, maybe you could create an intermediate model of the form
public class Line {
  String labelColumnA; // Holds X for the first row, Y for the second, etc.
  List<String> otherColumns; // Holds An, Bn, Cn for each column n
...
}


Then you can use a label provider that shows the right label according to the column index (index==0 --> labelCol, index>0 --> otherColumns.get(index-1) ).
I'm not sure how Table and TableViewer behave, if you add columns dynamically, but probably it works with some tableViewer.refresh() fiddling.


Sylphen - Ihr Systemhaus in Mittelhessen - http://www.sylphen.com/
Previous Topic:[Databinding] Master-detail-binding and validators
Next Topic:StructuredViewer useHashlookup
Goto Forum:
  


Current Time: Wed Apr 16 03:31:09 EDT 2014

Powered by FUDForum. Page generated in 0.01749 seconds