Dialog Wizard

The Merriam Webster dictionary defines dialogueor dialog as "a conversation between two or morepersons; also: a similar exchange between a personand something else (as a computer)." It is in thissecond context that this article will delve further and describea new BASIS tool that allows for the creation of the programthat manages a dialog between a user and a computer.

The new Dialog Wizard, accessible from the IDE, is a modernand powerful alternative to AppBuilder. Its key advantageover AppBuilder is that it generates fully object-oriented BBjprograms from a resource file, automatically generating thecallbacks and the method stubs. But, quite interestingly, it alsopreserves custom editing of the resultant BBj code, allowingyou to run a second or third pass of the code generator toleverage any changes you may have made to your resourcefile. It also optionally generates the automatic tool buttonintegration to Barista. In addition, the Dialog Wizard gives youthe ability to automatically test the resultant code, offeringa launcher to launch a GUI or BUI version of your code.And, if that wasn’t enough, it also generates Javadoc-likedocumentation from comment lines in the code!

Let’s go through the steps and see just how quick it is to go from a resource file to a running program.

Resource File to a Running Dialog Program

After creating the resource file for a simple customermaintenance form, right-click on the resource name in theFilesystems navigation tree of the BASIS IDE and choose"Run Dialog Wizard" as shown in Figure 1.

The Dialog Wizard launches and offers a suggestion of theprogram path to the program that is to be generated as shownin Figure 2; choose among the top level window IDs to steerthis session of the wizard and then click [Next].

The Dialog Wizard’s second frame shown in Figure 3 lists thecontrol names derived from the controls in the resource fileand allows selection of the access scope of the member field,the variable name (or class member field) to be used in theprogram, the basic type of the variable, and a flag for whetherthe field is a required input. Click [Next].

This utility, as a minimum, requires a definition for the windowclose event, so select the control name that represents the toplevel window and either double-click on the “Close” event, orselect the “Close” event and click on the right arrow button toadd the Close event to the list of program events, as shown inFigure 4. Click [Next].

The last panel (Figure 5) offers some selectionsthat we’ll visit a little later. For now, skip those byclicking [Finish] to generate the BBj custom dialogclass program.

That’s all, in seconds the Wizardgenerates the requisite codeautomatically. Next, simply runthe program and a small selectiondialog then appears (Figure 6)offering choices to test the programin either GUI or BUI (Figure 7) or torerun the Wizard.

One thing to note is the Dialog Wizarddoes not use data files, per se, forsettings entered or chosen in thewizard for program generation. Theprogram code itself contains this data.Through the use of identifiable beginand end code-blocks, for example,rem /** DLGWIZ_DDX_BEGIN **/and its matching end-blockrem /** DLGWIZ_DDX_END **/,the wizard knows where to look forthis data and parses what it needsfrom the program code. Any codeoutside of these blocks is ignoredand will remain intact during theregeneration process.

Click [Finish] to regenerate the programautomatically. The code shown in Figure 9now contains method stubs for all of thetoolbuttons on the toolbar.

Next, we add a little bit of code shown inFigure 10 to the "Options" toolbuttonto enable and disable the four navigationbuttons when the "Options" button is clicked.

These two methods are available for enablingand disabling toolbar buttons in the dialogas well as the corresponding toolbar buttonand menu item, for running the dialog classin Barista.

The new code lives outside any Dialog Wizardbegin and end blocks, and is thereforepreserved betweenprogram generations. Ifwe now run our programin GUI, and click on the[Options] button, we willsee the record navigationbuttons toggle betweenan enabled and disabledstate. Additionally, if we runthis class inside of Barista(see Figure 11), we alsosee that the correspondingtoolbuttons and menuitems in the Barista MDI match the enabledstate of the navigation buttons on our form.

Summary

The new Dialog Wizard is great for rapidapplication development of your GUI apps,your BUI apps, and your custom dialogs thatmay not fit well into the core Barista datadictionary driven paradigm. You can createhand-crafted code and very easily plumb itinto Barista. The Dialog Wizard encouragesgood development practices, as it resultsin documented object oriented code. It isalso flexible enough to handle multipleexecutions against resource files thatchange over time as the program matures.See for yourself how helpful it can be onyour next coding project!

http://documentation.basis.com/advantage/v16-2012/12dialogwizard.pdf