Interface ModelRoot
-
public interface ModelRootRepresents a logically connected group of models that come from a related physical origin, such as a file or a directory. For implementation consider extendingjetbrains.mps.extapi.persistence.ModelRootBase,jetbrains.mps.extapi.persistence.FolderModelRootBaseorjetbrains.mps.extapi.persistence.FileBasedModelRoot. The model root MPS workflow is as follows: 1. ModelRoot is constructed; 2. The methodload(Memento)is called to fill theModelRootwith data. Note that any model root must be attached to a module during construction- See Also:
getModule()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleancanCreateModel(String modelName)Deprecated.we have aDataSourceFactory#create+ModelFactory.create(DataSource, SModelName, ModelLoadingOption...)to create a new model (from a new data source) having just a model name and a model root.booleancanCreateModels()Deprecated.use specific #canCreateModel(SModelName)SModelcreateModel(String modelName)Creates a new model with the given name.SModelgetModel(SModelId id)Iterable<SModel>getModels()SModulegetModule()The owning module which must be present as well.StringgetPresentation()A textual representation of the model root TODO what is the difference with theObject.toString()?? TODO very ambiguous in API: is it to be used in UI? somewhere else? TODO one needs to clarify or replace it with a prosy #getNameStringgetType()A customizable categorization identifier, such as JavaStubsvoidload(Memento memento)Allows the model root to read its previously saved configuration informationvoidsave(Memento memento)Gives the model root the opportunity to persist into the supplied memento whatever configuration information may be needed to restore the models in the future.
-
-
-
Method Detail
-
getType
String getType()
A customizable categorization identifier, such as JavaStubs
-
getPresentation
String getPresentation()
A textual representation of the model root TODO what is the difference with theObject.toString()?? TODO very ambiguous in API: is it to be used in UI? somewhere else? TODO one needs to clarify or replace it with a prosy #getName
-
getModule
SModule getModule()
The owning module which must be present as well. The module must be fixed for a model root and passed via constructor (TODO) obviously the returned module is the one which has this model root among itsSModule.getModelRoots()
-
getModel
@Nullable SModel getModel(@NotNull SModelId id)
- Returns:
- the model with a given id one-to-one relation is assumed
-
getModels
@NotNull Iterable<SModel> getModels()
- Returns:
- a sequence of the models under this model root.
Implementors must impose some order on the returned result, such that
two consequent invocations of this method return equal results.
Note that owning module also returns all the models (module is believed to be a model container)
SModule.getModels(), however it might contain the models which are not attached to the model roots as well (!)
-
canCreateModels
@Deprecated boolean canCreateModels()
Deprecated.use specific #canCreateModel(SModelName)There are model roots which are read-only and fix the result ofgetModels()right away from the construction FIXME it is strange to have two similar methods: we are better to merge this method into the methodcanCreateModel(java.lang.String).- Returns:
- whether this model root is read-only in the way described above
-
canCreateModel
boolean canCreateModel(@NotNull String modelName)
Deprecated.we have aDataSourceFactory#create+ModelFactory.create(DataSource, SModelName, ModelLoadingOption...)to create a new model (from a new data source) having just a model name and a model root. this method gives out an insufficient API -- it kind of implies that a model root has the only way to create a model given a name, however obviously it is not true in a current MPS setup. Semantics of this method (as for 3.5) is to create a new model via defaultDataSourceFactoryand defaultModelFactory. Not sure if it makes sense at all shaped like this. The signature needs to be extended with aModelFactoryparameter. The same applies to the #createModel as well. [AP]- Parameters:
modelName- -- the same as in thecreateModel(String)- Returns:
- whether a model with a name
modelNamecan be created under this model root.
-
createModel
@Nullable SModel createModel(@NotNull String modelName)
Creates a new model with the given name. The new model will be contained in this model root (methods #getModel, #getModels).- Parameters:
modelName- -- might fq name or just simple short model name. Up to implementor- See Also:
// * @deprecated // * @return null if failed, for instance returned false.
-
save
void save(@NotNull Memento memento)
Gives the model root the opportunity to persist into the supplied memento whatever configuration information may be needed to restore the models in the future.
-
-