Domain Model Updates with Eclipse RCP – “Best” Pratices

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.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Domain Model Updates with Eclipse RCP – “Best” Pratices

  1. Daniel Milosevic says:

    Well, its a year late, but oh well.

    Exactly my thoughts as I go through creating my first Eclipse RCP application. I thought a singleton on the content provider would be perfect to update several different listeners. Thank you so much for filling the rest of it (third paragraph)!!!!!

Comments are closed.