Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Group ItemProvider Children in folders in TreeViewers(How to modify EMF.Edit in order to show children of the same type inside a folder when displayed in a TreeViewer)
Group ItemProvider Children in folders in TreeViewers [message #710161] Thu, 04 August 2011 19:13 Go to next message
Mauricio Reyes is currently offline Mauricio ReyesFriend
Messages: 26
Registered: August 2011
Junior Member
Hi, I'm starting with EMF and EMF Client Platform (ECP)

What I need
I want to display the navigation tree of ECP customized in order to group children of the same type in a folder.

Example
e.g. I define in my model an EClass called SoccerTeam that has EReferences to Goalkeeper, Defender, Midfielder, Forward (ref. Soccer: en.wikipedia.org/wiki/Association_football_positions), so when I open the EMF standard treeviewer or ECP Navigator, I'll have all my squad below SoccerTeam and I'd like to group them by position and all my players should be children of their position.
What I got from EMF

- SoccerTeam1
+- GK1 : Goalkeeper
+- DF1 : Defender
+- DF2 : Defender
+- MF1 : Midfielder
+- MF2 : Midfielder
+- FW2 : Forward


What I want

- SoccerTeam1
+- Goalkeepers
++- GK1 : Goalkeeper
+- Defenders
++- DF1 : Defender
++- DF2 : Defender
+- Midfielder
++- MF1 : Midfielder
++- MF2 : Midfielder
+- Forwards
++- FW2 : Forward


Alternatives
At this moment I'm thinking of two posibilities:
1) Change my model
2) Modify somehow the EMF.Edit to create those folders between father and child

I'm trying to make this without changing my original model, because the grouping thing is not an entity that should be modeled in an EClass like the other entities.

With option 2 I can make this example work in ECP or in the standard EMF TreeViewer so that's the way I'm trying to go.

My problem is that I cannot see where should I interfere the output ItemProvider to group the children. So far I've seen that getChildrenFeatures in the ItemProvider is where EMF defines who are the children and ItemProviderAdapter returns me the children in getChildren method. But I don't know how can I Override it to join the children by their type.

Thanks in advance and if there's something not clear about the problem just ask Smile

Mauricio
Re: Group ItemProvider Children in folders in TreeViewers [message #710269 is a reply to message #710161] Thu, 04 August 2011 21:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
The EMF Book has a chapter about introducing synthetic nodes in the tree...

One way of looking at it as to think of it as if you replicate the item
provider for SoccerTeam but in each case you show a different subset of
children which a matter of fiddling with the list of features returned a
children features to specify only one. Each of these can then be made
to look like a child of a SoccerTeam item provider that shows only these
fake children. The devil is in the details. The book (which I don't
have with me in Germany) covers those.


On 04/08/2011 9:13 PM, maureyeslopez wrote:
> Hi, I'm starting with EMF and EMF Client Platform (ECP)
>
> What I need
> I want to display the navigation tree of ECP customized in order to
> group children of the same type in a folder.
>
> Example
> e.g. I define in my model an EClass called SoccerTeam that has
> EReferences to Goalkeeper, Defender, Midfielder, Forward (ref. Soccer:
> en.wikipedia.org/wiki/Association_football_positions), so when I open
> the EMF standard treeviewer or ECP Navigator, I'll have all my squad
> below SoccerTeam and I'd like to group them by position and all my
> players should be children of their position.
>
> What I got from EMF
>
> - SoccerTeam1
> +- GK1 : Goalkeeper
> +- DF1 : Defender
> +- DF2 : Defender
> +- MF1 : Midfielder
> +- MF2 : Midfielder
> +- FW2 : Forward
>
>
>
> What I want
>
> - SoccerTeam1
> +- Goalkeepers
> ++- GK1 : Goalkeeper
> +- Defenders
> ++- DF1 : Defender
> ++- DF2 : Defender
> +- Midfielder
> ++- MF1 : Midfielder
> ++- MF2 : Midfielder
> +- Forwards
> ++- FW2 : Forward
>
>
> Alternatives
> At this moment I'm thinking of two posibilities:
> 1) Change my model
> 2) Modify somehow the EMF.Edit to create those folders between father
> and child
>
> I'm trying to make this without changing my original model, because
> the grouping thing is not an entity that should be modeled in an
> EClass like the other entities.
>
> With option 2 I can make this example work in ECP or in the standard
> EMF TreeViewer so that's the way I'm trying to go.
>
> My problem is that I cannot see where should I interfere the output
> ItemProvider to group the children. So far I've seen that
> getChildrenFeatures in the ItemProvider is where EMF defines who are
> the children and ItemProviderAdapter returns me the children in
> getChildren method. But I don't know how can I Override it to join the
> children by their type.
>
> Thanks in advance and if there's something not clear about the problem
> just ask :)
>
> Mauricio


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Group ItemProvider Children in folders in TreeViewers [message #710981 is a reply to message #710269] Fri, 05 August 2011 16:49 Go to previous messageGo to next message
Mauricio Reyes is currently offline Mauricio ReyesFriend
Messages: 26
Registered: August 2011
Junior Member
Thanks Ed, I'll check it
Re: Group ItemProvider Children in folders in TreeViewers [message #714058 is a reply to message #710981] Tue, 09 August 2011 17:51 Go to previous message
Mauricio Reyes is currently offline Mauricio ReyesFriend
Messages: 26
Registered: August 2011
Junior Member
In case somebody else has the same doubt the chapter of the book is 19.2.3. Adding Non-Model Intermediary View Objects

Another useful resource for me was: wiki.eclipse.org/Sphinx/tutorials#Adding_Transient_Nodes
Previous Topic:[xcore] A textual language for Ecore
Next Topic:GEF - images
Goto Forum:
  


Current Time: Tue Apr 16 09:47:17 GMT 2024

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

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

Back to the top