There is a lot of different data formats today. For example J2EE framework descriptors, IDE plugin descriptors and XML based DSLs. Often they have no or have very unusable editors. It is possible to use MPS to transparently work with them. MPS supports loading models from different formats and saving models into different formats using a technique that we call a custom persistence.
All nodes in MPS when they are loaded in memory are stored within SModels. But because in a project there is often a lot of SModels visible from it and their loading is a rather expensive operation we use lazy initialization of SModels. To make lazy initialization more transparent we use SModelDescriptor class. It makes possible to know some important information about a model like its file name or timestamp, without loading, and it loads its model if required.
Model roots in MPS are similar to source roots in IDEA and other IDEs. A model root specifies a place where and how models are stored. Each module (i.e a language, a solution or a generator) has one or more model roots. You can add and remove model roots in a language/solution/generator properties dialog. When you add a model root, you should specify its directory and a model root manager for your model root. A directory specifies where the models under your root are stored. A model root manager is responsible for how they are stored. The default model root manager knows how to work with default mps models (.mps files) but you may want to create your own. If you want to work with your format in MPS you will have to create a new model root manager that will handle it.
If you want to create you own model root manager you have to implement jetbrains.mps.smodel.IModelRootManager interface or derive a class from a helper class jetbrains.mps.smodel.AbstractModelRootManager. This class has sensible defaults for most methods and we recommend to derive from AbstractModelRootManager when you want to create model root manager. The most important methods in AbstractModelRootManager are :
Often you want not only to load and save models but also to create new ones. To do so you have to override models creating related methods.
SModelRepository.getInstance().markChanged(modelDescriptor, true);
After you created a new model root manager, you want to use it. To do it, you need your model root manager class to be available in a MPS project classpath. You can set project classpath in a project settings dialog. After that, you'll be able to see your model root manager in a completion menu in model root's inspector. You need to install MPS plugin for doing this, so this menu works only when you have a running IDEA.