Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: MalkContent on January 10, 2010, 07:02:05 am
-
Hi,
I am currently trying to get a self made diagram (done via diagram profile) to add an element to the repository when an instance of it is created.
Is there a possibility to make it happen via profile editing?
And if not:
-how do I create Elements in the Repository
-how do I add Elements to the Diagram
I honestly searched a lot for the element creation and adding to a diagram thing and I tried a few things, but so far no luck.
EA.Element doesn't seem to posess a visible creator so I guessed it only could be added by methods of the Repository.
And as for the adding it to the diagram part, I am guessing it's done via the elements taggedvalues attribute, but I am not sure and don't know how it would be done.
Help :(
-
Hi,
If I understand you correctly, when you create an instance in a diagram, you want to create the classifier also.
I think you'll need automation to do that. It will need to hook into the EA event model and use the creation event of the instance to trigger the creation of the classifier.
However, I would expect other issues - like what do you do with two (or more instances) of the same classifier?
HTH,
Paolo
-
I want to create an instance of a certain element when I create the instance of a specific diagram.
I already have the creation event of the diagram.
Problem is, I have no idea which methods of the repository to use to create a new instance of an element.
-
I want to create an instance of a certain element when I create the instance of a specific diagram.
I already have the creation event of the diagram.
Problem is, I have no idea which methods of the repository to use to create a new instance of an element.
Do you already know the classifier element that you are creating an instance of?
Paolo
-
I want to add a "ActivityInitial" with the stereotype "mofsdmStart".
It is part of a custom ToolBox I build.
I am not sure if this is what you mean :/
-
Then you'll have to first create the element itself, and then add it to the diagram.
To create the element get the owner element and do a addNew() to the collection of elements.
Give it the appropriate attribute values and don't forget to update. (you may have to update between setting creating the element and setting some of its attributes as well)
Then add a new go to the diagram and do addnew() to the diagramobjects collection.
again make sure to update the diagramobject after creating it. (maybe you need to update() the diagram as well, I'm not sure)
Geert
-
I just realized that the EA_OnPostNewDiagramm event doesn't occur after a Diagram has been created, but an object within a diagram, so I am now without a clue how to add standard elements to a diagram on it's creation.
:(
-
So is there no way to create a new element in the repository upon diagram creation? :(
-
I just realized that the EA_OnPostNewDiagramm event doesn't occur after a Diagram has been created, but an object within a diagram, so I am now without a clue how to add standard elements to a diagram on it's creation.
:(
That sounds like you are using EA_OnPostNewDiagramObject. EA_OnPostNewDiagram should do exactly what you want it to do. This is what the help claims:
EA_OnPostNewDiagram notifies Add-Ins that a new diagram has been created. It enables Add-Ins to modify the diagram upon creation.
If that isn't happening then please send in a bug report with a code sample. Thanks.
-
well seemingly this method doesn't exist OR I didn't find a way to get it called
here's my code example - c# in visual studio 2005 pe
public bool EA_OnPostNewDiagram(EA.Repository Repository, EA.EventProperties Info)
{
MessageBox.Show("diagram created!");
return true;
}
I created a variation of diagrams AND I tried to get it called like the EA_OnPostNewDiagramObject method would which I also didn't succeed in.
also the help contents only list an entry for EA_OnPostNewDiagram (Object) which - in the details - is then titled EA_OnPostNewDiagram and has a description which makes it pretty much sound like EA_OnPostNewDiagramObject:
Details
EA_OnPostNewDiagram notifies Add-Ins that a new object has been created on a diagram. It enables Add-Ins to modify the object upon creation.
This event occurs after a user has dragged a new object from the Enterprise Architect Project Browser or Resources window onto a diagram. The notification is provided immediately after the object is added to the diagram. Set Repository.SuppressEADialogs to true to suppress Enterprise Architect from showing its default dialogs.
Also look at EA_OnPreNewDiagram.
I am using EA v7.1 Academic.
-
I am using EA v7.1 Academic.
That might be your problem. Have you tried using the latest version?
Geert
-
EA_OnPostNewDiagramObject was added at version 7.1.833
-
that is my version exacly
but does this version already include EA_OnPostNewDiagram?
-
Ah sorry, I looked up the wrong event. No, EA_OnPostNewDiagram is new for EA 8.0...
-
hooray ^^