Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [DataBinding] No IObservableFactory for table details?
[DataBinding] No IObservableFactory for table details? [message #318227] Mon, 23 July 2007 18:26 Go to next message
Juergen King is currently offline Juergen KingFriend
Messages: 3
Registered: July 2009
Junior Member
Hi,

I am about to port a client framework from my proprietary binding to
JFace databinding. The binding for beans works pretty well, but I also
want to support POJOs without PropetyChangeSupport. The mapping of those
POJOs outside a Table is not the problem, but to map a list of POJOs to
a table my code looks like this:

IObservableList observableList =
aMatchingTarget.createIObservableList();
Class<?> realComponentType = calcComponentType(observableList,
getComponentType());
ObservableListContentProvider contentProvider = new
ObservableListContentProvider();
getViewer().setContentProvider(contentProvider);
final String[] associatedNames = getAssociatedNames();
if ((associatedNames != null) && (associatedNames.length > 0)) {


IObservableMap[] attributeMaps = BeansObservables.observeMaps(
contentProvider.getKnownElements(), realComponentType,
associatedNames);


getViewer().setLabelProvider(new
ObservableMapLabelProvider(attributeMaps));
} else {
getViewer().setLabelProvider(new LabelProvider());
}
getViewer().setInput(observableList);

Using BeansObservables.observeMaps(...) I get an error in stderr about
the missing PropertyChangeSupport.
I can only find a IObservableFactory in the context of
MasterDetailObservables did I miss something important? Should I
implement my own IObservableMap or my own LabelProvider to solve this
problem?

Juergen
--
https://sourceforge.net/projects/jrcaf/
Re: [DataBinding] No IObservableFactory for table details? [message #318235 is a reply to message #318227] Mon, 23 July 2007 20:27 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
The databinding expects real Beans so you are better of using your own
LabelProvider or better CellLabelProvider if you are targeting 3.3. See
http://wiki.eclipse.org/index.php/JFaceSnippets.

If you want to use inline editing this is supported by 3.3 API This is
shown in
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.e xamples.databinding/src/org/eclipse/jface/examples/databindi ng/snippets/Snippet013TableViewerEditing.java?view=markup

Tom

Juergen King schrieb:
> Hi,
>
> I am about to port a client framework from my proprietary binding to
> JFace databinding. The binding for beans works pretty well, but I also
> want to support POJOs without PropetyChangeSupport. The mapping of those
> POJOs outside a Table is not the problem, but to map a list of POJOs to
> a table my code looks like this:
>
> IObservableList observableList =
> aMatchingTarget.createIObservableList();
> Class<?> realComponentType = calcComponentType(observableList,
> getComponentType());
> ObservableListContentProvider contentProvider = new
> ObservableListContentProvider();
> getViewer().setContentProvider(contentProvider);
> final String[] associatedNames = getAssociatedNames();
> if ((associatedNames != null) && (associatedNames.length > 0)) {
>
>
> IObservableMap[] attributeMaps = BeansObservables.observeMaps(
> contentProvider.getKnownElements(), realComponentType,
> associatedNames);
>
>
> getViewer().setLabelProvider(new
> ObservableMapLabelProvider(attributeMaps));
> } else {
> getViewer().setLabelProvider(new LabelProvider());
> }
> getViewer().setInput(observableList);
>
> Using BeansObservables.observeMaps(...) I get an error in stderr about
> the missing PropertyChangeSupport.
> I can only find a IObservableFactory in the context of
> MasterDetailObservables did I miss something important? Should I
> implement my own IObservableMap or my own LabelProvider to solve this
> problem?
>
> Juergen


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: [DataBinding] No IObservableFactory for table details? [message #318279 is a reply to message #318235] Tue, 24 July 2007 14:24 Go to previous messageGo to next message
Juergen King is currently offline Juergen KingFriend
Messages: 3
Registered: July 2009
Junior Member
Hi Tom,

Thank you for your answer. I expected to find an API like the one in
MasterDetailObservables where I could pass a IObservableFactory. From my
point of view the elements in a list are details like the detail in
DetailObservableValue.
Now that I am sure I didn't miss an important API I will write my own
CellLabelProvider like you suggested. Inline editing is also on the list
of features for the final 1.0 release.

Juergen
--
https://sourceforge.net/projects/jrcaf/
Re: [DataBinding] No IObservableFactory for table details? [message #318430 is a reply to message #318227] Sun, 29 July 2007 06:01 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
Juergen King wrote:
> Hi,
>
> I am about to port a client framework from my proprietary binding to
> JFace databinding. The binding for beans works pretty well, but I also
> want to support POJOs without PropetyChangeSupport. The mapping of those
> POJOs outside a Table is not the problem, but to map a list of POJOs to
> a table my code looks like this:
>
> IObservableList observableList =
> aMatchingTarget.createIObservableList();
> Class<?> realComponentType = calcComponentType(observableList,
> getComponentType());
> ObservableListContentProvider contentProvider = new
> ObservableListContentProvider();
> getViewer().setContentProvider(contentProvider);
> final String[] associatedNames = getAssociatedNames();
> if ((associatedNames != null) && (associatedNames.length > 0)) {
>
>
> IObservableMap[] attributeMaps = BeansObservables.observeMaps(
> contentProvider.getKnownElements(), realComponentType,
> associatedNames);
>
>
> getViewer().setLabelProvider(new
> ObservableMapLabelProvider(attributeMaps));
> } else {
> getViewer().setLabelProvider(new LabelProvider());
> }
> getViewer().setInput(observableList);
>
> Using BeansObservables.observeMaps(...) I get an error in stderr about
> the missing PropertyChangeSupport.
> I can only find a IObservableFactory in the context of
> MasterDetailObservables did I miss something important? Should I
> implement my own IObservableMap or my own LabelProvider to solve this
> problem?
>
> Juergen

I logged an enhancement request for us to provide support for POJOs[1].
You're always going to see these error messages if you attempt to use
BeansObservables with a POJO. You could create your own implementation
of ILogger to eat these messages although it would be a hackish
solution... but it would work.

-brad

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=198201
Re: [DataBinding] No IObservableFactory for table details? [message #318538 is a reply to message #318430] Tue, 31 July 2007 16:32 Go to previous messageGo to next message
Juergen King is currently offline Juergen KingFriend
Messages: 3
Registered: July 2009
Junior Member
Hi Brad,

> I logged an enhancement request for us to provide support for POJOs[1].
> You're always going to see these error messages if you attempt to use
> BeansObservables with a POJO. You could create your own implementation
> of ILogger to eat these messages although it would be a hackish
> solution... but it would work.

I am not sure if a simple POJO support is generic enough.

In my case I have my own notification mechanism to get notified about
changes on a POJO by the Controller. So I could create a
IObservableValue if e.g. a method like
JavaBeanObservableMap#hookListener(Object domainElement) would delegate
the creation to a IObservableFactory.

You may want to support a list of POJOs, EMF-Objects or even JavaBeans
in e.g. a table.

Juergen
--
https://sourceforge.net/projects/jrcaf/
Re: [DataBinding] No IObservableFactory for table details? [message #318576 is a reply to message #318538] Wed, 01 August 2007 02:53 Go to previous message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
Juergen King wrote:
> Hi Brad,
>
>> I logged an enhancement request for us to provide support for
>> POJOs[1]. You're always going to see these error messages if you
>> attempt to use BeansObservables with a POJO. You could create your
>> own implementation of ILogger to eat these messages although it would
>> be a hackish solution... but it would work.
>
> I am not sure if a simple POJO support is generic enough.
>
> In my case I have my own notification mechanism to get notified about
> changes on a POJO by the Controller. So I could create a
> IObservableValue if e.g. a method like
> JavaBeanObservableMap#hookListener(Object domainElement) would delegate
> the creation to a IObservableFactory.
>
> You may want to support a list of POJOs, EMF-Objects or even JavaBeans
> in e.g. a table.
>
> Juergen

We support any observable in a table, not just beans. By invoking
BeansObservables.observeMaps(...) you're saying that your object is a
bean. If it's not it's not going to work because that's all this method
supports. If you have your own model object type you need to write your
own observable implementation and invoke it from your own factory (e.g.
MyTrustyObservables.observeMaps(...).

-brad
Previous Topic:Globalizing site.xml
Next Topic:manipulating source files changes
Goto Forum:
  


Current Time: Thu Dec 18 20:23:04 GMT 2014

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

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