Exercise 2: Creating custom forms and writing scripts for shapefiles

Exercise 1: Creating a default configuration file for toolbars (tree inventory)Exercise 3: Deploying customization files

Creating a custom data entry form with data validation for a layer

Next, you will create a layer definition file by using the new layer definition file Form Wizard dialog box. Layer definition files provide a way to deliver customizations that are loaded with data.

This exercise introduces the basic techniques for creating custom forms and writing scripts to perform initialization and data validation for shapefiles. You will use the Trees shapefile, which is located in the Tutorial folder below the \\Program Files\ArcGIS\ArcPad\Developer\Samples\ folder.

Creating a layer definition file

Steps:
  1. Start ArcPad Studio. Click the New Layer Definition New Layer Definition button button on the toolbar.
  2. Navigate to the Tutorial folder and click the Trees.shp file located at \\Program Files\ArcGIS\ArcPad\Developer\Samples\Tutorial.
  3. Click the Open button. The Form Wizard dialog box appears to assist in quickly generating data entry forms. On the Layout tab, you can modify the form's properties such as the form size, the pages visible on the form, and the text and background properties. Select all the page check boxes so they will be visible. First, select the fields you want to display on the form. See the following screen shot:
    Screen shot showing the Form Wizard dialog box.
  4. Click the Fields tab. Select the ID, OWNER, COM_SPECIES, DBH, HEIGHT, and IDP check boxes to display on the form for the user to view. See the following screen shot:
    Screen shot showing the Form Wizard dialog box.
  5. Click the Controls tab to add the required controls and additional parameters to the controls on the form, since you require values to be entered properly when the feature attributes are being collected.
  6. Select the OWNER, COM_SPECIES, DBH, HEIGHT, and IDP check boxes.
  7. For the purpose of demonstrating how to make edits to the layer definition file, you will link the OWNER, COM_SPECIES, and IDP controls to an external database table for list values in a later step.

    In this example, you could have manually added list values to be used as parameters of the available OWNER choices. For example, you could list potential owners such as Diane, Craig, and Ben as possible selection values. These selection values can be added directly as parameters on the Form Wizard dialog box.

  8. You also require a numeric value for the Diameter at Breast Height (DBH) and HEIGHT attributes. The DBH for a tree's diameter measurement must have a defined minimum and maximum range. The city trees' range is between 6 to 36 inches (you will limit the selection to that range). Type 6 in the DBH Minimum field and 36 in the DBH Maximum field.
  9. The city trees' height range is around 15 to 100 feet. Type 15 in the HEIGHT Minimum field and 100 in the HEIGHT Maximum field.
  10. You will also change how a label is defined to make the presentation of field information more informative to the user. Click the ID field's label text box on the Form Wizard dialog box. Change the Label text value from Id to ID. Change Com_SPECIES to Species, and IDP to Problem. See the following screen shot:
    Screen shot showing the Form Wizard dialog box.
  11. Click OK on the Form Wizard dialog box to keep your changes. The result of your choices on the Form Wizard dialog box is shown in a tree view as a new layer definition file created with the <ArcPad> root element and the <LAYER> child element. See the following screen shot:
    Screen shot showing results in a tree view as a new layer definition file.
  12. Double-click <LAYER> in the tree view to set the layer definition file's properties.
  13. Type City Trees in the Name text box and click OK. The name attribute is added to the <LAYER> element in the tree view. See the following screen shot:
    Screen shot showing the <LAYER> element.
  14. Click the Save Save button button on the toolbar to save the layer definition file (save your file periodically when editing in case something unexpected occurs).

Modifying an Edit form generated from the Form Wizard dialog box

When a form has been created through the Form Wizard dialog box, changes can be made to the attributes and properties for that form.

Steps:
  1. Click the <EDITFORM> Trees element. The Trees Edit form appears.
  2. Click the Form menu and click Form Properties. See the following screen shot:
    Screen shot of the Form Properties option.
  3. The Form Properties dialog box appears after you select Form Properties on the preceding screen shot. This dialog box resembles the previous Form Wizard dialog box and you can make changes to the form's properties here. For example, previously you did not intend to make all of the pages visible on the Form Wizard dialog box. Therefore, to make the changes to display the pages you need, clear the Symbology Page and Attributes Page check boxes.
  4. Type City Trees in the Caption text box. See the following screen shot:
    Screen shot showing the Form Properties dialog box.
  5. Click OK. The form's title bar changes from Trees to City Trees.

Modifying the form's pages

