How to set properties of an object automatically when it is created in the diagram? [message #758877] |
Thu, 24 November 2011 16:54  |
Eclipse User |
|
|
|
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 08:28   |
Eclipse User |
|
|
|
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 #765789 is a reply to message #759118] |
Wed, 14 December 2011 12:29  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04915 seconds