Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to make a node pre-displayed inside another node
how to make a node pre-displayed inside another node [message #485937] Tue, 15 September 2009 14:58 Go to next message
Eclipse UserFriend
Originally posted by: yuzhanghan.hotmail.com

Could anybody tell me how to realize the following:

Given that both Node A and Node B possess independent classes in the
ecore, and Node B is defined to be drawn inside of Node A (conpartment
defined). Then how to realize that when one draws a Node A in the editor,
Node B's figure shound exist inside Node A's, there's no need to draw Node
B separately.

Thanks a lot!
Re: how to make a node pre-displayed inside another node [message #486001 is a reply to message #485937] Tue, 15 September 2009 20:58 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Yuzhang,

Create feature sequence initializers for node A creating node B automatically.

-----------------
Alex Shatalin
Re: how to make a node pre-displayed inside another node [message #486191 is a reply to message #486001] Wed, 16 September 2009 16:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yuzhanghan.hotmail.com

Alex Shatalin wrote:

> Hello Yuzhang,

> Create feature sequence initializers for node A creating node B
automatically.

> -----------------
> Alex Shatalin

Hi, Alex,
your soloution works. But I have other problems following. Now I wanna
generate Node A, at the same time Node B and Node C generated inside Node
A automatically. Both Node B and C have aggregation from A. I made two
Reference New Element Specs for Node B and C respectively, but only Node B
got generated along with Node A, not Node C. (FYI Node A B C can be
generated correcly manually)

I paste the relevant part of my .gmfmap. Could you give some hints? Thanks
a lot!

... ...
<ownedChild> // from Top Node Reference of Node A
<domainMetaElement
href="dmiwf.ecore#//ProcessingElement"/> //Node A
<domainInitializer
xsi:type="gmfmap:FeatureSeqInitializer">
<initializers //Reference New Element Spec for Node B
xsi:type="gmfmap:ReferenceNewElementSpec">
<feature
xsi:type="ecore:EReference"
href="dmiwf.ecore#//ProcessingElement/inputs"/>
<newElementInitializers>
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
xsi:type="ecore:EReference"
href="dmiwf.ecore#//Inputs/items"/>
<value
body="0"
language="java"/>
</initializers>
</newElementInitializers>
</initializers>
<initializers //Reference New Element Spec for Node C
xsi:type="gmfmap:ReferenceNewElementSpec">
<feature
xsi:type="ecore:EReference"
href="dmiwf.ecore#//ProcessingElement/outputs"/>
<newElementInitializers>
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
xsi:type="ecore:EReference"
href="dmiwf.ecore#//Outputs/items"/>
<value
body="0"
language="java"/>
</initializers>
</newElementInitializers>
</initializers>
</domainInitializer>
... ...
Re: how to make a node pre-displayed inside another node [message #486227 is a reply to message #486191] Wed, 16 September 2009 19:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.sascha.gessler.googlemail.com

Yuzhang Han wrote:


>> Create feature sequence initializers for node A creating node B
> automatically.

good way to go. If you want to take full control of the creation /
configuration of elements you can configure an AdviceBinding. For more
information and some examples, see:

Eclipse Help contents > GMF Developer Guide > Programmer's Guide > Runtime
> Extensible Type Registry > "Binding Advice to an Existing Element Type"


For example you could overwrite
"getAfterConfigureCommand(ConfigureRequest)". This way you get a hook to
provide a more complex configuration. For example you could easily
instantiate an element B when the configuration of A is requested. This
again results in an configure request after B has been created, and so on
...


A good example for an advice binding is the class
"NotationViewDependentsAdvice".


Cheers,

sas
Re: how to make a node pre-displayed inside another node [message #486343 is a reply to message #486191] Thu, 17 September 2009 11:23 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Yuzhang,

I've tried same code with latest GMF sources and looks like it is working
for ecore diagram. Here is a part of .gmfmap file I added to make it working
with ecore diagram:

<domainInitializer
xsi:type="gmfmap:FeatureSeqInitializer">
<initializers
xsi:type="gmfmap:ReferenceNewElementSpec">
<feature
xsi:type="ecore:EReference"
href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EP ackage/eClassifiers "/>
<newElementInitializers>
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
xsi:type="ecore:EAttribute"
href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EN amedElement/name "/>
<value
body="'class1'"/>
</initializers>
<elementClass
href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EC lass "/>
</newElementInitializers>
</initializers>
<initializers
xsi:type="gmfmap:ReferenceNewElementSpec">
<feature
xsi:type="ecore:EReference"
href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EP ackage/eSubpackages "/>
<newElementInitializers>
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
xsi:type="ecore:EAttribute"
href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EN amedElement/name "/>
<value
body="'pkg2'"/>
</initializers>
<elementClass
href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EP ackage "/>
</newElementInitializers>
</initializers>
</domainInitializer>

The only difference with your .gmfmap file i can see here is:
<elementClass href=" ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EP ackage "/>
attribute...

-----------------
Alex Shatalin
Re: how to make a node pre-displayed inside another node [message #486812 is a reply to message #486343] Sat, 19 September 2009 13:13 Go to previous messageGo to next message
Yuzhang Han is currently offline Yuzhang HanFriend
Messages: 19
Registered: September 2009
Junior Member
this solution has worked. Thanks man.
I find out that my fault was not having used OCL expressions correctly
Re: how to make a node pre-displayed inside another node [message #487593 is a reply to message #486343] Wed, 23 September 2009 16:47 Go to previous messageGo to next message
Yuzhang Han is currently offline Yuzhang HanFriend
Messages: 19
Registered: September 2009
Junior Member
Hi, thanx man,
another question follows up:
given that NodeA contains NodeB and NodeC, when NodeA is created, NodeB and NodeC are AUTOMATICALLY generated inside of NodeA. A XY-layout of NodeA is used so that NodeB and C can be movable and resizeable.

The question is, how do I set the default size and position of NodeB and NodeC when NodeA is created? I would want NodeB and C to be created on customized positions and size.

Thank you!
Re: how to make a node pre-displayed inside another node [message #488174 is a reply to message #487593] Fri, 25 September 2009 18:29 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Yuzhang,

Looks like you have to modify CreationEditPolicy used to create NodeA to
properly set layout constraints for NodeB/C inside a command returned from
getCreateCommand() method. Another option is to modify ???CanonicalEditPolicy
for NodeA to properly set locations for newly created child nodes (I think
NodeB/C notation elements will be created by this EditPolicy).

-----------------
Alex Shatalin
Re: how to make a node pre-displayed inside another node [message #499591 is a reply to message #488174] Mon, 23 November 2009 12:45 Go to previous message
nguyen  is currently offline nguyen Friend
Messages: 1
Registered: November 2009
Junior Member
Hi, Can you more tell about , or give a example
thanks a lot
Previous Topic:Enabling/disabling palette item
Next Topic:Two diagram editors on same model: Exception when creating diagram
Goto Forum:
  


Current Time: Fri Apr 26 10:00:49 GMT 2024

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

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

Back to the top