Since a while I’m trying to defining the easiest way to update the views and editors of an Eclipse RCP application whenever the domain model is changing. First I started with linking the views and editors to eachother so whenever a view / editor would change the data model this view / editor would notify his observers. I really didn’t liked this as I thought this cross-linking of view is a little bit overkill to notify all responsible parties.
I when started to use the Eclipse EMF datamodel and used the automatic model notifcation in EMF. I basically attached an EObserver in each view / editor to listen to changes in the datamodel and updated then the views / editors in case changes were happing. Nice but with this I introducted a dependency to EMF which I also didn’t like particular.
Today I decided that as I use anyhow a Singleton as ContentProvider for my model I can also add hooks in this contentProvider for PropertyChangeListener (the views and editors) which could then register themselfs of Listeners. And instead of listening to changes in the data model directly (which would either require EMF or a lot of boiler plate code in my domain model) I just offer a public notifyListeners() method in my ContentProvider. So every class which does some relevant changes to the domain model can you call notifyListeners() and all the registered views / editors will update themself.
Improvements suggestions are more then welcome.