Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: 2ben7 on September 25, 2012, 11:33:28 pm
-
Hi,
this event works if Diagram is not still open. But how to i recognize a switching between different still opened diagrams ? I can`t find a suitable event.
thx
ben
-
EA_OnPostOpenDiagram will fire only when the diagram is opened.
If you are looking for an event that fires when switching between diagrams that were previously opened (lik eg clicking tabs) => there isn't one.
But maybe this helps: clicking on a diagram will fire EA_OnContextItemChanged - provided that diagram didn't already have the focus.
-
that would make it.... difficult.
Not suggest that there is nothing like this existing.
I have another idea: is it at least possible to get an event
of all opened diagrams, so i would iterate through all diagrams, if i
switch through still opened diagrams ?
-
OK if your diagram already contains at least one element that has compartments eg a class, document artifact, etc in fact most elements in EA) then you can use EA_QueryAvailableCompartments: this will get fired for each element on your diagram.
But *beware* this event is fired *a lot* especially when you drag eg a dialog across the diagram (it seems like every WM_PAINT causes it to fire).
So make sure that whatever you do takes as little time as possible (maybe implement a timer that triggers another event, and is reset on every call to EA_QueryAvailableCompartments)
hope this helps,
regards,
Paulus
-
i tried the event.
When i start EA 9.3 the event is called only once until the project is loaded.
But if i open several new not opened diagrams -> event not called
if i switch between the opened diagrams -> also not called
-
... that's odd: I create 2 new class diagrams and from the toolbar drop a new Class on each diagram.
Just to be sure i close both diagrams and reopen them. If i switch between both diagrams using tabs the event EA_QueryAvailableCompartments fires.
-
For an example of how EA_QueryAvailableCompartments can be used, see:
http://community.sparxsystems.com/resources/scripts/showing-classifier-notes-custom-compartment
Regarding your original question about an event for switching between diagram tabs, there is nothing at this time, but I believe there might be a new broadcast event being added soon in EA 10 that will be of help. Once EA 10 is out, check the release notes and help documentation for something like "EA_OnTabChanged". Hopefully should be in there.
No schedule for when EA 10 will be available as yet.
HTH.
-
yeah, but it was not called on switching.
Her is my usage:
public void EA_QueryAvailableCompartments(Repository repository)
{
// should be called on still opened (Diagram/Subdiagram) switch
}
-
I notice that you've declared the method as void (ie a Sub) whereas the Sparx help defines it should return a Variant (and the example is returning a String).
If EA is looking for a function EA_QueryAvailableCompartments returning a Variant/String it won't find it so change your code to (i hope i got the syntax right ;)):
public String EA_QueryAvailableCompartments(Repository repository)
{
return "";
}