Changed params to processPrefsTree    02 Jan 2002
Original    11 Dec 2001
Steve Meredith

How to Add a PrefsTree Pref Editor Widget to a CCK Wizard Page

Introduction

The Pref Editor is a widget for CCK/Factory, named PrefsTree in .ini files. It is a tree control which displays prefs in a hierarchy and allows a user to edit their values. It reads an XML file to determine the structure of the tree control. The details of the XML file format can be found in the document PrefsTreeFileFormat.htm. That document, together with this one, describe how to add a pref editor tree control to CCK.

Example

The easiest way to understand how to add a PrefsTree pref edit widget is to look at an example.

Screen shot example

The INI File

The .ini file used to insert this pref editor onto this widget page is as follows:

[Local Variables]
Name=PrefsTree
Title=Advanced Preferences
Caption=1st level node
Help=Online;%Root%Help\PrefsTree.html

[Navigation Controls]
onEnter=
onNext=
Help=

[Image 4200]
Type=Image
Name=prefstree.bmp
Value=
Start_x=0
Start_y=0
Width=425
Height=56

[Widget 4201]
Type=GlobalText
Name=Text4201
Value=Browse this tree to find other preferences that you want to customize. Double-click to edit.
Start_x=0
Start_y=32
Width=400
Height=30

[Widget 4202]
Type=PrefsTree
Name=AdvancedPrefs
Attrib=MetaPrefs.xml
Value=
Start_x=0
Start_y=45
Width=405
Height=181

Above is the section which defines the PrefsTree widget. The Name is important if you want to hook up the control to some buttons, as in our example. The Attrib specifies the name of the prefs XML file. This file belongs in the root with the .exe files. Once edited, a copy of the file gets saved in the working config directory. This is where install builder picks up its values. The Value is not used.

[Widget 4203]
Type=Button
Name=Button4203
Value=Open
Start_x=0
Start_y=232
Width=40
Height=14
onCommand=OpenPrefTreeItem(AdvancedPrefs)

Above is the section defining the "Open" button. When pressed, it calls OpenPrefTreeItem() for the PrefsTree widget named in the parameter. If a pref is selected, a dialog is open which allows the user to edit that text. If a group is selected, then that group is expanded or collapsed, depending on its current state. You can also use the right-button menu to open a pref for editing.

[Widget 4204]
Type=Button
Name=Button4204
Value=Find Pref
Start_x=50
Start_y=232
Width=40
Height=14
onCommand=FindPrefTreeItem(AdvancedPrefs)

Above is the section defining the "Find Pref" button. When pressed, it calls FindPrefTreeItem() for the PrefsTree widget named in the parameter. This function opens a find dialog which is used to find any text associated with a pref. It searches the pref name, its description, and its files for the text. You can also use the right-button menu to open the find dialog.

[Widget 4205]
Type=Button
Name=Button4205
Value=Find Next
Start_x=100
Start_y=232
Width=40
Height=14
onCommand=FindNextPrefTreeItem(AdvancedPrefs)

Above is the section to define the "Find Next" button. When pressed, if calls FindNextPefTreeItem() for the PrefsTree widget named in the parameter. This function selects the next pref which matches the last text search. It opens a find dialog if "Find Pref" was never used.

[Widget 4206]
Type=Button
Name=Button4206
Value=Add Pref
Start_x=150
Start_y=232
Width=40
Height=14
onCommand=AddPrefTreeItem(AdvancedPrefs)


Above is the section to define the "Add Pref" button. It calls AddPrefTreeItem() for the PrefsTree widget named in the parameter. This function opens the add dialog which prompts the user for the name and description of the new pref. It then open the edit dialog which allows the user to set the value of the new pref.

SCRIPT.IB

A SCRIPT.IB entry must be made in order for Install Builder process the .XML file: processPrefsTree(PrefFile.xml,browser.xpi,bin/netscp6.cfg). Spaces are not allowed between the parameters. The first parameter must be the name of the file as specified in the .ini file. The second param is the .xpi file that the preference file is in. The first paramater is the preferences file. If it ends with a .cfg, then it will be hashed.