ibm-doors - 使用模块填充列表并将其显示在 DOORS 的对话框中
问题描述
我需要一个用返回的模块名称填充对话框的 DXL 脚本。我在一个项目中有几个模块。
以下是我目前的进展。我的想法是将所有模块名称放在一个列表中,然后在对话框中显示该列表。
你能帮我写下'''fillModulelist()'''
// This DXL script iterates through all formal modules of the folder
DB dbMain = null
DBE dbeModuleList = null
DBE dbeExport = null
DBE dbeExportPath = null
Folder currFolder = null
string startFolder="/Project/Folder";
int moduleCount=0;
void forAllModulesInFolder(Folder f)
{
Item itemRef;
string shType;
string sItemNameFull;
string sItemName;
Module moduleReference;
for itemRef in f do
{
shType = type(itemRef);
print shType "\t";
sItemNameFull = fullName(itemRef);
print sItemNameFull "\t";
sItemName = name(itemRef);
print sItemName "\n";
if(shType=="Folder")
{
string selectedFolder = sItemNameFull;
Folder f = folder selectedFolder;
forAllModulesInFolder(f);
}
if(shType=="Formal")
{
moduleReference = read(sItemNameFull,false,true);
filtering off;
// do s.th. with the moduleReference
close(moduleReference);
moduleCount++;
}
}}
void fillModuleList()
{
//........... HELP NEEDED........
}
// Main-Method
void main(void)
{
string selectedFolder = startFolder;
Folder f = folder selectedFolder;
forAllModulesInFolder(f);
print "Affected Modules: " moduleCount "\n";
}
main();
提供的任何帮助我将不胜感激。
解决方案
由于模块列表用于向用户显示它(也许让他们从该列表中选择),因此最好显示模块的全名,因此我不会存储模块引用。当用户选择/双击模块时,您可以稍后打开模块(假设这是您想要的)。因此,我用 填充跳过列表sItemNameFull, sItemNameFull
,但如果它更适合您的脚本,您也可以用(在这种情况下moduleReference, sItemNameFull
使用create
而不是)填充它。createString
对脚本的更改标有//->>
和//<<-
// This DXL script iterates through all formal modules of the folder
DB dbMain = null
DBE dbeModuleList = null
DBE dbeExport = null
DBE dbeExportPath = null
Folder currFolder = null
string startFolder="/testtrunk";
int moduleCount=0;
//->>
Skip skModules = createString()
//<<-
void forAllModulesInFolder(Folder f)
{
Item itemRef;
string shType;
string sItemNameFull;
string sItemName;
Module moduleReference;
for itemRef in f do
{
shType = type(itemRef);
print shType "\t";
sItemNameFull = fullName(itemRef);
print sItemNameFull "\t";
sItemName = name(itemRef);
print sItemName "\n";
if(shType=="Folder")
{
string selectedFolder = sItemNameFull;
Folder f = folder selectedFolder;
forAllModulesInFolder(f);
}
if(shType=="Formal")
{
//->>
put (skModules, sItemNameFull, sItemNameFull)
//moduleReference = read(sItemNameFull,false,true);
//filtering off;
// do s.th. with the moduleReference
//close(moduleReference);
//<<-
moduleCount++;
}
}}
//->>
void fillModuleList(Skip skContent, DBE dbeList)
{
empty dbeList
int cnt=0
string sLine
for sLine in skContent do {
insert (dbeList, cnt, sLine)
cnt++
}
}
//<<-
//->>
void DoSomethingWithDoubleClickedModule (DBE x) {
string sModName = get(x)
print "doing something with " sModName "<---\n"
}
void canvasDummyCB( DBE dummy ) { }
void doNothing(DBE x) {}
void prepareGui()
{
const string sArEmpty[] = {}
dbMain = create ("mytitle", styleCentered)
DBE spaceLeft = canvas(dbMain, 0, 0, canvasDummyCB)
spaceLeft->"top"->"form"; spaceLeft->"left"->"form"
spaceLeft->"right"->"unattached"; spaceLeft->"bottom"->"unattached"
DBE spaceRight = canvas(dbMain, 0, 0, canvasDummyCB)
spaceRight->"top"->"form"; spaceRight->"right"->"form"
spaceRight->"left"->"unattached"; spaceRight->"bottom"->"unattached"
DBE dInfoTextLabel = label(dbMain, "choose a module")
dInfoTextLabel->"top"->"form"
dInfoTextLabel->"left"->"flush"->spaceLeft
dInfoTextLabel->"right"->"flush"->spaceRight
dbeModuleList = list( dbMain, "Modules", 200, 15, sArEmpty)
dbeModuleList->"top"->"flush"->dInfoTextLabel
dbeModuleList->"left"->"flush"->spaceLeft
dbeModuleList->"right"->"flush"->spaceRight
realize dbMain
set( dbeModuleList, doNothing, DoSomethingWithDoubleClickedModule)
}
//<<-
// Main-Method
void main(void)
{
//->>
prepareGui()
//<<-
string selectedFolder = startFolder;
Folder f = folder selectedFolder;
setempty(skModules)
forAllModulesInFolder(f);
//->>
fillModuleList (skModules, dbeModuleList)
//<<-
print "Affected Modules: " moduleCount "\n";
}
main();
推荐阅读
- sql - Oracle 12c - 过滤具有多个值的记录
- python - Django Post Request 返回 405 Method not allowed 错误
- laravel - Laravel 以巨大的延迟发送密码重置电子邮件
- java - 搜索3个元素是否出现在同一行
- haskell - How to find out if it's summer or winter time?
- ios - 尝试为新闻提要创建 timeAgo 函数,但它只显示“0 秒前”
- python - Python - 不确定如何将元组附加到字典值
- azure - 通过 HTTPS 将 Azure AppService 连接到 VM 上的应用程序
- c - 设置区域设置不起作用
- rest - 如何使用rest api写入firebase数据库?