Notifying changes in Object (structures) when using multiple Models

Hello,

I am at the moment working on a editor for a configuration class. The class has several lists, some trees and objects some lists share references to object other lists and/or trees. The editor shows the structer in different views, be it either lists, trees and/or comboboxes (depending on the context), mostly the entire structure, sometimes only partial. I use one Model for each view

Now, if I do something as simple as changing the attribute "name" of one object in one view, all the other views needs to be notified. One approach is to make one Model the "master" (this model is allowed to modify the object) and it can notify the "slave" Models when changes occur. The top gui class must then add the respective listeners.

Another approach is to let the editable object add propertychangelisteners. Whenever an attribute is changed with a set-Method, all propertychangelisteners are notified (in this case the models).

I want to use the most elegant approach, but I seem to lack the experience here. Any suggestions?

[1060 byte] By [mhstava] at [2007-11-26 14:34:05]
# 1
I would go with something like the latter. You can listen fora generic PropertyChange and repaint the view.Another option might be the mediator route.
es5f2000a at 2007-7-8 2:30:07 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
Just googled some articles about the Mediator Pattern and it looks like this is what I need :)Probably better than building too much functionality into the data objects, or do anyone think otherwise?
mhstava at 2007-7-8 2:30:07 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

> Just googled some articles about the Mediator Pattern

> and it looks like this is what I need :)

>

> Probably better than building too much functionality

> into the data objects, or do anyone think otherwise?

almost certainly. give your objects as little work to do as you possibly can!

georgemca at 2007-7-8 2:30:07 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
Thanks for all the advice!Note to self:Purchase a Design Pattern book
mhstava at 2007-7-8 2:30:07 > top of Java-index,Other Topics,Patterns & OO Design...