首页 > 解决方案 > 如何为 Rhapsody 表生成自定义选择器?

问题描述

我正在为 IBM Rhapsody 表编写自定义选择器。选择器用于选择满足特定要求的块(代表功能)。我希望选择器只显示子目录中的选择树中的块,每次满意节省大约 10 次点击。

我已经找到了这个:https ://www.ibm.com/developerworks/community/forums/html/topic?id=46c45210-b12e-4779-aac5-4c22b04c69fb但它根本没有帮助,因为它没有告诉它是如何完成的。

这是选择器的当前代码片段:

public List<IRPModelElement> pick_3_UserDefinedImplementation(IRPModelElement cellElement, IRPModelElement oldValue){

IRPCollection refCollection = cellElement.getReferences();
IRPDependency dependency = null;
ArrayList<IRPModelElement>  elementList = new AayList<IRPModelElement>();

    for(int i = 1; i <= refCollection.getCount(); i++) 
    {
              if (refCollection.getItem(i) instanceof BLOCKCLASS)  
             { 
                IRPDependency depLink =  (IRPDependency)refCollection.getItem(i);
                elementList.add(depLink.getDependent());
             }
    }
    return elementList;
}

我找不到 Rhapsody 块的类(或 IRPMetaclass)。我确信有一种更聪明的方法可以实现我想要的。有人已经写过这样的选择器和/或可以帮助我吗?

标签: javapickerrhapsody

解决方案


Block 是基于 Class 的“新名词”刻板印象。

因此,您应该能够通过以下方式识别块:1) 获取所有类 2) 遍历类并调用方法 IRPModelElement.getUserDefinedMetaClass() 以查看它是否与 Block 匹配。


推荐阅读