|DeleteCommand on a resource [message #1841292]
||Tue, 11 May 2021 10:10
| Wernke zur Borg
Registered: December 2011
I am trying to "properly" delete a loaded EMF Resource in our application within a transaction. The deletion is supposed to (in whatever order):
- Unload the resource
- Delete all references to contained objects from the rest of the model
- Physically delete the resource file
The most obvious way to do it would be the usage of a DeleteCommand with the Resource object as value. But this does not work because the ResourceSetItemProvider cannot create a RemoveCommand for the resource. I found an ancient post in this context: DeleteCommand on top level resource contents but I am still not sure what to do. Does it mean I have to override createCommand() in a subclass of ResourceSetItemProvider and do all the above steps in a custom RemoveCommand? Does anybody have an example of that? It seems to me like a common use case but I can't find anything usable, and I feel like reinventing the wheel.
Remark 1: The deletion of all incoming references is already nicely supported by the DeleteCommand, and I can subclass it to use the ECrossReferenceAdapter for finding the usages in a performant way. The problem is one step before, in the deletion of the resource.
Remark 2: There is no strict requirement in that the deletion shall be undoable; the user can be warned.
Thanks for all hints.
[Updated on: Tue, 11 May 2021 10:19]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.03247 seconds