gui design about observer pattern
i have 2 swt components both including a browser component.
they both are instatiated passing a reference to an observable document:
publicclass ObservableW3CDocumentextends java.util.Observable{
private Document document;
private String content;
/**
* Modifications to the document should be mirrored in by notifications to
* this document observers
*
* @param document
*/
publicvoid setDocument (Document document){
this.document = document;
if(document.getTextContent()!=null){
this.content = document.getTextContent();
System.out.println("Setting content at: "+content);
}
this.setChanged();
notifyObservers(this);
}
publicvoid setContent (String content){
this.content = content;
try{
this.document = DOMUtil.parseHTML(new StringReader(content));
}catch (SAXException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}
this.setChanged();
notifyObservers(this);
}
publicvoid setDocumentAndContent(Document d, String c){
this.document = d;
this.content = c;
this.setChanged();
notifyObservers(this);
}
}
both components implements thejava.util.Observer interface: the first one refresh its content when ever a new document is set (that it, the observable document registers it as an observer).
. the other one should apply an xpath query over it and display the result in its embedded browser.
My question: should I have 2 copies of the same document going around?
How can i make all this updating process easier to mantain?