Steps:
  1. On the form, click the Page menu and click Page Properties. The Page Properties dialog box appears. You will use this dialog box to gather information about the tree.
  2. Type Tree Information in the Caption text box. See the following screen shot:
    Screen shot showing the Page Properties dialog box.
  3. Click OK to close the Page Properties dialog box. The form looks like the following screen shot:
    Screen shot showing the City Trees form.
  4. The form has unused space at the bottom. You can modify the controls as you want; however, in this tutorial, resize the form by typing 80 in the Height text box (to change the height from 130 to 80).
  5. On the form, click the Form menu and click Form Properties. The Form Properties dialog box appears. See the following screen shot:
    Screen shot showing the Form Properties dialog box.
  6. Click OK to close the Form Properties dialog box. The form now looks like the following screen shot:
    Screen show showing the new form.
  7. Click OK to close the form.
  8. Click the Save Save button button on the toolbar to save your layer definition (Trees.apl) file.

Modifying an Edit form further from the Form Wizard dialog box

There may be times when you want to modify the form to a greater extent. You may want the value for a numerically bound control. For example, with the Tree ID, you may want to auto increment the record values as features are added to the map.

Steps:
  1. You will make a change to the Tree ID so the records automatically increment as records are added. Select the Tree ID edit control on the form. See the following screen shot:
    Screen shot showing the Tree ID edit control.
  2. Double-click the Tree ID edit control or click the Control menu, then click Control Properties to open the Control Properties dialog box. See the following screen sot:
    Screen shot showing the Control Properties dialog box.
  3. Click the Values tab and select the Auto Increment (Numeric bound fields only) check box. Leave the Increment Step text box set to 1 to allow records to increment sequentially (that is, 1, 2, 3, 4, and 5).
    In this tutorial, you want to use ComboBox controls instead of edit controls to provide a list of choices when there is a minimum amount of space available on the form. You will make changes to the OWNER, COM_SPECIES, and IDP controls to show a list of choices to the user in the drop-down list.
  4. You will now replace the three edit controls with ComboBox controls added earlier on the Form Wizard dialog box. Select the Owner field on the form (anchors shown). See the following screen shot:
    Screen shot showing the Delete Control option.
  5. Click theControl menu, then click Delete Control to remove the control. Once the Owner control field is deleted, do the same for the COM_SPECIE and IDP controls by selecting the Species and Problem control fields. With the controls deleted, the form looks like the following screen shot:
    Screen shot showing the form with deleted controls.
  6. You will now add new ComboBox controls to replace the deleted controls by clicking the Controls palette, then dragging a COMBOBOX control to where the previous Owner, Species, and Problem control fields were located on the form. See the following screen shot:
    Screen shot showing the COMBOBOX controls and the Controls palette.
  7. The Control Properties dialog box for the COMBOBOX control becomes visible after you drop the control on the page. Type cboOwner in the Name text box. Click the Field drop-down list and choose OWNER from the list. This links the Owner field to this combo box. You can manually resize and change the placement of a control on the form editor or on the Control Properties dialog box. Next, you will change the width and height properties.
  8. Type 84 in the Width field and 12 in the Height field to reflect the same size as the predefined control from the Form Wizard dialog box. You will manually align the X and Y placement options with the existing controls later. Leave the Control Properties dialog box open. See the following screen shot:
    Screen shot showing the Control Properties dialog box.

    Once you decide on the control location on the page, you can make changes to the control's attributes and properties to reflect what gets displayed in the combo box. For example, linking ownership information to a stand-alone data table that only contains owner information making it more efficient to update the stand-alone table when needed.

  9. With the Control Properties dialog box still open, click the Values tab, then click the table icon to browse for a .dbf file. You will use the Tree Ownership.dbf file located with the Tutorial data at \\Program Files\ArcGIS\ArcPad\Developer\Samples\Tutorial.
  10. Click the Values Field and the Text Field drop-down lists, and select OWNER from the Tree Ownership.dbf file.
  11. Select the Limit to list check box to ensure that users cannot add values to the table. Limit to list specifies if the text box portion of the combo box can accept text or not. See the following screen shot:
    Screen shot showing Control Properties dialog box.
  12. Click OK to maintain the External List Value choices for the cboOwner control.
  13. You are now back in the editor form. Move the added control to align with the other controls on the form. See the following screen shot:
    Screen shot showing aligning the added control with other controls.
  14. With the Tree Information page still open, add another ComboBox control by clicking the Controls palette (as you did with the cboOwner combo box), then dragging a COMBOBOX control to the location of the previous COM_SPECIE edit control.
  15. Type cboSpecies in the Name text box. Click the Field drop-down list and choose COM_SPECIE.
  16. Type 84 in the Width text box and 12 in the Height text box to reflect the same size as the predefined controls from the Form Wizard dialog box. You will manually align the X and Y placement options with the existing controls later. Leave the Control Properties dialog box open. See the following screen shot:
    Screen shot showing the Control Properties dialog box.

    With the Control Properties dialog box still open, you will link the cboSpecies control with the Tree Names.dbf file.

  17. Click the List Values tab, then the table icon to browse for a .dbf file. You will use the Tree Names.dbf file located with the Tutorial data at \\Program Files\ArcGIS\ArcPad\Developer\Samples\Tutorial.
  18. Click the Values Field and Text Field drop-down lists, and select COMMON_NAME from the Tree Names.dbf file.
  19. Select the Limit to list check box to ensure that users cannot add values to the table. Limit to list specifies if the text box portion of the combo box can accept text or not. See the following screen shot:
    Screen shot showing the Control Properties dialog box.
  20. Click OK to maintain the External List Values choices for the cboSpecies control.
  21. You are now back in the editor form. Move the added control to align with the other controls on the form. See the following screen shot:
    Screen shot showing aligning the added control with other controls.
  22. You will now add the final combo box control. Click the Control palette (as you did with the cboOwner and cboSpecies combo boxes) and drag a COMBOBOX control to the location of the previous IDP edit control. Type cboProblem in the Name text box. Click the Field drop-down list and select IDP.
  23. Type 84 in the Width field and 12 in the Height field to reflect the same size as the predefined controls from the Form Wizard dialog box. You will manually align the X and Y placement options with the existing controls later. Leave the Control Properties dialog box open. See the following screen shot:
    Screen shot showing the Control Properties dialog box.

    With the Control Properties dialog box still open, you will link the cboSpecies control with the IDP List.dbf file.

  24. Click the List Values tab and the table icon on the Control Properties dialog box to browse for a .dbf file. You will use the IDP List.dbf file located in the Tutorial data at \\Program Files\ArcGIS\ArcPad\Developer\Samples\Tutorial. Select the IDP_LIST.dbf file.
  25. Click the Values Field and Text Field drop-down lists, and select IDP_LIST from the IDP List.dbf file.
  26. Select the Limit to list check box to ensure that users cannot add values to the table. Limit to list specifies if the text box portion of the combo box can accept text or not. See the following screen shot:
    Screen shot showing the Control Properties dialog box.
  27. Click OK to maintain the External List Values choices for the cboProblem control, then click OK again to save changes to the City Trees Tree Information editor form.
  28. On the City Trees form, you can move the added cboProblem control (or any control) to align with the other controls on the form. You can select any control and move it when the control's anchors are visible. See the following screen shot:
    Screen shot showing aligning the added control with other controls.
  29. Click OK to close the City Trees form.

    In the final steps, you want to add a SYMBOLOGY element that contains a VALUMAPRENDER and SIMPLELABELRENDERER child element. These come from a layer definition file (.apl) that was pre-defined in another project. You want to use that same defined symbology for your Trees layer, as well as how the features are labeled on the map.

  30. Click the Open Tool Open Tool button button to open the Trees_OLD_Study.apl file located in the Tutorial folder, then navigate to the folder at \\Program Files\ArcGIS\ArcPad\Developer\Samples\Tutorial. With the Trees.apl and Trees_OLD_Study.apl files open, click the Window menu, then click Tile to view both files simultaneously. Click to expand the Trees_OLD_Study.apl <SYMBOLOGY> elements to see how it is defined. See the following screen shot:
    Screen shot showing the .apl files.
    In the next step, you will copy the <SYMBOLOGY> element from the Trees_OLD_Study.apl file to the Trees.apl file.
  31. Select the Trees_OLD_Study.apl window's title bar and copy the <SYMBOLOGY> element from the Trees_OLD_Study.apl file by right-clicking the <SYMBOLOGY> element, then selecting Copy. See the following screen shot:
    Screen shot showing the Copy function.
  32. Click the window's title bar to activate Trees.apl, right-click the <LAYER> element, then select Paste. The <SYMBOLOGY> element from the Trees_OLD_Study.apl file is now copied to the Trees.apl file.
  33. Close the Trees_OLD_Study.apl file.
  34. Click to expand the <SYMBOLOGY> element in the Trees.apl file. See the following screen shot:
    Screen shot showing the Trees.apl file.
    NoteNote:

    The EXACT tag continues on in the list. It is cut off in the screen shot.

  35. Click the Save Save button button on the toolbar to save the Trees layer definition file (Trees.apl). You are now ready to test and deliver your application to field personnel.

2/7/2013