-
Notifications
You must be signed in to change notification settings - Fork 6
Saving Plugin Data with Paratext Project Data
The plugin can save its data so that it is treated as part of the project data. The plugin's data will participate in the Paratext Send/Receive process. Reference Plugin F demonstrates this capability.
The plugin should have a control in Paratext derived from EmbeddedPluginControl. The plugin should register handlers for the following events:
- SaveRequested, so it can save its data when the user asks Paratext to do a Save
- WindowClosing, so it can save its data before closing
The plugin is responsible for tracking if it has made any changes to its data. The plugin is responsible to ask the user if they want to save any changes.
The IProject has a GetPluginData
method that is used to read previously saved data.
The IProject has a PutPluginData
method that is used to save data.
The IProject has a GetPluginDataModifiedTime
method that can be used to check the last time a particular item of plugin data was last changed (which could have happened either by running the plugin locally or as a result of getting new data using Send/Receive).
For plugin data savedin XML format, the plugin can implement 'MergeDataInfo' to return information that tells Paratext how to handle Send/Receive conflicts (when more than one user changes the plugin data). For non-XML data, the Send/Receive process keeps and discards differences on a line-by-line basis. If there is a collision on a line, the merged output will have both lines.
In order to save, the plugin must use a Write Lock to make sure it coordinates changes with Paratext. By getting the lock before reading the data, the plugin can ensure that it is notified if Paratext requests the lock when the data is about to be changed (as part of a Send/Receive).