How to create and use Hyperlinks Print this Topic Previous Page Up One Level Next page

Home >  UModel Programmer's Reference > The UModel API > Overview > How to... >

How to create and use Hyperlinks

UModel allows hyperlinks between most modeling elements (except for lines) and:


any diagram in the current ump project
any element on a diagram
any element in the Model Tree
external documents, e.g. PDF, Excel or Word documents
web pages


See also: Hyperlinking modeling elements.


Hyperlinks are not part of the UML specification and the UModel API introduces the following interfaces for hyperlinks on




IUMLHyperlink is the common base interface and can be used to open links as well as to retrieve the default- and user-defined link name
IUMLHyperlink2File to handle external documents and web pages
IUMLHyperlink2GuiElement to handle any diagram in the current ump project or any element on a diagram
IUMLHyperlink2Model for hyperlinks to model elements (in the Model Tree)



Insert a hyperlink to the Altova homepage:


IUMLHyperlink2File iHyperlink = iMyClass.InsertOwnedHyperlink2FileAt(-1, "");


Insert a hyperlink to a diagram of the current ump project:


IUMLGuiDiagram iDiagram = ...;
IUMLHyperlink2GuiElement iHyperlink = iMyClass.InsertOwnedHyperlink2GuiElementAt(-1, iDiagram, null);


Insert a hyperlink to the representation of a class on a diagram:


IUMLGuiNodeLink iNodeLink = ...;
IUMLHyperlink2GuiElement iHyperlink = iMyClass.InsertOwnedHyperlink2GuiElementAt(-1, iNodeLink, null);


Insert a hyperlink to an attribute of a class on a diagram:


IUMLGuiNodeLink iNodeLink = ...;
IUMLProperty iAttribute = ...;
IUMLHyperlink2GuiElement iHyperlink = iMyClass.InsertOwnedHyperlink2GuiElementAt(-1, iNodeLink, iAttribute);


Insert a hyperlink to the same attribute (from above) in the Model Tree:


IUMLHyperlink2Model iHyperlink = iMyClass.InsertOwnedHyperlink2ModelAt(-1, iAttribute);


Open all hyperlinks of an IUMLNamedElement:


foreach (IUMLHyperlink iHyperlink in iMyClass.OwnedHyperlinks)


UModel also allows hyperlinks in notes (IUMLGuiNote) and comments (IUMLComment):


These are handled by IUMLGuiTextHyperlinks (respectively IUMLCommentTextHyperlinks) and the start- and end-character position of the hyperlink must be specified, e.g:


IUMLGuiDiagram iDiagram = ...;
IUMLGuiNote iNote = iDiagram.AddUMLGuiNote(200, 100);
iNote.NoteText = "This is my Altova link";
int nStart = iNote.NoteText.IndexOf("Altova");
int nEnd = nStart + "Altova".Length;
IUMLGuiTextHyperlink iHyperlink = iNote.InsertOwnedGuiTextHyperlinkAt(nStart, nEnd, "");


Similar for hyperlinks in comments:


IUMLComment iComment = ...;
IUMLClass iClass2 = ...;
iComment.Body = "This is my link to Class2";
int nStart = iComment.Body.IndexOf("Class2");
int nEnd = nStart + "Class2".Length;
IUMLCommentTextHyperlink iHyperlink = iComment.InsertOwnedCommentTextHyperlinkAt(nStart, nEnd, "");
iHyperlink.SetHyperlinkModelElementAddress( iClass2 );


© 2019 Altova GmbH