Home » Eclipse Projects » e(fx)clipse » How to use AdapterFactoryObservableList ?(Problem with the provided root)
How to use AdapterFactoryObservableList ? [message #1462366] |
Wed, 05 November 2014 13:55 |
Thomas Elskens Messages: 159 Registered: September 2014 Location: Brussels - Belgium |
Senior Member |
|
|
Hello,
I'm trying out the demo about EMF Edit in efxclipse but with my own (extremely simple) ecore model : I only have one class in it, Employer.
So I want to bind this model to an ObservableList, like this :
@PostConstruct
public void init(BorderPane parent, MApplication application)
{
EditingDomain domain = modelservice.getEditingDomain() ;
AdapterFactory factory = modelservice.getAdapterFactory() ;
listView.setItems(new AdapterFactoryObservableList<Object>(factory, modelservice.getRoot()));
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
parent.setCenter(listView);
}
As root element, I thought of just providing the first element of my resource, as follows :
@Override
public Object getRoot()
{
return resource.getContents().get(0) ;
}
When I run this code, I get an IllegalArgumentException : Provided root object cannot be adapted.
But what other root could I provide ? In the demo, the (contact)Group is used for this, but I don't have one in my own model.
The demo would have the same problem anyhow if we would try to have a ListView of contact groups.
I can't come up with some useful alternative, a fortiori because I can't figure out the semantics of a rootelement in a listview? I should just layout independent elements, or am I getting this wrong ?
Thomas
|
|
|
Re: How to use AdapterFactoryObservableList ? [message #1462435 is a reply to message #1462366] |
Wed, 05 November 2014 15:15 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
How did you setup your adapter-factory? Have you tried simply pushing
your resource?
Tom
On 05.11.14 14:55, Thomas Elskens wrote:
> Hello,
>
> I'm trying out the demo about EMF Edit in efxclipse but with my own
> (extremely simple) ecore model : I only have one class in it, Employer.
> So I want to bind this model to an ObservableList, like this :
>
>
> @PostConstruct
> public void init(BorderPane parent, MApplication application)
> {
> EditingDomain domain = modelservice.getEditingDomain() ;
> AdapterFactory factory = modelservice.getAdapterFactory() ;
> listView.setItems(new
> AdapterFactoryObservableList<Object>(factory, modelservice.getRoot()));
>
> listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
> parent.setCenter(listView);
> }
>
>
> As root element, I thought of just providing the first element of my
> resource, as follows :
>
> @Override
> public Object getRoot()
> {
> return resource.getContents().get(0) ;
> }
>
>
> When I run this code, I get an IllegalArgumentException : Provided root
> object cannot be adapted.
> But what other root could I provide ? In the demo, the (contact)Group is
> used for this, but I don't have one in my own model.
>
> The demo would have the same problem anyhow if we would try to have a
> ListView of contact groups.
> I can't come up with some useful alternative, a fortiori because I can't
> figure out the semantics of a rootelement in a listview? I should just
> layout independent elements, or am I getting this wrong ?
>
> Thomas
|
|
|
Re: How to use AdapterFactoryObservableList ? [message #1462542 is a reply to message #1462435] |
Wed, 05 November 2014 17:41 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You could also look how the generated SWT-Editor works. I've never
really used EMF-Edit so I'm not of great help in this regard but from my
EMF-Projects I normally always create a Root-Element which holds my
domain model, the reason is simply you can only serialize to XML (I'm
not talking about XMI) if you have exactly 1 root-element.
Tom
On 05.11.14 16:15, Tom Schindl wrote:
> How did you setup your adapter-factory? Have you tried simply pushing
> your resource?
>
> Tom
>
> On 05.11.14 14:55, Thomas Elskens wrote:
>> Hello,
>>
>> I'm trying out the demo about EMF Edit in efxclipse but with my own
>> (extremely simple) ecore model : I only have one class in it, Employer.
>> So I want to bind this model to an ObservableList, like this :
>>
>>
>> @PostConstruct
>> public void init(BorderPane parent, MApplication application)
>> {
>> EditingDomain domain = modelservice.getEditingDomain() ;
>> AdapterFactory factory = modelservice.getAdapterFactory() ;
>> listView.setItems(new
>> AdapterFactoryObservableList<Object>(factory, modelservice.getRoot()));
>>
>> listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
>> parent.setCenter(listView);
>> }
>>
>>
>> As root element, I thought of just providing the first element of my
>> resource, as follows :
>>
>> @Override
>> public Object getRoot()
>> {
>> return resource.getContents().get(0) ;
>> }
>>
>>
>> When I run this code, I get an IllegalArgumentException : Provided root
>> object cannot be adapted.
>> But what other root could I provide ? In the demo, the (contact)Group is
>> used for this, but I don't have one in my own model.
>>
>> The demo would have the same problem anyhow if we would try to have a
>> ListView of contact groups.
>> I can't come up with some useful alternative, a fortiori because I can't
>> figure out the semantics of a rootelement in a listview? I should just
>> layout independent elements, or am I getting this wrong ?
>>
>> Thomas
>
|
|
| | | |
Goto Forum:
Current Time: Sat Jan 25 19:32:55 GMT 2025
Powered by FUDForum. Page generated in 0.03809 seconds
|