Other windows need to be informed if model element properties are modified in a window so that they can adapt their contents accordingly.
Most windows do not merely show model elements; they also enable their changes. These changes normally affect both the window which the change was made in and the other windows as well. e.g. if the name of an open diagram is changed in the model tree, the text in the diagram's tab and the name field in the Properties area also need to be modified. This means that the window which changes to model elements were made in needs to inform the other windows about the action. The Refresh message can be used for this.
A Refresh message contains data of the RefreshWindowMessage type. The data contains information about the type of refresh.
Mode from the RefreshMode type
Type of refresh
ElSet from the ElementSet type
Model elements affected by refresh
| Mode | Triggering Action | ElSet |
|---|---|---|
| Command | The Reload Contents command was triggered. | Empty set |
| Content1 |
Old window contents was made visible. |
Empty set |
| Add | Model elements were created or added. | Created elements |
| AddDiagramGraphic | Model elements were added to a diagram. | Added elements |
| Delete2 | Model elements were deleted. | Deleted elements |
| ChangeName | Changes to a name | Element affected |
| ChangeStereotype | Changes to stereotypes | Elements affected |
| ChangeStereoM2Attribute | Changes to properties | Elements affected |
| ChangeStereoProperty | Changes to stereotype properties | Elements affected |
| ChangeLabel | Changes to labels | Elements affected |
| ChangeSpecification | Changes to specification texts | Element affected |
| ChangePicture | Changes to an assigned picture | Element affected |
| ChangeOrder | Changes to the order of assigned elements | Element affected |
| ChangeImportedProfiles | Changes to imported profiles for packages | Packages affected |
| ChangeAccess | Changes to access rights | Elements affected |
| ChangeLock | Changes to locking state |
Elements affected; empty set when unlocking all elements |
1 A tool window does not get any Refresh messages if it is not visible. A flag saying that the window was not refreshed and that its contents is probably old is set instead. If the window is activated, a Refresh message with the Content mode is triggered. The tool window should then fully refresh its contents.
2 For RefreshMode.Delete mode please note that the deleted elements may be in the message's information but these are already deleted and no longer valid. No properties of these elements can be accessed. The element set can only be used to e.g. search for the elements affected in the window to decide whether the window is affected by the delete action.
See the MID.Innovator.Plugin.Sample.RefreshMessage sample for editing the Refresh message.
Server performance may be drastically reduced if you wrongly process Refresh messages. Please make sure you read the information in the Performance section.
You need to send Refresh messages to other windows if you make changes to model elements. Element modification is therefore normally carried out as follows:
The change is made in a window control or in a dialog and applied.
Applying sends the change to the server using a call of a respective method of the server API.
If the server reports an error this is shown in a message box. The window and/or dialog returns to the state it was in immediately prior to applying the changes once the message box has been closed. i.e. the control element still contains the modified data.
If the server returns a reply that the changes have been transferred with no errors, a Refresh message needs to be sent to all windows so they can update their contents if necessary by processing the Refresh message in their MessageHandler method.
Use the RefreshModel method for sending messages.
See the MID.Innovator.Plugin.Sample.RefreshModel sample for sending the Refresh message.
© 1986-2014 MID GmbH Nuremberg Germany. DIN EN 9001 certified. All rights reserved.