Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » 2 different top level node types from same model element type
2 different top level node types from same model element type [message #228619] Thu, 30 April 2009 23:39 Go to next message
John Yotka is currently offline John YotkaFriend
Messages: 144
Registered: July 2009
Senior Member
I need to display 2 different types of top level nodes for a given type
of model element, where each type displays different relevant
information about the model element. For example, suppose I have a
model element type FOLDER that always contains TEXT_FILES, but sometimes
(rarely) also contains IMAGE_FILES. I need one top level node type,
which has a compartment showing the TEXT_FILES. And I also need a
different top level node type, which has a compartment showing the
IMAGE_FILES. When I create the two top level nodes in the .gmfmap file
everything generates ok, that is there are 2 different editParts
generated for the 2 different top nodes, but only one type of nodes
(eg., TEXT_FILES) are displayed.

Is this concept of multiple (different) Top Level Nodes for same model
element type supported directly by GMF? Is there a way to modify the
generated code to accomplish this? Thanks for any help in advance!
Re: 2 different top level node types from same model element type [message #228635 is a reply to message #228619] Fri, 01 May 2009 07:58 Go to previous messageGo to next message
Yuri G is currently offline Yuri GFriend
Messages: 32
Registered: July 2009
Member
Hello, John!

I guess you need to add OCL constraints to each of node mappings for
FOLDER, so that GMF can choose the right type of node to display (I think
in your case at the moment it just peeks the first node mapping which
works for the FOLDER meta-element).

For the FOLDER only with TEXT_FILES it would be something like
'self.IMAGE_FILES->isEmpty()' and for the second node which has an image
compartment: 'self.IMAGE_FILES->notEmpty()'. Here I suggest that
IMAGE_FILES is a collection contained in the FOLDER.

John Yotka wrote:

> I need to display 2 different types of top level nodes for a given type
> of model element, where each type displays different relevant
> information about the model element. For example, suppose I have a
> model element type FOLDER that always contains TEXT_FILES, but sometimes
> (rarely) also contains IMAGE_FILES. I need one top level node type,
> which has a compartment showing the TEXT_FILES. And I also need a
> different top level node type, which has a compartment showing the
> IMAGE_FILES. When I create the two top level nodes in the .gmfmap file
> everything generates ok, that is there are 2 different editParts
> generated for the 2 different top nodes, but only one type of nodes
> (eg., TEXT_FILES) are displayed.

> Is this concept of multiple (different) Top Level Nodes for same model
> element type supported directly by GMF? Is there a way to modify the
> generated code to accomplish this? Thanks for any help in advance!
I suggest that you need to add OCL constraints
Re: 2 different top level node types from same model element type [message #229378 is a reply to message #228619] Mon, 11 May 2009 15:21 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello John,

Currently generated code is not able to show two different diagram nodes
for the same domain model element. By default each domain model element can
be represented by only one particular diagram node. If you need to display
two diagram nodes representing different aspects of same domain model then
you have to modify generated code. Common practice in GMF for such a use
cases is: use compartments to group child element of this domain model one,
so you can create two compartments first will list all the text files and
second – for image files.

-----------------
Alex Shatalin
Previous Topic:EMF file name
Next Topic:context menu item disabled
Goto Forum:
  


Current Time: Fri Nov 24 03:58:18 GMT 2017

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

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