Row Numbering in TableViewer [DATABINDING]

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Row Numbering in TableViewer [DATABINDING]

Postby raven » Mon Jul 30, 2007 3:44 am

Hi there,

How to provide a static line numbering (say 1st column) to a TableViewer.

Don't wanna add this information to the Domain object.

Any sorting on the other columns should not affect the sequence of the numbers in the first columns.

Thanks
raven
 
Posts: 5
Joined: Wed Sep 06, 2006 11:38 am

Re: Row Numbering in TableViewer [DATABINDING]

Postby Eric Clayberg » Mon Jul 30, 2007 5:21 am

General questions about how to use various Eclipse widgets should be posted to the appropriate Eclipse newsgroup.

raven wrote:How to provide a static line numbering (say 1st column) to a TableViewer. Don't wanna add this information to the Domain object. Any sorting on the other columns should not affect the sequence of the numbers in the first columns.

Presumably, you would need to set up your TableViewer's LabelProvider to return row numbers (indexes into your sorted element collection) for the first column (columIndex == 0).
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby raven » Tue Jul 31, 2007 1:47 am

Hi Eric,



What LabelProvider do you mean -ObservableMapLabelProvider?

My table has 2 Columns "Row" & "Data".

"Data" is filled via Databinding from the Domain Object ("name" property)

If I do as you suggested, the records from the Domain Object show up
either in "Row" column or, the running numbers are shown instead of the
data from the Domain object.

I really cannot see how I could show row numbers here, without having
the Domain object keeping that information - or can the TableViewer have
more than one input?

Snippet:


protected DataBindingContext initDataBindings() {
//
DataBindingContext bindingContext = new DataBindingContext();
//
//
ObservableListContentProvider tvFirstDataContentProviderList = new ObservableListContentProvider();
tvFirstData.setContentProvider(tvFirstDataContentProviderList);
//
IObservableMap[] tvFirstDataLabelProviderMaps = BeansObservables.observeMaps(tvFirstDataContentProviderList.getKnownElements(), Data.class, new String[]{"name"});
tvFirstData.setLabelProvider(new ObservableMapLabelProvider(tvFirstDataLabelProviderMaps));
//
IObservableList firstDataModelFirstDataObserveList = BeansObservables.observeList(Realm.getDefault(), firstDataModel, "firstData");
tvFirstData.setInput(firstDataModelFirstDataObserveList);
//
return bindingContext;


Br, raven
raven
 
Posts: 5
Joined: Wed Sep 06, 2006 11:38 am

Postby Eric Clayberg » Tue Jul 31, 2007 3:45 am

What you are describing does not sound compatible with the Eclipse Data Binding API. If your table only had two columns and only one column comes from your data, I don't see much benefit to using DB either. A normal TableViewer with its own LabelProvidr and ContentProvider is probably the route you will need to take.

In any case, questions like this are better directed to the appropriate Eclipse newsgroup as I stated earlier.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests