Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Get all object with specific value
Get all object with specific value [message #727011] Tue, 20 September 2011 07:55 Go to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
Hi,

I guess it's a simple question, but I can't find the answer...

I have a Resource with objects of type A. These objects have a reference to object B. How can I retrieve all objects in the resource with a specific object B. So three objects have a reference to object B with id=1. I want to retrieve those three objects..

It needs to be a ObservableList, so I can set it as an input of my tableviewer..

Thanks in advance.
Re: Get all object with specific value [message #727085 is a reply to message #727011] Tue, 20 September 2011 11:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ricky,

EcoreUtil.UsageCrossReferencer can be used for something like this. Or
you can use Resource.getAllContents() to iterate over all objects in the
resource, determine which ones are instances of A, and then determine
which of those reference the particular B of interest. I'm not sure
how to turn the result into an observable list.



On 20/09/2011 3:55 AM, Ricky de Klerck wrote:
> Hi,
>
> I guess it's a simple question, but I can't find the answer...
>
> I have a Resource with objects of type A. These objects have a
> reference to object B. How can I retrieve all objects in the resource
> with a specific object B. So three objects have a reference to object
> B with id=1. I want to retrieve those three objects..
>
> It needs to be a ObservableList, so I can set it as an input of my
> tableviewer..
>
> Thanks in advance.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Get all object with specific value [message #727087 is a reply to message #727085] Tue, 20 September 2011 11:29 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Using a ComputedList but an important fact is that you need to observe
all elements because you need to recalculate the value once the
reference of an object changes!

Tom

Am 20.09.11 13:23, schrieb Ed Merks:
> Ricky,
>
> EcoreUtil.UsageCrossReferencer can be used for something like this. Or
> you can use Resource.getAllContents() to iterate over all objects in the
> resource, determine which ones are instances of A, and then determine
> which of those reference the particular B of interest. I'm not sure
> how to turn the result into an observable list.
>
>
>
> On 20/09/2011 3:55 AM, Ricky de Klerck wrote:
>> Hi,
>>
>> I guess it's a simple question, but I can't find the answer...
>>
>> I have a Resource with objects of type A. These objects have a
>> reference to object B. How can I retrieve all objects in the resource
>> with a specific object B. So three objects have a reference to object
>> B with id=1. I want to retrieve those three objects..
>>
>> It needs to be a ObservableList, so I can set it as an input of my
>> tableviewer..
>>
>> Thanks in advance.
Re: Get all object with specific value [message #727089 is a reply to message #727011] Tue, 20 September 2011 11:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ricky,

EcoreUtil.UsageCrossReferencer can be used for something like this. Or
you can use Resource.getAllContents() to iterate over all objects in the
resource, determine which ones are instances of A, and then determine
which of those reference the particular B of interest. I'm not sure
how to turn the result into an observable list.



On 20/09/2011 3:55 AM, Ricky de Klerck wrote:
> Hi,
>
> I guess it's a simple question, but I can't find the answer...
>
> I have a Resource with objects of type A. These objects have a
> reference to object B. How can I retrieve all objects in the resource
> with a specific object B. So three objects have a reference to object
> B with id=1. I want to retrieve those three objects..
>
> It needs to be a ObservableList, so I can set it as an input of my
> tableviewer..
>
> Thanks in advance.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Get all object with specific value [message #727091 is a reply to message #727085] Tue, 20 September 2011 11:29 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Using a ComputedList but an important fact is that you need to observe
all elements because you need to recalculate the value once the
reference of an object changes!

Tom

Am 20.09.11 13:23, schrieb Ed Merks:
> Ricky,
>
> EcoreUtil.UsageCrossReferencer can be used for something like this. Or
> you can use Resource.getAllContents() to iterate over all objects in the
> resource, determine which ones are instances of A, and then determine
> which of those reference the particular B of interest. I'm not sure
> how to turn the result into an observable list.
>
>
>
> On 20/09/2011 3:55 AM, Ricky de Klerck wrote:
>> Hi,
>>
>> I guess it's a simple question, but I can't find the answer...
>>
>> I have a Resource with objects of type A. These objects have a
>> reference to object B. How can I retrieve all objects in the resource
>> with a specific object B. So three objects have a reference to object
>> B with id=1. I want to retrieve those three objects..
>>
>> It needs to be a ObservableList, so I can set it as an input of my
>> tableviewer..
>>
>> Thanks in advance.
Previous Topic:How to create a diagram instance from an Ecore model?
Next Topic:Re: [CDO] References across two EMF models
Goto Forum:
  


Current Time: Wed Apr 24 17:13:16 GMT 2024

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

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

Back to the top