3.3.5 Replace Tool
The basic idea of Replace Tool (Figure 3–44
) 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
Figure 3–44. 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:
will replace all element(s) with one specified
add a new object to this field, choose New... from its pop-up menu. To
add an existing object, choose
to Depth will replace each element(s) with a copy of it to a certain
Copy will replace each element(s) with a deep copy (unrestricted
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
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 subgraphs: 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 direct subgraph – but not objects within those objects or that
As an example, consider the scenarios presented in Figure 3–45
. 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–45. Replace scenario 1 for level 1, and scenario 2 for level 2.
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’.
behavior is provided to maintain shared properties correctly when copying.
During the replace operation, normal unshared properties will be created as new
copies like other elements, but shared properties will be left uncopied, with
new objects also sharing them, unless all objects sharing the property are being
copied, in which case a copy of the property will be made, and the new objects
will all share this copy.
subgraphs are always taken into account. An explosion subgraph link is only
valid in the context of a particular graph, so explosion subgraphs of the
selected object are only taken into account when the operation is invoked on
that object in the context of a graph, e.g. in the main pane of an Editor.
Explosion subgraphs are always taken into account deeper within a copy, e.g.
when the depth of a copy takes it to a graph and an exploded element within that
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(s) 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:
Explosions to follow the explosion
Decompositions to follow the decomposition
Properties to follow properties linking to
You can also define whether
or not the copied sub-elements will be replaced as well by checking Replace
. In scenario 2 above, if there was an extra object F,
reachable with the ‘In’ settings and that just pointed to E, this
would determine whether F would change to point to