Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: paradogma on February 21, 2005, 04:51:50 am
-
The GUI offers a menue-item (as icon) in the Toolbar "UML Elements" which allows to create a hyperlink to an external file (e.g. on a webserver) on a diagram.
When I go through the repository, using the automation interface, I can find these hyperlinks in the collections of Elements of the corresponding package. I can find them in the collection of DiagramObjects of the corresponding diagram, too. When I check the Element.Type it says "Text".
I want to create such hyperlinks by a script via the automation interface.
But simply creating "Text" elements (diagramObjects) doesn't do the job.
What kind of object do I have to create?
And how can I set the URL it points to ("Hyperlink Address" in the GUI)?
How can I set the displayed text ("Alias" in the GUI)?
Does anybody know?
Thanks
-
It's a two part process: first add an new object of type EA.Element to a package's Elements collection; then add a new object of type EA.DiagramObject to a diagram's DiagramObjects collection to display it on the diagram.
It looks like you should be setting Element.Type = "Text" and Element.Subtype = 19. Also, set Element.Name to the hyperlink address and Element.Alias to the display text.
If you need any more help, please ask :)
-
Thank you for your reply. And yes, I do have more questions.
I was aware of the fact that it is a two step process. This is what I did:
I created an EA.Element by
( 'pkg' is the EA.package in which the EA.diagram resides)
Dim eleLink As EA.Element
Set eleLink = pkg.Elements.AddNew("http://localhost/htdocs/test.html", "Text")
eleLink.Subtype = 19 '// this was not done in the first attempt
eleLink.Alias = "-->>"
And I created an EA.Diagram.DiagramObject by
( 'dia' is my diagram )
Dim dioL As EA.DiagramObject
Set dioL = dia.DiagramObjects.AddNew ("l=100;r=20;t=10;b=18, "Text")
dioL.ElementID = eleLink.ElementID
dioL.DiagramID = dia.DiagramID
After that I ".reloadDiagram" and a diagram object shows up at the specified position. It also has the name I gave it (can check that in the GUI).
However it does not look like an external hyperlink. It does not show any text at all. Neither does it show the icon for a link.
It is simply an empty rectangle of the specified dimension with a dashed border.
When I use the context-menue (right mouse click) on that diagram object and select "Text Properties" I only get a text field with the caption "Notes".
When I use the same context-menue on a manually created external hyperlink, I get a more elaborated dialog box, that allows me to edit the Hyperlink Address as well as the Alias and whether to display the Icon or not.
So obviously I am NOT creating the right type of object by my script.
What am I doing wrong?
Thank you in advance
-
You probably need to do eleLink.Update and dioL.Update to fix the changes, and I'm not sure if you need anything in the parameters for Diag.DiagramObjects.AddNew("",""). I got the following to work:
Set eleLink = Pkg.Elements.AddNew("http://www.sparxsystems.com.au/", "Text")
eleLink.Subtype = 19
eleLink.Alias = "Sparx Systems"
eleLink.Update
Set dioL = Diag.DiagramObjects.AddNew("", "")
dioL.ElementID = eleLink.ElementID
dioL.DiagramID = Diag.DiagramID
dioL.Update
-
Thank you! "eleLink.Update" did the trick!
I did the .update only on the DiagramObject but missed to do it for the Element, too.
May I bother you with more questions on hyperlinks?
- Is it possible, to use relative addressing for a hyperlink?
(like "../../someFolder/someFile.htm")
Currently I can only get results, when using absolute addressing like
("http://www.someDomain/someFolder/someFile.htm") or ("file://C:/someFolder/someFile.htm")
Actually, I like to refer to a file that resides in a folder relative to the folder, where the model-file (*.ea) is.
- Is it possible, to include a "Subaddress", i.e. an "Anchor", into the hyperlink reference?
Like "www.someUrl#someAnchorInTheTargetFile".
Currently, a hyperlink that works with a simple URL, will not work, when I append an achor (by separating it with '#').
Any chance?
Thank you