Altova UModel 2024 Enterprise Edition

How to Create and Use Hyperlinks

Home Prev Top Next

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

 

IUMLNamedElements:

 

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)

 

Examples

Insert a hyperlink to the Altova homepage:

 

IUMLHyperlink2File iHyperlink = iMyClass.InsertOwnedHyperlink2FileAt(-1, "https://www.altova.com");

 

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)
  iHyperlink.OpenLink();

 

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

GuiTextHyperlinkCommentTextHyperlink

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, "https://www.altova.com");

 

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 );

© 2017-2023 Altova GmbH