You represent "part of" relationships in G2 by:
![]() |
Objects with an icon representation might contain details on a subworkspace of the icon, as this figure shows:
![]() |
In most applications, you have numerous workspaces, which you organize hierarchically. To do this, you create a top-level workspace that contains navigation buttons, which display subworkspaces of the application when selected, as this figure shows:
![]() |
Creating Subobjects
You can create a subobject interactively in an individual instance of a class or in the class definition itself. In general, you should always create a subobject in the class definition rather than in the instance; otherwise, you will need to create a subobject each time you create a new instance.
To create an attribute of a class that contains an object:
In the Class-specific-attributes of a class definition, use the syntax is given by to specify that an attribute contains an instance of a class.
Attribute-initializations of the subclass.
The characteristics and behaviors of the resulting objects differ in important ways. For example, suppose you create a subobject and a subclass, each with the same set of attributes and methods. The difference between these objects is:
Some disadvantages of embedding sensors directly in the class definition are:
To create a subworkspace for an object:
Choose create subworkspace on an instance of a class
or
create by cloning action to clone the master object with the subworkspace.
To support hierarchical views in which objects on the subworkspace are connected to superior objects, you can use subworkspace connection posts, which are a connection between workspaces.
To create subworkspace connection posts:
Instance-configuration of the class follows:
declare properties as follows: subworkspace connection-posts
Stubs system attribute in the Attribute-initializations. Alternatively, interactively create a connection for the instance.
To create a subworkspace for an object:
Choose create subworkspace on an object.
or
Interactively create a master object with a subworkspace, then use the create by cloning action to clone the master programmatically.
To declare a subworkspace to be activatable:
Specify the Item-configuration of any object, or the Instance-configuration of any class, as follows:
declare properties as follows: activatable subworkspace
To activate and deactivate a subworkspace:
activate the subworkspace of and deactivate the subworkspace of actions.
Creating Workspace Hierarchies
You can create a workspace hierarchy to organize your application. A workspace hierarchy is a nested set of workspaces that allow navigation between the various parts of the application. Typically, you have a single top-level workspace per module, and you access the rest of the application from that top-level workspace.
To create a workspace hierarchy:
uilroot.kb from the /utils directory.
KB Workspace > New Object > uil-navigation-button-template to display a submenu of button classes.
uil-goto-workspace-button-template to create a button that displays a subworkspace.
uil-build mode, specify the Label attribute for the button.
The first time you select the button in any mode except
uil-build mode or administrator mode, UIL creates a subworkspace of the button object. Thereafter, selecting the button displays the subworkspace.
You do not typically name the subworkspaces; instead, you provide labels.
You typically provide close buttons (uil-hide button-template) and buttons that go to the superior workspace (uil-goto-superior-button-template) on subworkspaces of the hierarchy.
For more information on creating workspaces, see Organizing Workspaces within Modules.
Create Only One or Two Workspace Hierarchies
Create a minimum number of top-level workspaces. If possible, organize all workspaces in a module into a single hierarchy by providing access to private workspaces from the top-level public workspace. For example, you can use the subworkspace of the version information object, or some other item, as the home for private items. Restrict the item to prevent the user from moving it, deleting it, or accessing its subworkspace. Name as Few Workspaces as Possible
It is good practice to name only the top-level workspace, if at all. Name other workspaces only if they need to be quickly accessible via the Main Menu > Get Workspace menu choice. Keep in mind that naming too many workspaces quickly causes the Get Workspace selection menu to get unwieldy. Do Not Create a Large Number of Subworkspaces
You should not create an excessive number of subworkspaces or "go to subworkspace" buttons. Too many workspaces can hinder, rather than help, navigation. Also, too many buttons wastes memory. Identify the Top-Level Workspace
Put the module name and, optionally, version information on the top-level workspace. Use GFR's version information objects to store and present this information. Consider Creating a Top-Level Palette
If you are creating a toolkit with a limited set of items to clone, consider using the top-level workspace as a palette. Use GFR palette tools to create palette items.