SWT Databinding question

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

SWT Databinding question

Postby IanHarac » Mon Nov 22, 2010 8:25 am

I am trying to use data binding to show a single element in a collection. I have looked at the phone book application, but trying to apply it to my particular setup has proven frustrating. I feel I am missing one particular bit of understanding, and hopefully someone can nudge me in the right direction.

I have a datagrid (Nebula control). The grid shows rows from a ResultSet, using a content provider that returns the data as a string array. This all works.

The purpose of this application to is to let the user map and change field types. The data being shown is for information purposes, so the user can see what's in each column of the table. What matters is which *column* is being selected, though the user can navigate cell-by-cell. So the grid's selection will return a cell, but what I care about is the column the cell is in.

In the header of each cell is a custom control which allows the user to set specific field data, and more data is displayed on a panel above the grid. The data model that feeds both the header control in the grid column and the detailed data display on the panel is called FieldColumnInfo, and I have a vector of those, with one for each column.

When the user moves from one column to the next, the panel should change to reflect the new column's data; when the user edits the data, either in the panel or the column header, the underlying model needs to be updated.

I tried creating a wrapper class for the list of field columns, and made it a SelectionProvider, and tried to bind the fields to the column selected (any time the user clicked on the grid, I would set the selection in the wrapper class to the proper index), but this did not work, or, at least, I set something up wrong.

Any help is appreciated. Thank you. This has been frustrating me for several days, and I know it should be much easier than it seems.
Attachments
FieldConverter.jpg
Screenshot of what I'm trying to do.
FieldConverter.jpg (174.81 KiB) Viewed 255 times
IanHarac
 
Posts: 27
Joined: Wed Jan 10, 2007 7:04 am

Re: SWT Databinding question

Postby Eric Clayberg » Mon Nov 22, 2010 4:50 pm

I would highly recommend asking detailed Nebula/SWT/RCP usage questions like this in either the Eclipse Nebula, SWT or RCP newsgroups.

We would like to keep this forum very focused on SWT Designer itself.

I would also suggest that without posting some working sample code illustrating what you have done (and giving someone the opportunity to play around with where you are now), very few people will be able to offer much help.
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

Re: SWT Databinding question

Postby IanHarac » Tue Nov 23, 2010 10:28 am

Thanks for the advice on moving it to SWT/Jface forums; I wasn't sure if it was mostly an issue w/using the data binding wizard or a deeper problem. IAE, as is often the case, after organizing my thoughts enough to compose a request for help, I managed to figure out the issue.

Part of the problem was that a bug I was/am experiencing with WindowBuilder that I was attributing to the databinding code, but it turns out this was not the case, which is the subject of a new thread.
IanHarac
 
Posts: 27
Joined: Wed Jan 10, 2007 7:04 am

Re: SWT Databinding question

Postby Eric Clayberg » Tue Nov 23, 2010 10:45 am

It is important to keep in mind that we are not experts in using either Nebula or the Eclipse Data Binding framework (neither are used internally to create WindowBuilder, for example). A complex question that involves usage of both of those combined is well outside our area of expertise (thus the suggestion to ask the question in the most likely places to find someone knowledgeable to help you).

General comment to all readers:

It is also always a good idea to provide a small, self-contained, working (to the extent that it does work) example that illustrates what you are doing and the problem you are having. That will allow someone to actually try to replicate the issue and possibly offer a suggestion. No test case at all limits you to being helped only by those who might know the answer off of the tops of their heads (which isn't many and definitely isn't us). An incomplete or fragmentary test case is similarly not very helpful because most potential helpers are only willing to invest a small amount of time on the problem you pose, so having it compile and run on the first try is very important.
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

Re: SWT Databinding question

Postby IanHarac » Fri Nov 26, 2010 6:47 am

Eric Clayberg wrote:It is important to keep in mind that we are not experts in using either Nebula or the Eclipse Data Binding framework (neither are used internally to create WindowBuilder, for example). A complex question that involves usage of both of those combined is well outside our area of expertise (thus the suggestion to ask the question in the most likely places to find someone knowledgeable to help you).


Let me ask, then, whether this is the correct forum.

I eventually tracked the problem down to the generated code. It seems that SWT Designer always called "InitDataBindings()" if it is present in the form code, even if it's not called from CreateContent(). (i.e, I moved the explicit call to it out of that method). When I use the DataBindingWizard to generate code, and then move the code it generates to another method ("MyDataBindingInit()"), the generated code works properly when I run my application. However, SWT Designer will not render the form properly if I leave the generated code in place. This may be due to how the underlying objects being bound are initialized, or it might be due to how SWT Designer is processing the code when it gets ready to render the page for the visual editor. Since the code works when I run it, I have to guess I'm creating the objects properly, but there might be another step I need to let SWT Designer access them when it needs to do whatever-it-does to set up the DataBinding Wizard?

If you think it will be valuable for me to post the source here, I will try to provide as much of the relevant code as possible.
IanHarac
 
Posts: 27
Joined: Wed Jan 10, 2007 7:04 am

Re: SWT Databinding question

Postby Eric Clayberg » Fri Nov 26, 2010 7:15 am

SWT Designer will definitely process initDataBindings(), if it is present in the class.

If you don't want that to happen, you should either delete it, comment it out or hide it from the parser with code hiding tags.
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: Bing [Bot] and 1 guest

cron