Child pages
  • Custom Persistence Cookbook

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The xmlPersistence module implements the persistence logic. The persistence type in MPS is set on the per-model level. In our simplified case, the sample can store a model, which is restricted to a single single XMLFile root  root element of the the jetbrains.mps.core.xml language, into plain XML documents. The actual

The actual XML parsing logic resides in the the XmlConverter class, while the the XmlModelPersistence class implements the essential interfaces for hooking into the internal workings of MPS.

Image Removed
The getFormatTitle() method is worth a special mention here, since the string it returns will be used to represent the storage format to the future users.

Additionally, the getFileExtension() method will register our custom persistence for .xml files.You need to implement the method #getPreferredDataSourceTypes() which returns the data source types which this model factory associates itself with. We have several bundled data source types in the PreinstalledDataSourceTypes class.

If one does not introduce new types of data sources then he could return just the data source types of the bundled data sources. Otherwise he needs to provide the data source type of his specific data source.

Also it is absolutely important for each ModelFactory implementor to provide the identifier of the implementing factory. That means that one needs to implement the ModelFactory#getType() method.

The purpose of this method is to make each ModelFactory replacable (anyone can register a model factory with the same id thus effectively replacing the persistence format logic).

Plugin ID

Also notice that the module has a Plugin ID set in the Idea Plugin tab of its module properties:

...