To exploit the message framework in RSE, you start by create an message file, named say mymessages.xml, which looks something like this:
<?xml version="1.0" encoding='UTF-8'?> <!-- This is a sample message file --> <MessageFile Version="1.0"> <Component Name="ACME Tools" Abbr="ACME"> <Subcomponent Name="General" Abbr="G"> <MessageList> <Message ID="1001" Indicator="E"> <LevelOne>You made a mistake</LevelOne> <LevelTwo>Fix your mistake, then re-attempt the operation.</LevelTwo> </Message> </MessageList> </Subcomponent> </Component> </MessageFile>
Typically, this file is created in plugin project's root folder.
The important elements in this file are:
Element | Description |
---|---|
MessageFile | The overall element for the file. There is only one of these tags. |
Component | Identifies a course-grained component within your plugin. You can specify multiple component tags. It is up to you to decide how many components to divide your plugin into. The abbreviation (Abbr) of the component constitutes the first part of the message ID for messages defined in this component, aiding in servicing when an error message is reported. |
Subcomponent | Identifies a fine-grained subcomponent within a component. The abbreviation (Abbr) of the subcomponent is appended to the component's abbreviation when the message ID is created for messages in this subcomponent. It is up to you to decide how many subcomponents to divide your component into, and what to name them. |
MessageList | Simply encapsulates the list of Message elements for this subcomponent. |
Message | Defines a message. The ID attribute can be anything you like, but following a naming or numbering convention is a good idea. The ID is appended to the component and subcomponent abbreviations to form the message ID the user will see. The Indicator attribute identifies the severity of the message: I for Information, E for Error, W for Warning, U for Unexpected, and Q for Question. This affects the icon that will be used for this message, and the buttons allowed on the message dialog. |
LevelOne | The first-level message the user will initially see. Use %n for substitution variables, where n is a positive integer incrementing up from 1. |
LevelTwo | The second-level help for the message, the user will only see if they ask to see it. Use %n for substitution variables. Any variable used here and in the LevelOne text will be consistently substituted with the same value. |
This is a bigger sample.