Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to set properties of an object automatically when it is created in the diagram?
How to set properties of an object automatically when it is created in the diagram? [message #758877] Thu, 24 November 2011 21:54 Go to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi all,

I have this situation. When I select an object from the Palette, and add it into the diagram. I want to automatically set its properties. Which places can I look at to do that?

Specifically, I have a compartment as follow: Object A contains object B, object B contains object C, object C contains object D. Then when user selects object D and drop it into the diagram, I want to set its properties, as example: property fullPath = A.B.C

Besides that, I want to create some files in the folder structure. Where is the right place to do so?

Is it in the EditPart of the diagram?

Thanks,

Hoang
Re: How to set properties of an object automatically when it is created in the diagram? [message #758984 is a reply to message #758877] Fri, 25 November 2011 13:28 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 24/11/2011 22:54, Hoang wrote:
> Hi all,
>
> I have this situation. When I select an object from the Palette, and add
> it into the diagram. I want to automatically set its properties. Which
> places can I look at to do that?
>
> Specifically, I have a compartment as follow: Object A contains object
> B, object B contains object C, object C contains object D. Then when
> user selects object D and drop it into the diagram, I want to set its
> properties, as example: property fullPath = A.B.C

I think the best place to do so is the FeatureSeqInitializer on a
NodeMapping in gmfmap.
If this is not enough for you, have a look at the code that is generated
from the FeatureSeqInitializer, this will be an interesting entry point
to find out what you need to customization.

> > Besides that, I want to create some files in the folder structure. Where
> is the right place to do so?
> Is it in the EditPart of the diagram?

This could be a nice use-case for the DiagramEventBrocker. You can
listen to changes in your diagram and react to them without modifying
its code.

--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to set properties of an object automatically when it is created in the diagram? [message #759118 is a reply to message #758984] Sat, 26 November 2011 14:24 Go to previous messageGo to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi Mickael,

Thanks for the response, I have found a workaround for my issue. I will investigate further your approaches.
Re: How to set properties of an object automatically when it is created in the diagram? [message #765789 is a reply to message #759118] Wed, 14 December 2011 17:29 Go to previous message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi Mickael,

Thanks for the suggestion to use Feature Sequence Initializer. I have changed the customization code to use Feature Sequence Initializer.

If someone is interested in seeing the solution, it is as follows:
- Modify the .gmfmap to add Feature Seq Initializer
- Add Feature Value Spec and select the attribute that you are going to set
- Add the Value Expression as follows:

self.targetState.targetBehavior.targetService.name.concat('.').concat(self.targetState.targetBehavior.name).concat('.').concat(self.targetState.name).concat('.action')


- Notice that all the targetState, targetBehavior and targetState are just the inverse relationship to track the parent of the object that it is in. In this way, I have the reference to the parent object and can get its property Name.

If you are interested in seeing the full solution, you can see this commit
Previous Topic:How to create the FigureDescriptor for this final state figure with GMF Graph
Next Topic:[GMF] Create Undefined ??
Goto Forum:
  


Current Time: Wed Apr 24 15:51:29 GMT 2024

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

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

Back to the top