Up Previous Next Title Page Index Contents

3.3.5 Replace Tool

The basic idea of Replace Tool (Figure 3-41) is to support re-use by enabling the user to replace certain object(s) in certain context(s), based on certain rules. This is useful for example when the user wants to create a new model by extending a copy of an existing model. Typically in this kind of situation, it is not possible to tell beforehand which parts of the model really needs to be copied and which parts are better to be left as references. The Replace functionality allows these decisions to be made later when the need for them occurs.

Figure 3-41. Replace Tool.

You can open the Replace Tool by choosing Replace... from an element’s popup menu. The ‘Replace’ section on the left side of the dialog shows a list of the element(s) selected to be replaced. The pop-up menu for this list allows you to add (Add Graph..., Add Object...) or remove (Remove) elements, see their properties (Properties...), open them (Open...) or open an Info Tool for them (Info...).

A set of radio buttons below the list is used to define the element(s) that will replace the selected graphs and objects. There are three options for replacing:
Object will replace all element(s) with one specified object.
 To add a new object to this field, choose New... from its pop-up menu. To add an existing object, choose Existing....
Copy to Depth will replace each element(s) with a copy of it to a certain depth.
Deep Copy will replace each element(s) with a deep copy (unrestricted depth).
The semantics of the first one are simple: the selected object will be replaced by another new or existing object as chosen by the user. Copy to Depth replaces with copies down to the level entered into the number field. Deep Copy makes full copies of the object and all its contents, i.e. works like Copy to Depth with an infinite level.

Each level indicates the objects and graphs directly referred to by the previous level. Level 1 would just copy an object and its simple properties (strings, numbers, texts, booleans), but no objects contained in its properties, nor its decomposition graph: the copy would point to the same elements as the original object does. Level 2 would copy the object and its simple properties as before, but also the objects directly contained in its properties and its decomposition graph – but not objects within those objects or that graph.

As an example, consider the scenarios presented in Figure 3-42. Originally we have A with element C and B with element D, both linking to E. The first scenario shows what happens when we replace D with copy to depth down to level 1. Scenario two shows the results of replacing D with copy down to level 2 (or in this case with deep copy as well).

Figure 3-42. Replace scenario 1 for level 1, and scenario 2 for level 2.

It is important to note that this is a replace operation, not just a copy operation. In scenario 1, the original D still exists somewhere, and still points to E. However, it is no longer part of this chain, since D was replaced with D’, and hence B now refers to D’.

The ‘In’ section on the right side of the Replace dialog is used to define the context that the replace will take place in. In our example scenario, this determines which objects will have their D replaced with D’, as happened to B. The context is specified as being a set of elements, and any elements reachable from them following certain navigation rules recursively.

The list in the ‘In’ section shows the root element from which the contextual navigation will start. The pop-up menu for this list allows you to add (Add Graph..., Add Object...) or remove (Remove) root elements, see their properties (Properties...), open them (Open...) or open an Info Tool for them (Info...). Below this list there are three check boxes that allow you to define the navigation rules to follow from the root elements:
Check Explosions to follow the explosion links.
Check Decompositions to follow the decomposition links.
Check Properties to follow properties linking to non-properties.
You can also define whether or not the copied sub-elements will be replaced as well by checking Replace copied subelements. In scenario 2 above, if there was an extra object F, that just pointed to E, this would determine whether F would change to point to E’.



Up Previous Next Title Page Index Contents