Selection

The Selection and SelectionPropagation properties control how a window behaves during selection.

Global Selection

Many commands require numerous model elements to be executed. A simple example is the command Delete from Model. A selection is normally made in a window to set this element set, e.g. in the model tree or in a diagram. Many windows can be open at the same time and these can all contain a selection of model elements. How do you know which of these element sets a ribbon command such as Delete from Model will have an effect on? There needs to be a mechanism which sets one of the selections as currently valid. This selection is marked as "global selection".

  • The status bar indicates the global selection.

  • Windows such as the Detail and in the Properties windows adjust their content to suit the global selection

  • Commands for model elements refer to the global selection.

Note

The rule that the active window provides the global selection applies.

Global selection is technically realized using the two IWorkArea properties Selection and SelectionPropagation.

Scenario 1 - Window with Element Selection

A window where model elements can be selected should treat the properties as follows:

  • SelectionPropagation should be set to SelectionType.ContextElement.

    (The ContextElement value tells the framework that model elements which present global selection can be selected in the window if the window is active.)

  • A private variable of the ElementSet type should be prepared for the Selection property; this is set using the setter and delivered using the getter.

    (If you jump to another active window, the framework automatically updates the global selection. It needs to retrieve the selection in the window which is now active. The Selection property is used for this.)

  • If the element selection is modified in the window, the Selection setter needs to transfer the new selection to the private variable. The WorkArea.TransferSelection static method then needs to be called.

    (The framework needs to be informed if selection is changed in the active window so that the global selection can be adapted accordingly. The TransferSelection method is called for this.)

Note

See the MID.Innovator.Plugin.Sample.Selection1 sample for creating a window with element selection.

Scenario 2 - Window with a Dependency on the Selection

Windows such as the Detail and in the Properties windows adjust their content to suit the global selection. A window of the same type is implemented as follows:

  • SelectionPropagation should be set to SelectionType.None.

    (The None value informs the framework that no model elements can be selected in the window which means it has no effect on the global selection.)

  • The Selection getter delivers null and the setter has no action.

  • A SelectionChanged message should be processed in the MessageHandler method in such a way that the global selection updates the window contents accordingly.

    (The SelectionChanged message is generated by the framework upon changes made to the global selection and sent to all windows.)

Note

See the MID.Innovator.Plugin.Sample.Selection2 sample for generating a window with a dependency on the selection.

Scenario 3 - Window with no Selection Reference

A few windows e.g. the Info area do not simulate the selection and are not dependent on it. A window of the same type is implemented as follows:

  • SelectionPropagation should be set to SelectionType.None.

  • The Selection getter delivers null and the setter has no action.

Note

See the MID.Innovator.Plugin.Sample.HelloToolWindow sample for creating a window with no selection reference.