The pattern author can add one
or more patterns to the pattern library. A pattern can only be distributed
with its library in a pattern plug-in.
Before you begin
Before you can perform these steps,
you must create a pattern library.
About this task
The New Pattern wizard enables you
to define the properties for the pattern and add all of its template
parameters. After the pattern is added to the library, you can modify
the pattern's properties and add, redefine, or remove its parameters.
Many of the steps are optional. You can create a simple pattern by
accepting all of the defaults.
To add a pattern and its parameters
to the pattern library:
Procedure
- In the Pattern Authoring view, right-click
the library node and click New Pattern. The New Pattern window opens.
- Define the basic pattern properties by completing the following
steps:
- Type a name for the pattern in the Pattern
Name field. This is the name that will be listed
in the Pattern Explorer view to identify the pattern.
- Accept the generated class and package names as generated
from the pattern name or modify them in the Class Name and the Package fields.
- From the Pattern Type list, select
the type of pattern (Class, Collaboration, or Package) you are creating.
- On the General page, in the Target Types field, select the type for your pattern
(Package, Collaboration, or Class).
- Click the Add button next to
the Groups field to open the Add
Group window and add group names to the pattern. Patterns must be assigned to at least one group and can be assigned
to multiple groups. All patterns are listed in groups in the Pattern Explorer view. The default group, Miscellaneous
Patterns, can be deleted.
- In the Version field, modify
the version number. The number must
be in a major.minor.service format where major, minor and service
are integers. Any profiles associated with the pattern library will
have its types available at this point as well. For example, if there
are two stereotypes and one enumeration defined in a UML profile associated
with the pattern library those types will be a valid choice when picking
the parameter type here.
- Click the Detail tab to open
the Detail page of the New Pattern wizard.
- Type your name in the Author field.
- Type a brief pattern synopsis in the Short
Description field. This short description
is displayed on the Short Description page of
the Pattern Explorer view.
- Click the Add button next to
the Keywords field and add keywords for the
pattern. Add keywords that a pattern applier would use
to find a match to your specific pattern. The metafiles in the pattern
are also searched for matches so you do not need to duplicate any
of the contents of such properties as descriptions or names. The client
parameter is the dependent parameter and the supplier parameter is
also referred to as the dependency parameter. The supplier parameter
notifies the client parameter when its values change at runtime.
- Add parameters by doing the following
steps:
- Click the General tab to return
to the General page of the New Pattern wizard.
- Click the Add button next
to the Parameters field to display the General page of the New Pattern Parameter wizard. You can always add or modify parameters after
you finish using the wizard.
- Type a name for the parameter in the Name field. The class name is automatically derived
from the parameter name.
- Accept the class name as generated or modify it in the Class Name field.
- Type a short description of the parameter that can assist
the pattern applier to specify arguments for the pattern. This description is displayed on the Short Description page of the Pattern Explorer view and as hover
help when the pattern applier hovers over the template parameter in
the diagram editor.
- In the Type field, accept the
default UML type of Class for the parameter's type or click Browse and select another UML type.
- If the Allowable Subtypes field
is enabled, accept the default, to have all subtypes available to
the pattern applier as possible kinds of arguments, or click Browse, to select a limited set of subtypes.
- Accept or clear the Allow text entry
of argument value check box that permits specifying or
creating arguments by typing an argument name.
Note: For
parameters that you create with multiple subtype options, the subtype
that is created from the pattern applier's text entry is controlled
by the code you supply in the parameter's update method. If you do
not supply this code, a default subtype from your allowable subtypes
list is selected.
- If you are adding the pattern's first parameter or do
not want to add a parameter dependency, go to step 3.k. To add a dependency, click the Parameter Dependency tab.
- On the Parameter Dependency page,
in the Existing Parameters field, click one
or more parameter names and then click the right-arrow button to position
the parameter names in the Client Parameters field or the Supplier Parameters field. When you assign another parameter as a client or supplier parameter,
it dynamically adds the reciprocal assignment to the parameter you
are adding. Thus, moving an existing parameter into the Supplier Parameters field assigns the role of client
to the parameter you are adding.
- Click OK to return to
the New Pattern wizard.
- To add additional parameters, repeat steps 3.b through 3.k.
- Click OK to close the New Pattern wizard and complete the addition of the pattern.
Results
The new pattern is added as a node to the pattern library
in the
Pattern Authoring view and the supporting
RAS metafile for the pattern asset and the Java classes for both the pattern and each parameter are created.