Custom models / modules for RCP

Hi all,

I'm looking for a way to add custom information to modules and models my language users interact with.

When users of my RCP interact, they should not have to think in "modules" and "models". Instead, I want them to interact with customized versions of both modules and models. Similarly as we have "Solution" and "Language" as customized modules in MPS or "structure"-, and "editor"-aspects as customized models.

I can see different ways on how to implement that, but I wonder if there are recommendations, best practices, or some documentation someone could point me to (didn't find much myself).

Best case scenario from my current point of view would be there to be some API that allows me to "annotate" models and modules with additional information (e.g. some payload or something) which allows me to make the necessary distinction in the RCP UI. I would really like to avoid having to implement my own SModules and SModels, since I believe that would also require to add some custom persistency logic to persist my customizations.



1 comment

So, regarding models, I found the ModelWithAttributes interface which seems to meet my requirements.

Regarding modules, I tried to (mis-?)use facets in order to provide my own module kinds. Never used facets before, not sure if they are meant to be used in a way like this, but maybe someone can share some knowledge on facets and how one would provide their own facet to a module programmatically?

Amongst other things, I tried somethjing like this:

solution solutionNew = this.proj.addSolution(NAME_SOLUTION); 
SolutionDescriptor moduleDescriptor = solutionNew.getModuleDescriptor();
moduleDescriptor.addFacetDescriptor(new MyFacet("facet.type"));

This results in:

ins.mps.project.AbstractModule - no registered factory for a facet with type=`facet.type'

Is there a hook to register a factory for my facet?

I tried adding something like:

FacetsFacade facetsFacade = FacetsFacade.getInstance(); 
if (facetsFacade.getFacetFactory("facet.type") == null) {
facetsFacade.addFactory("facet.type", new FacetsFacade.FacetFactory() {
public SModuleFacet create() {
return new MyFacet("facet.type");

This results in this exception, which tells me that I cannot use this API in the context of an Action:

jetbrains.mps.classloading.ModuleClassLoader$ModuleClassLoaderIsDisposedException: ClassLoader of the module 'bla.bla.bla.pluginsolution [solution]' is disposed and not operable!
at jetbrains.mps.classloading.ModuleClassLoader.checkNotDisposed(
at jetbrains.mps.classloading.ModuleClassLoader.loadClass(
at jetbrains.mps.classloading.ModuleClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at bla.bla.bla.pluginsolution.plugin.CreateNewSolution_Action$1.create(
at jetbrains.mps.project.AbstractModule.updateFacets(
at jetbrains.mps.project.AbstractModule.initFacetsAndModels(
at jetbrains.mps.project.AbstractModule.reloadAfterDescriptorChange(
at jetbrains.mps.project.AbstractModule.setModuleDescriptor(
at bla.bla.bla.pluginsolution.plugin.CreateNewSolution_Action.doExecute(

I might be completely on the wrong track, though.


Please sign in to leave a comment.