Home » Modeling » GMF (Graphical Modeling Framework) » Two different containers for one type of nodes 
| Two different containers for one type of nodes [message #52064] | 
Wed, 20 September 2006 10:20   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi all, 
 
I am trying to be able to drag and drop various SubNodes (represented using  
1 class in my meta-model and 1 rectangle in my gmfgraph) into two different  
containers layed out (using a BorderLayout) into one single SuperNode (1  
class in my meta-model and 1 rectangle with 2 internal rectangles associated  
to 2 containers in my gmfgraph). 
 
The idea is to be able to have a SuperNode with various SubNodes placed on  
the left and right sides of the SuperNode. 
 
The problem is in the mapping!! I can't define two different compartment  
mappings using the same SubNode child; if I do so, whenever I drag & drop a  
SubNode into one of the compartments, another one appears also in the other  
compartment. 
 
I have tried to solve this problem creating different SubNode Rectangles  
(LeftSubNode and RightSubNode) in the gmfgraph and then associate them to  
the LeftCompartment and RightCompartment, respectively in the gmfmap. But it  
doesn't work either. 
 
The only solution seems to be changing the meta-model to add two different  
kinds of SubNodes (LeftSubNode and RightSubNode). But I don't want to do  
that since the SubNode domain concept should be unique in the meta-model  
(there is only one kind of SubNodes, independently of the fact that they  
appear graphically on the right or on the left side of the SuperNode). 
 
Any help? 
 
Thanks in advance !!! 
 
Best regards, 
 
Cristina
 |  
 |  
  |  
| Re: Two different containers for one type of nodes [message #52145 is a reply to message #52064] | 
Wed, 20 September 2006 11:21    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
 
If I understood you correctly, it should be enough to define different  
NodeMapping's for the same SubNode EClass but with different OCL constraints  
defining the relation between internal state of the SubNode and its  
compartment. 
 
As a side effect you will probably have to extend the SubNode class with  
some attributes capturing the compartment relation. But it seems to be  
reasonable in any case. In this case the command for drag & drop may just  
change internal state of the SubNode and diagram update should replace  
editparts for changed element types "for free". 
 
In the old gmf newsgroup I posted the modified Mindmap sample with 2 thread  
compartments in the border layout -- the left one was suited for threads  
with name.length() > 5 and the right for others. Unfortunately I can not  
find it now, but you may probably will have a better luck. 
 
Regards, 
Michael 
 
 
"Cristina" <Cristina.Vicente@upct.es> wrote in message  
news:eerinr$bpe$1@utils.eclipse.org... 
> Hi all, 
> 
> I am trying to be able to drag and drop various SubNodes (represented  
> using 1 class in my meta-model and 1 rectangle in my gmfgraph) into two  
> different containers layed out (using a BorderLayout) into one single  
> SuperNode (1 class in my meta-model and 1 rectangle with 2 internal  
> rectangles associated to 2 containers in my gmfgraph). 
> 
> The idea is to be able to have a SuperNode with various SubNodes placed on  
> the left and right sides of the SuperNode. 
> 
> The problem is in the mapping!! I can't define two different compartment  
> mappings using the same SubNode child; if I do so, whenever I drag & drop  
> a SubNode into one of the compartments, another one appears also in the  
> other compartment. 
> 
> I have tried to solve this problem creating different SubNode Rectangles  
> (LeftSubNode and RightSubNode) in the gmfgraph and then associate them to  
> the LeftCompartment and RightCompartment, respectively in the gmfmap. But  
> it doesn't work either. 
> 
> The only solution seems to be changing the meta-model to add two different  
> kinds of SubNodes (LeftSubNode and RightSubNode). But I don't want to do  
> that since the SubNode domain concept should be unique in the meta-model  
> (there is only one kind of SubNodes, independently of the fact that they  
> appear graphically on the right or on the left side of the SuperNode). 
> 
> Any help? 
> 
> Thanks in advance !!! 
> 
> Best regards, 
> 
> Cristina 
>
 |  
 |  
  |   |  
| Re: Two different containers for one type of nodes [message #52268 is a reply to message #52169] | 
Wed, 20 September 2006 12:25    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
 
What I meant is to define "fake" property in your semantic model (say attr  
boolean SubNode::isLeft). 
All of your domain code calling your semantic model will just ignore this  
property -- it will be just a hint (editable from the property sheet) to  
mark some particular subnode to prefer this or that side of the parent node. 
 
Then you will be able to define 2 compartment mappings with OCL constraint  
operation with the new isLeft property. You will also need to create feature  
initializers for both mappings that sets the isLeft according to the left or  
right compartment clicked by creation tool. Also you will be able to set the  
same Creation Tool for both mappings completely hiding the difference  
between "left" and "right" element types from diagram user. 
 
It is probably some kind of hack, but it is definitely simpler than writing  
a lot of custom code for disjoint compartments. 
Hope this helps. 
 
Michael. 
 
"Cristina" <Cristina.Vicente@upct.es> wrote in message  
news:eerouv$6ks$1@utils.eclipse.org... 
> Thank you for your fast answer, Michael. 
> 
> Probably I didn't explain the problem correctly, but the fact is that I  
> don't want my SubNodes to be different depending on the container they are  
> placed in (I think it's not an OCL constraining problem). 
> 
> I want all SubNodes to be SubNodes and nothing else... Putting them into  
> one compartment or into the other is just a graphical question regarding  
> the ease of SubNodes connectivy. 
> 
> For example, if I only allow SubNodes in the left side of SuperNodes, then  
> the problem is easily solved but then, to be able to connect SubNodes from  
> different SuperNodes, I need a long and complex line (see the Example  
> Figure1). 
> 
> I rather want to have something like the ExampleFigure2, i.e. only one  
> kind of SubNodes which can be dragged and dropped in any of the two  
> compartments (see ExampleFigure3). 
> Do you think that it is possible? 
> 
> Thanks in advance ;D 
> 
> All the best, 
> 
> Cristina 
> 
> 
> "Michael Golubev" <michael.golubev@borland.com> escribi
 |  
 |  
  |  
| Re: Two different containers for one type of nodes [message #52294 is a reply to message #52169] | 
Wed, 20 September 2006 12:48    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hello, 
 
Guess, there's no need to modify your domain model and to keep there  
information which compartment SubNode belongs to. 
 
>> > The problem is in the mapping!! I can't define two different  
>> > compartment 
>> > mappings using the same SubNode child; if I do so, whenever I drag &  
>> > drop 
>> > a SubNode into one of the compartments, another one appears also in the 
>> > other compartment. 
 
It's possible to define two (or more) compartments for same SubNode, the  
..gmfmap should look like 
NodeMapping SuperNode 
  ChildReference compartment=Left 
    ownedChild NodeMapping SubNode 
  ChildReference compartment=Right 
    referencedChild NodeMapping SubNode 
 
Note use of referencedChild instead of ownedChild in the second (and  
subsequent) child references. 
 
With this, you get exactly one SubNode concept, and we get to another part  
of the problem, subnodes being automatically added to all compartments. You  
can approach this problem either with keeping your diagram not automatically  
synchronized (GMFGen.GenDiagram#synchronized attribute), which means  
generated code won't try to add elements automatically; or you can keed  
whole diagram synchronized and fix canonical edit policy of the compartments  
only not to process domain notifications (ADD/SET) and not to add children.  
I'd recommend the former approach because it rarely makes sense to have  
synchronized diagrams anyway. 
 
BTW, thanks for good question and well-written posts. 
 
Artem 
 
"Cristina" <Cristina.Vicente@upct.es> wrote in message  
news:eerouv$6ks$1@utils.eclipse.org... 
> Thank you for your fast answer, Michael. 
> 
> Probably I didn't explain the problem correctly, but the fact is that I  
> don't want my SubNodes to be different depending on the container they are  
> placed in (I think it's not an OCL constraining problem). 
> 
> I want all SubNodes to be SubNodes and nothing else... Putting them into  
> one compartment or into the other is just a graphical question regarding  
> the ease of SubNodes connectivy. 
> 
> For example, if I only allow SubNodes in the left side of SuperNodes, then  
> the problem is easily solved but then, to be able to connect SubNodes from  
> different SuperNodes, I need a long and complex line (see the Example  
> Figure1). 
> 
> I rather want to have something like the ExampleFigure2, i.e. only one  
> kind of SubNodes which can be dragged and dropped in any of the two  
> compartments (see ExampleFigure3). 
> Do you think that it is possible? 
> 
> Thanks in advance ;D 
> 
> All the best, 
> 
> Cristina 
> 
> 
> "Michael Golubev" <michael.golubev@borland.com> escribi
 |  
 |  
  |   |   
Goto Forum:
 
 Current Time: Tue Nov 04 00:03:02 EST 2025 
 Powered by  FUDForum. Page generated in 0.07339 seconds  
 |