用模块填充列表并将其显示在 DOORS 的对话框中

Populate a list with Modules and display it in a Dialogbox in DOORS

我需要一个 DXL 脚本,用返回的模块名称填充对话框。我在一个项目中有几个模块。

以下是我目前的进度。我的想法是把所有的Module名称放在一个List中,然后在DialogBox中显示这个列表。

你能帮我写下 ´´´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();

如有任何帮助,我将不胜感激。

由于模块列表是用来展示给用户的(也许让他们从那个列表中select),最好显示模块的全名,所以我不会存储模块参考。您可以稍后在用户 selected/double 单击该模块时打开该模块(假设这就是您想要的)。因此,我用 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();