Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Emf.Edit] Problem in displaying specific items
[Emf.Edit] Problem in displaying specific items [message #420681] Mon, 07 July 2008 15:18 Go to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hello!

I have the following meta-model:
Company -1- contains -n- Division
Division -1- contains -n- Worker
Division -1- contains -n- Division.

Now I have the following requirement: I have to display all Worker model
instances available in all Division in an JFace (Tree)Viewer (This view
should not graphically distinguih in which Division a Worker works). The
problem is I do not know how to that with the EMF generated
AdapterFactory..Providers!
How do I set the input?!? I have tried building up a custom resource that
contains only the Workers, but the Viewer doe s not show anything
(although having the ResourceItemProviderAdapterFactory in my
AdapterFactory added).
I am modifyng my model instances through commands so it would be good to
get this working this way and not writing my on content and label
providers.

Thanks!
Matthias
Re: [Emf.Edit] Problem in displaying specific items [message #420683 is a reply to message #420681] Mon, 07 July 2008 15:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Matthias,

If you want to simply walk the tree and collect all the works to show in
a list, you could do that with an eAllContents on the company looking
work worker instances and once you've constructed that list, you can use
it to create a new ItemProvider(...) and set that as input to the view.


Matthias wrote:
> Hello!
>
> I have the following meta-model:
> Company -1- contains -n- Division
> Division -1- contains -n- Worker
> Division -1- contains -n- Division.
>
> Now I have the following requirement: I have to display all Worker
> model instances available in all Division in an JFace (Tree)Viewer
> (This view should not graphically distinguih in which Division a
> Worker works). The problem is I do not know how to that with the EMF
> generated AdapterFactory..Providers! How do I set the input?!? I have
> tried building up a custom resource that contains only the Workers,
> but the Viewer doe s not show anything (although having the
> ResourceItemProviderAdapterFactory in my AdapterFactory added). I am
> modifyng my model instances through commands so it would be good to
> get this working this way and not writing my on content and label
> providers.
>
> Thanks!
> Matthias
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Emf.Edit] Problem in displaying specific items [message #420713 is a reply to message #420683] Tue, 08 July 2008 14:49 Go to previous message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Thanks a lot Ed!

It can be so simple :)
If some of you have the same requirement:

Company company = (Company) resource.getContents().get(0);
TreeIterator<EObject> iter = company.eAllContents();
while (iter.hasNext()) {
EObject next = iter.next();
if (next instanceof Worker) {
workers.add((Worker) next);
}
}

new ItemProvider("Workers", workers);

Bye,
Matthias
Previous Topic:EAnnotation and Cross document reference
Next Topic:Associations lost when converting from UML
Goto Forum:
  


Current Time: Fri Apr 26 14:15:06 GMT 2024

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

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

Back to the top