简体   繁体   English

在元素注释中添加超链接Enterprise Architect

[英]Adding hyperlinks in element notes Enterprise Architect

I am working on Enterprise Architect C# add-ins. 我正在研究Enterprise Architect C#加载项。 I am trying to add hyperlink to another package in element notes through add-ins as shown below: 我试图通过加载项将超链接添加到元素注释中的另一个包,如下所示:

包超链接

I found the code for adding hyperlink in element to package here : https://www.sparxsystems.com/forums/smf/index.php?topic=4068.0 and tried the following code: 我在以下位置找到了用于在元素中添加超链接的代码以打包: https : //www.sparxsystems.com/forums/smf/index.php?topic=4068.0并尝试了以下代码:

                    EA.Package parentPkg = Session.Repository.GetPackageByID(currentPackage.ParentID);//target package
                    hyperlink = currentPackage.Elements.AddNew("$package://"+parentPkg.PackageGUID, "Text"); //adding hyperlink
                    hyperlink.Update();
                    hyperlink.Subtype = 19; 
                    hyperlink.Update();
                    hyperlink.Notes = parentPkg.Name;
                    hyperlink.Update();
                    demoElement.Notes = "test for packages hyperlinks" + hyperlink; //demo element's notes must contain hyperlink to target package
                    mobjElement.Update();

It is not displayed as hyperlink here but as System.__ComObject. 它不是在此处显示为超链接,而是在System .__ ComObject中显示。 Kindly help. 请帮助。 Thanks in advance. 提前致谢。

I tried (as Geert suggested) the following code snippet (sorry for the Perl): 我尝试了(如Geert所建议的)以下代码片段(对Perl感到抱歉):

my $e = $rep->getElementByGuid("{92EF2B52-B75E-454d-AD03-5BDC12256A36}");
$e->{notes} = "<a href=\"\$package://{81657422-5D41-4dbf-9210-461DF67FD2C2}\"><font color=\"#0000ff\"><u>Link name</u></font></a>";
$e->Update();

Just replace the GUID and the display name and you have a hyperlink to a package. 只需替换GUID和显示名称,您就可以找到程序包的超链接。 Note that the above string has some escape chars, so here's the raw text: 注意上面的字符串有一些转义字符,所以这是原始文本:

<a href="$package://{81657422-5D41-4dbf-9210-461DF67FD2C2}"><font color="#0000ff"><u>Link name</u></font></a>

As Geert and Thomas Suggested if you just need to make hyperlink in notes just add a herf tag ti that word like below 正如Geert和Thomas所建议的,如果您只需要在笔记中建立超链接,只需在该单词上添加一个shef标签即可,如下所示

This is a <a href="$element://{64162D99-026B-40b3-914C-2CC009943540}"><font
     color="#0000ff"><u>Hyperlink</u></font> </a> Example

and the output in notes will be like 注释中的输出将像

在此处输入图片说明

In API you can just add the link text in notes property of any class. 在API中,您只需在任何类的notes属性中添加链接文本即可。

switch ( treeSelectedType )
    {
        case otElement :
        {
            // Code for when an element is selected
            var theElement as EA.Element;
            theElement = Repository.GetTreeSelectedObject();
            theElement.Notes="This is a <a href=\"$element://{700ED461-FAC6-4097-AFF5-5F4787AD99CB}\"><font color=\"#0000ff\"><u>Hyperlink</u></font></a>  Example";
            theElement.Update();
            theElement.Refresh();



            break;
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM