Consultor Eletrônico



Kbase 21183: How the Dynamic Toolbar Works & How To Customize It?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   04/02/2005
Status: Verified

GOAL:

How the Dynamic Toolbar Works & How To Customize It?

GOAL:

Supported way to customize the SmartToolBar

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x

FIX:

Dynamic Toolbar lends the developer the ability to manage transactions and navigation in the SmartDataObject (SDO) and the Smart Business Object (SBO).

The dynamic toolbar also manages TableIO behavior in visual SmartObjects such as the SmartDataViewer and SmartDataBrowse, as well as providing a feature to instantiate a SmartFilter.

Since the dynamic toolbar is a visual SmartObject, smart.p and visual.p are included in its super procedure stack. Since it is an extension of the panel class, panel.p is also loaded. The super procedures specific to the toolbar are action.p and toolbar.p. They are loaded when the dynamic toolbar is instantiated.

Here is the super procedure stack of the dynamic toolbar:

smart.p
visual.p
panel.p
action.p
toolbar.p
The master file dyntoolbar.w includes toolbar.i which executes toolbar.p and loads it as a super procedure. Toolbar.i includes action.i which executes action.p and loads it as a super procedure.

Customizing the SmartToolbar

When modifying the default behavior of the SmartToolbar Progress recommends doing so by copying dyntoolbar.w locally and adding actioncustom.p and toolbarcustom.p to the super procedure stack instead of actually changing the action.p and toolbar.p super procedures in the dlc directory.

Action.i, after running the action.p super procedure, includes src/adm2/custom/actioncustom.i. In the Main-Block of actioncustom.i the following line of code is commented out:

/*RUN start-super-proc ('adm2/custom/actioncustom.p':U).*/
By uncommenting this line and recompiling dyntoolbar.w, actioncustom.p will be loaded as it's super procedure.

Toolbar.i, after running the toolbar.p super procedure, includes src/adm2/custom/toolbarcustom.i. In the Main-Block of toolbarcustom.i the following line of code is commented out:

/*RUN start-super-proc ('adm2/custom/toolbarcustom.p':U).*/
By uncommenting this line and recompiling dyntoolbar.w, toolbarcustom.p will be loaded as it's super procedure.

In order to change the dynamic toolbar behavior without changing the Progress source files, the application directory should look like this:

MyApp
|__adm2
| |__dyntoolbar.w
| |__custom
| |__actioncustom.p
| |__toolbarcustom.p
|
|__src
|__adm2
|__custom
|__actioncustom.i
|__toolbarcustom.i
After making these changes, the super procedure stack of the dynamic toolbar will be:

smart.p
visual.p
panel.p
action.p
actioncustom.p
toolbar.p
toolbarcustom.p
As seen in the above list, the procedures in actioncustom.p and toolbarcustom.p will be executed before the procedures in action.p and toolbar.p.

Adding/Overriding Dynamic Toolbar Actions

The default actions for the dynamic toolbar like 'add' or 'update' records are defined in the initAction internal procedure in action.p. To add actions or override the default toolbar construction altogether, you should create an initAction internal procedure in actioncustom.p.

When adding new actions dynamic-function 'defineAction' should be used. The following is an example of how to use the defineAction dynamic-function in the initAction procedure in actioncustom.p:

PROCEDURE initAction:

DYNAMIC-FUNCTION('defineAction':U IN TARGET-PROCEDURE, INPUT "File":U,
INPUT "Name,Caption,Order":U,
INPUT "File" + CHR(1) + "File" + CHR(1) + "50").

DYNAMIC-FUNCTION('defineAction':U IN TARGET-PROCEDURE, INPUT "openFile",
. INPUT "Name,Caption,Type,onChoose,Parent,Order":U,
INPUT "openFile" + CHR(1) + /*Name */
"Open" + CHR(1) + /*Caption */
"RUN":U + CHR(1) + /*Type */
"":U + CHR(1) +
"File":U + CHR(1) + /*Parent */
"100").

DYNAMIC-FUNCTION('defineAction':U IN TARGET-PROCEDURE, INPUT "closeFile",
INPUT "Name,Caption,Type,onChoose,Parent,Order":U,
INPUT "closeFile" + CHR(1) + /*Name */
"Close" + CHR(1) + /*Caption */
"RUN":U + CHR(1) + /*Type */
"":U + CHR(1) +
"File":U + CHR(1) + /*Parent */
"100").

RUN SUPER.

END PROCEDURE.
This example shows that action attributes can be added dynamically. If the parent attribute is not set, this action will be a parent action and thus will appear as a top level menu in the menu bar.

So the 'File' action in the example above and the children actions will be sub-menu and/or menu items such as the 'openFile' and 'closeFile' actions in the example above.

At this time, actions are defined in the tAction temp-table, in order to add this functionality to the menu or as toolbar buttons the initializeMenu and initializeToolbar functions should be added to the toolbarcustom.p super procedure.

This example shows the initializeMenu override:

FUNCTION initializeMenu RETURNS LOGICAL:

DYNAMIC-FUNCTION('insertMenu':U IN TARGET-PROCEDURE, INPUT "",
INPUT "File,NAVIGATION",
INPUT no, /* Make this a sub-menu */
INPUT ?).

DYNAMIC-FUNCTION('insertMenu':U IN TARGET-PROCEDURE, INPUT "File",
INPUT "openFile,closeFile",
INPUT yes, /* Make these Menu-Items */
INPUT ?).

RETURN TRUE. /* Returning TRUE overrides default menu behavior */

END FUNCTION.
Next is an example of the initializeToolbar:

FUNCTION initializeToolbar RETURNS LOGICAL:

DYNAMIC-FUNCTION('createToolbar':U IN TARGET-PROCEDURE, INPUT "NAVIGATION").

END FUNCTION.
When adding actions as menus or buttons, if the name of a parent action is passed as parameter in the function the children actions will be added too. If you want to add just specific child actions, name them individually..

FIX:

References to Written Documentation:

Progress Solutions:

P8090, "How to add a new Button in a SmartToolbar"