【问题标题】:Tagged value validation through C# add-ins in Enterprise Architect通过 Enterprise Architect 中的 C# 插件进行标记值验证
【发布时间】:2016-11-09 12:19:01
【问题描述】:

我正在编写一个 C# Add-in Enterprise Architect 来验证标记值,因为当我使用 Type=Integer 的标记值时,标记值空间中会出现一个默认值 0。 我已经给出了 Type=String 的标记值并验证了用户输入的值。我正在使用以下代码。

    public bool EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {


                string test_value;
                bool isInteger;
                int integer_converted;
                if (ot == EA.ObjectType.otElement)
                {

                        EA.Element element = (EA.Element)Repository.GetElementByGuid(GUID);
                        EA.TaggedValue tag = element.TaggedValues.GetByName("MAX-BASE-TYPE-SIZE");
                        test_value = tag.Value;
                        if (string.IsNullOrEmpty(test_value))
                        {
                            Session.Repository.WriteOutput("EA", "Enter any Value", 1);
                        }
                        else
                        {
                            isInteger = int.TryParse(test_value, out integer_converted);
                            if (isInteger == false)
                            {

                                string empty = " ";
                                tag.Value = empty;
                                tag.Update();
                                Session.Repository.WriteOutput("EA", "Enter Integer Value" + " " + tag.Name + ":" + "", 1);
                            }
                        }
                    }

                }
            }


            return true; 
}

问题是,只有当我关闭元素属性窗口并重新打开元素时,才会用空字符串替换无效的标记值。

当我将光标移动到元素本身的下一个标记值而不是每次都关闭并重新打开元素时,如何查看使用空字符串更新的标记值。

请帮助。提前致谢。

【问题讨论】:

  • 如果您正在构建插件,为什么要坚持使用 EA 属性窗口..?构建一个您自己的简单表单,用于向元素添加标记值,以便您也可以轻松验证......!
  • 我需要为该元素设置 type=RefGUID ,RefGUIDList 的标记值,这就是我尝试验证这些值的原因
  • 您甚至可以在自定义窗口中获取所有这些值。?

标签: c# add-in enterprise-architect


【解决方案1】:

没有优雅的解决方案。您需要刷新模型视图并再次在浏览器中显示元素(伪代码):

repository.RefreshModelView(element.PackageID)
repository.ShowInProjectView(element)

【讨论】:

  • @Kilian 当我使用 RefreshModelView(element.PackageID) 时,EA 有时会停止工作。我厌倦了只使用 ShowInProjectView(element) 它仅在元素被拖放并停止更改时第一次工作下次标记值..请帮助..
  • 我得到一个窗口“Enterprise Architect-UML 开发工具已停止工作”弹出消息
  • 您使用的是 V13 吗?
  • 不,我使用的是 V12.1
  • 这些是相当基本的方法,不太可能怀疑它们不起作用。在这种情况下,我怀疑插件中存在编程错误。试试上面的评论。还可以在加载项的进入和退出时将调试打印打印到 EA 的控制台。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-20
  • 1970-01-01
相关资源
最近更新 更多