DOORS DXL Dialog Box
In this article we will discuss DOORS DXL Dialog box.
In IBM Rational DOORS DXL (DOORS eXtension Language), a dialog box is a graphical user interface element that allows users to input data and interact with a DXL script. A dialog box can be used to prompt the user for input, display messages or warnings, or provide status updates on the progress of a script.
Overall, using a dialog box in DOORS DXL can help make your scripts more user-friendly and interactive. By prompting the user for input and providing feedback on the progress of the script, you can create a more streamlined and efficient workflow.
Sample Dialog Box
Here is an example code to build a sample dialog box –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db1.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example DB simpleDB = create ("Traceability", styleCentered|styleStandard) show simpleDB
Dialog Box Element – DBE
You can create a frame with a dialog box element. In the following example, we have create a frame using frame() function –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db2.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example DB simpleDB = create ("Traceability", styleCentered|styleStandard) DBE dbe = frame (simpleDB, "Traceability Analysis", 400, 150) separator (simpleDB) show simpleDB
Dialog Box Element – field() and date()
In this example, we have shown how to use field() and date() DBE –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db3.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example DB simpleDB = create ("Traceability", styleCentered|styleStandard) DBE dbe = frame (simpleDB, "Traceability Analysis", 400, 150) DBE dbe2 = field (simpleDB, "Requirement ID: ", "REQ-1", 30, false) DBE dbe3 = date (simpleDB, 40, today, true) separator (simpleDB) show simpleDB
Here is the output –
Dialog Box Element – text box
A text box DBE can be created in DXL –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db4.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example DB simpleDB = create ("Traceability", styleCentered|styleStandard) //DBE dbe = frame (simpleDB, "Traceability Analysis", 400, 150) DBE dbe2 = field (simpleDB, "Requirement ID: ", "REQ-1", 30, false) DBE dbe3 = date (simpleDB, 40, today, true) DBE dbe1 = text (simpleDB, "Requirement Text:", "", 350, 120, false) separator (simpleDB) show simpleDB
Sample Dialog Box
Here is a small sample dialog box that has different types of DBE –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db5.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example DB simpleDB = create "Create Module" DBE dbe1 = field (simpleDB, "Module Name: ", "", 30, false) DBE dbe2 = field (simpleDB, "Description: ", "", 30, false) DBE dbe3 = field (simpleDB, "Prefix: ", "", 30, false) show simpleDB
Dialog Box Element – radioBox() and checkBox()
You can create radio button, drop down list, check box using DXL DBE –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db6.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example string req_status[] = {"Pending", "In-Progress", "Completed"} string test_status[] = {"Pending", "In-Progress", "Completed"} DB simpleDB = create "Req Status" DBE dbe1 = choice (simpleDB, "Req Status ", req_status, 3, 2, 20, true) DBE dbe2 = radioBox (simpleDB, "Test Status ", test_status, 2) DBE dbe3 = checkBox (simpleDB, "Test Script Status ", test_status, 2) DBE dbe4 = toggle (simpleDB, "Export Status", true) show simpleDB
Sample GUI
Here is an example that contains different types of DBE – field(), radioBox(), choice() etc –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db7.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example string link_types[] = {"oneToMany", "manyToMany", "manyToOne"} string mod_types[] = {"Formal", "Link", "Descriptive"} DB simpleDB = create "Req Status" DBE dbe1 = field (simpleDB, "Module Name: ", "", 30, false) DBE dbe2 = field (simpleDB, "Description: ", "", 30, false) DBE dbe3 = field (simpleDB, "Prefix: ", "", 30, false) DBE dbe4 = radioBox (simpleDB, "Module Type", mod_types, 2) DBE dbe5 = choice (simpleDB, "Link Type ", link_types, 3, 2, 20, true) show simpleDB
Here is the output –
Dialog Box Element – Buttons
We can create buttons in DXL using button() function –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db8.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example void btnCallback(DBE dbe) { print "create button clicked\n" } void standardCallback(DB db) { print "Apply button clicked\n" //hide db } void dbClose(DB db) { release db hide db destroy db db = null halt } // Main Code string link_types[] = {"oneToMany", "manyToMany", "manyToOne"} string mod_types[] = {"Formal", "Link", "Descriptive"} DB simpleDB = create "Req Status" DBE dbe1 = field (simpleDB, "Module Name: ", "", 30, false) DBE dbe2 = field (simpleDB, "Description: ", "", 30, false) DBE dbe3 = field (simpleDB, "Prefix: ", "", 30, false) DBE dbe4 = radioBox (simpleDB, "Module Type", mod_types, 2) DBE dbe5 = choice (simpleDB, "Link Type ", link_types, 3, 2, 20, true) // callback DBE dbe6 = button (simpleDB, "Create", btnCallback) apply (simpleDB, standardCallback) close (simpleDB, true, dbClose) show simpleDB
Here is the output –
When the user clicks on ‘Create’ or ‘Apply’ button, a callback function is called and the respective message is printed on the DXL output window. For large complex dxl program, the callback function would include the behaviour of the button.
DXL – Message Box
There are different types of message box that can be used in DXL program – infoBox, warningBox etc –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db9.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example infoBox "This is a sample infoBox" warningBox "This is a sample warningBox" errorBox "This is a sample errorBox"
Here is the output –
DXL – confirm & messageBox
In the following example, we have demonstrated how to use confirm() and messageBox() –
// www.TheCloudStrap.Com /************************************************************************ * $FILENAME: db10.dxl * $DESCRIPTION: Dialog Box example * * NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved. * Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities. * * Contact: admin {at} TheCloudStrap.com ************************************************************************/ // Dialog Box example bool test_result = confirm ("Test Failed; Do you want to continue?", msgWarning) if (test_result) { string str_options[] = {"Yes", "No", "Cancel"} int option_sel = messageBox ("Save changes before closing the module?", str_options, msgQuery) if (option_sel == 0) print "Saving changes!\n" if (option_sel == 1) print "Closing!\n" if (option_sel == 2) print "Cancel!\n" } else { infoBox "You cancelled the operation" }
Conclusion
In this article we have explained how to create DOORS dialog box and dialog box element and create Graphical user interface.
This post was published by Admin.
Email: admin@TheCloudStrap.Com