Delete Object Detection

I am creating a modified mass viewpoint and have a background static variable that keeps track of the total mass. When I add new mass objects I can add to the variable and change its value.
My problem is, when I delete a mass object from the model, my static variable does not know that a mass has been lost. Is there a way to detect a deletion event? Additionally, is there a specific method that gets triggered when you reload the model? Maybe I can simply call that method whenever I detect a change in a mass object?
I am using Capella Studio 1.3
Thank you in advance,

Extend org.polarsys.capella.core.model.helpers.listeners.CapellaCon tainmentTreeListener and override handleContainmentTreeChange(). The first parameter of that method is a map that contains information about deleted elements, so you can update your mass value here. Also override isPostCommitOnly() to return true. You now must register/deregister the listener when appropriate. You can use session.getTransactionalEditingDomain().add/removeResourceSe tListener() for that.

Thank you for the response, I will try this out.