Chapter 9 Accessing objects using VBScript


Creating an Object Selection

Object Selection is a model object that is very useful to select other model objects in order to apply to them a specific treatment. You can for example add some objects to the Object Selection to move them to another package in a unique operation instead of repeating the same operation for each and every objects individually.

When dealing with a set of objects in the user interface, you use the Object Selection in VBScript.

You create the Object Selection from a model using the CreateSelection method: CreateSelection() As BaseObject.

Example

Set MySel = ActiveModel.CreateSelection

You can add objects individually by adding the required object to the Objects collection.

You use the Object Selection following method: Add(obj As BaseObject)

Example

Adding of an object named Publisher:

MySel.Objects.Add(Publisher)

You can add all objects of a given type by using the Object Selection following method: AddObjects(ByVal RootPackage As BaseObject, ByVal ClassType As Long, ByVal IncludeShortcuts As Boolean = 0, ByVal Recursive As Boolean = 0).

RootPackage is the package from which to add objects.

ClassType is the type of object to add.

IncludeShortcuts is the parameter to include shortcuts.

Recursive is the parameter to search in all the sub-packages.

Example

An adding of classes with no inclusion of shortcuts and no recursiveness into the sub-packages:

MySel.AddObjects(folder,cls_class)

You can remove objects from the current selection using the Object Selection following method: RemoveObjects(ByVal ClassType As Long, ByVal IncludeShortcuts As Boolean = -1)

Example

Withdrawal of all classes and shortcuts from the Object Selection:

MySel.RemoveObjects(cls_class, -1)

You can move objects of the current selection to a destination package using the Object Selection following method: MoveToPackage(ByVal TargetPackage As BaseObject)

Example

Move of objects of the selection to a destination package named Pack:

MySel.MoveToPackage Pack

You can copy objects of the current selection to a destination package using the Object Selection following method: CopyToPackage(ByVal TargetPackage As BaseObject)

Example

Copy of objects of the selection in a destination package named Pack:

MySel.CopyToPackage Pack

You can create an object selection and filter this selection using a stereotype. You have to use the following method: ShowObjectPicker(ByVal classNames As String, ByVal stereotypeFilter As String = "", ByVal dialogCaption As String = "") As BaseObject

Example

Opens a selection dialog box for selecting a business transaction:

If Not Fldr is Nothing then
         ' Create a selection object
         Set Sel = Mdl.CreateSelection
         If Not Sel is Nothing then
           'Show the object picker dialog for selecting a BT
            Set Impl = Sel.ShowObjectPicker ("Process", "BinaryCollaboration", "Select a Binary Collaboration Process")
            ' Retrieve the selection
            If not Impl is Nothing Then
               If Impl.IsKindOf(PDBPM.Cls_Process) and Impl.Stereotype = "BinaryCollaboration" then
                  Set Shct = Impl.CreateShortcut (Fldr)
                  If not Shct is Nothing Then
                     obj.Implementer = Shct
                        %Initialize% = True 
                  End If
               End If
             End If
         End If

 


Copyright (C) 2005. Sybase Inc. All rights reserved.