StudioWorks Cheat Sheet

This cheat sheet is a list of generic instructions to follow for creating a new servertable and window in a sub-library of a StudioWorks based application.

You should print this cheat sheet and folow it as a guide to assist you as you go through the Contacts tutorial.

This cheat sheet uses the sub-library name, SUBLIB, and the servertable name, TABLE. Replace the word SUBLIB with the name of the sub-library you are working with. Replace the word TABLE with the name of the servertable you are working with.

When we refer to an edit window, it means a window used for editing and inserting records.

Model

The model maps our application to the database.

  1. SQL Assist > Create/Alter > right-click on SUBLIB select Create New Schema...

  2. Enter TABLE in the prompt. The schema class sTable is created with the basic set of columns.

  3. Add columns to the sTable schema class. Set No nulls to kTrue for columns which you do not want to allow NULL values.

  4. SQL Asssit > @TAGs. Add the @HID, @LST, @PRMPT, @SRT, @FK, @IX, @UIX tags as applicable.

    • @LST tagged columns show up in autoconfig headed lists.

    • @SRT tags affect default sorting of the $get... series table class methods.

    • @HID tag columns are removed from the prompted Find window.

    • @IX and @UIX tags affect the SQL statements which create the servertable.

    • See StudioTips > StudioWorks > Lists > @TAGs for more information.

  5. SQL Assist > Create/Alter > right-click on sTable select Prepare Table and Index Statements.

  6. Right-click on the SQL Statement select Execute SQL and Index Statements to create the TABLE servertable in the database and add the indexes.

  7. SQL Assist > Query Builder. If the servertable is joined to other servertables create the list and edit query class views of the data. (qTableList, qTableEdit) You will likely not need to create query classes for a servertable that does not contain any foreign keys.

View

The view displays the data to the user and allows the user to edit/insert data.

If the edit view has quite a number of fields or needs special event handling create an edit subwindow. Otherwise we can ask StudioWorks to use wDataEntry_autoconfig subwindow which adds the entry fields on-the-fly. (@FLD tags can be used in the schema class columns to control entry field properties set by wDataEntry_autoconfig.)

  1. F3 Component Store. Select wWCO_abstract, or if there will be any type-ahead lookup entry fields, wWCO_abstract_FieldHandler. Drag the window class into SUBLIB and name it wTableEdit.

  2. Window Builder select the edit view query class or sTable schema class and drag the applicable columns to wTABLEEdit window class.

  3. Position and size the entry fields on the window. Remember to set the F6 $order property if you change the order of any fields.

  4. Set field properties and add $event method handling to any fields you like. Remember to end any $event code with Quit event handler (Pass to next handler) or the StudioWorks field handler will be skipped.

Controller

The controller is responsible for menus, toolbars, and subwindows. The controller is the coordinator/boss/manager of the window instance.

The window class wShell_Commands in your main library can be the controller for edit and list view window instances. You could create your own special controller, either from scratch or as a subclass of wShell or wShell_Commands. For some window instances you might not need a shell controller window. (e.g. wAbout is a simple display window that is simply opened its own "shell".)

  1. oWindowsList - If you haven't already done so copy and paste the $WindowsList and an add... private method from the superclass to the subclass. Decide on the MainMenuGroupID and MainMenuItemID that you will use for the TABLE edit and list view window instances. Modify the $WindowsList method to call the addTABLEs private method.

  2. Modify the addTABLEs method to suit your requirements. In this method you normally you add a WinInstID for BeginMode=list, and a WinInstID for BeginMode=edit.

    The list mode WinInstID normally uses:
    IconName: TABLE
    SQL Class: qTABLEList or sTable
    Shell: irShellCommands
    Subwindow: irSubWinList

    The edit mode window normally uses:
    IconName: TABLE
    SQL Class: qTABLEEdit or sTable
    Shell: irShellCommands
    Subwindow:

    If you created a wTABLEEdit window class, you would:

    Do fn.$findClassRef('wTABLEEdit',$cclass) Returns rSubwin

    and use rSubWin for the subwindow parameter.

    Otherwise use irSubWinEdit which is pointed to wDataEntry_autoconfig.

    Note: You can name the WinInstID any name you like. I tend to use the servertable name appended with the mode name. (TABLE_edit, TABLE_list)

  3. The $edit and $new commands in wShell_Commands depend on @EDITWINID SQL class description tags. The @EDITWINID tag allows wShell_Commands to determine the WinInstID of the edit view when a request comes through to switch from list view to edit view.

  4. F2 > select sTable. Set the Description property to include:
    `@EDITWINID:TABLE_edit`@LISTWINID:TABLE_list

String Tables & Icons

  1. sld_tbl - Add the TABLE servertable with the singular form name of the servertable in the Description column.

  2. sld_tblplural - Add the TABLE servertable with the plural form name of the servertable in the Description column.

  3. sld_mn - Add the MainMenuGroupID and the MainMenuItemID.

  4. sld_wn - Add TABLE_edit and TABLE_list. You can make the Description column values point to the tbl and tblplural string tables using the <stb> tags.

  5. sld_Icons - Add the MainMenuGroupID, MainMenuItemID, and the TABLE servertable. Enter the IconID values of your choice to the Description column.

  6. StudioTips String Table Editor - Create string tables for sTable, sld_tbl, sld_tblplural, sld_mn, sld_wn saving them in the programs/string_tables/mycontact folder.

Rebuild & Test

  1. Programmer Menu > Unload and Reload String Tables. (This also rebuilds the masterlists.)

  2. Open and test your new window instance. Insert a new record and save it. Then edit the record and save the changes.