Replies: 6 comments
-
Hi Andrew, ResourceSets should typically be used to aggregate inter-related resources (e.g. if a Resource/Model depends on another Resource/Model, which can both be edited together, they should belong to the same Resource Set). Then, when saving the model, you should make sure that all resources from a Resource Set are saved together, to avoid breaking any references. If the models are being edited independently, they should probably be loaded in separate Resource Sets. On the Model Server, each resource set is also associated with a distinct EditingDomain/CommandStack. This means that the Commands (Undo/Redo) are scoped to this EditingDomain/CommandStack/ResourceSet. Again, if the models are meant to be edited together in a consistent way, you probably want to share the CommandStack (And the correspond EditingDomain/ResourceSet). Otherwise, keeping the CommandStacks separated is probably a better choice. |
Beta Was this translation helpful? Give feedback.
-
[Vincent HEMERY] Hello, here is the interpretation of someone coming from the EMF world. You can use a custom resource manager to manage the Resourse Sets however you like. But you must keep these aspects in mind to provide a user experience consistent with your application. [...(when) loading them in the same Resource Set ...]. Hence, when undoing, you may undo a modification performed on a model that you have already closed instead of the current model. PS : cross-post with Camille who essentially says the same thing... so I removed the redundancy to only leave the additionnal details which may help for the comprehension. |
Beta Was this translation helpful? Give feedback.
-
[Andrew Willemsen] Thanks both. I have this problem with some inherited code... A resource (model) can contain a reference to another resource (model), in the form of a UUID. When the first model is loaded then the reference needs to be resolved - we are currently doing this in a custom JSON resource factory (emfjson). The problem is that the EMFContext only seems to have access to the resource set of the resource containing the reference, and not the resource set of the resource being referenced (unless the two resource sets are the same, of course). So, the code implements a pending references handler, so that references to a resource are resolved when the resource is loaded - but this only works if the resource being referenced is loaded last - if it is loaded first then the references are not resolved, but kept in the pending references list. Is there any way that I can get access to all the resource sets from the EMFContext? If not, then I guess that doing the resolution in the JSON resource factory is never going to work properly unless all resources are in the same resource set... |
Beta Was this translation helpful? Give feedback.
-
[Vincent HEMERY] You are typically in a situation where you will have to bind your own ModelResourceManager implementation. After that, you can virtually do anything you want by using your own resource factories and working with editing domains. But this is EMF framework, so the subject is a bit vast... |
Beta Was this translation helpful? Give feedback.
-
[Andrew Willemsen] Hi Vincent. We already have our own custom resource manager, at the moment with minor changes to the default. And the strategy is that each resource can be loaded and edited independently (we are using Theia plugins to provide editing facilities). Also, we would like to keep our options open, and be able to reference any resource from any other resource. I have implemented a new resource manager, not extended from the default, where every resource is in the same set, and the references then resolve successfully. But we are concerned about the knock-on effects this will have. Thanks for your help - it is much appreciated :-) |
Beta Was this translation helpful? Give feedback.
-
The EMF strategy for loading Proxies (i.e. lazily resolving cross-references) is to load them into the current resource set. So, an unresolved reference from a Resource A to a Resource B will be lazily loaded into A's ResourceSet.
|
Beta Was this translation helpful? Give feedback.
-
New to model server. Could someone please explain the role of a resource set please? The default resource manager loads each resource into its own resource set, so 10 resources get loaded then 10 resource sets are created. Is there any advantage of doing this, or can I use a custom resource manager to load every resource into the same set?
original thread by Andrew Willemsen
Beta Was this translation helpful? Give feedback.
All reactions