[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.dali] Re: question on ResourceModelListener

These listeners are very different.

The ResourceModelListener (recently renamed to JpaResourceModelListener) receives very coarse notifications. It is notified whenever *anything* in the Dali "resource" model changes. The "resource" model is the Dali representation of the various Eclipse resources that are relevant to JPA; namely Java source files, orm.xml files, and the persistence.xml file. If you are interested in more specific events you will need to add the appropriate listener to the appropriate "resource" object (e.g. JpaResourceCompilationUnit or PersistenceXmlResource).

Probably more helpful would be to listen to the "context" model. This is the model that more accurately describes the JPA "model". It provides *all* the settings, taking into account defaults, overrides in XML, etc. The "resource" reflects what is in the resource/file, ignoring defaults etc. To listen to the "context" model, add the appropriate listener to the appropriate "context" object (e.g. PersistentType, TypeMapping, or AttributeMapping).

Also, you say you have implemented these listeners, but you do not say what you added your listeners to. The object you listen to determines the types of events you will receive. Telling us what you add your listeners to might allow us to help you further.

Brian


Brian Vosburgh wrote:
Forwarded from dali-dev list:

-------- Original Message --------
Subject: [dali-dev] question on ResourceModelListener
Date: Fri, 30 Jan 2009 00:00:00 -0500
From: Ivy Ho <corporategirl@xxxxxxxxx>
Reply-To: General Dali EJB ORM developer discussion. <dali-dev@xxxxxxxxxxx>
To: dali-dev@xxxxxxxxxxx



Hi there:

I have implements in from our widget ,ResourceModelListener and ,PropertyChangeListener..

It is funny that if I click on the JPA view,on any fields The PropertyChangeListener is never invoked but it always go to ResourceModelListener.
However in the method resourceModelChanged() , there is no indication as what changes trigger the events,.
Is there any other listeners I can use or there is something we can do in the resourceModelChanged to find out what the change is ?


Thanks so much!

public void resourceModelChanged() {
  // TODO Auto-generated method stub

  System.out.println("resourceModelChanged...");

 }



=== some how the following was never invoked.== don''t know why.====

public void propertyChanged(
   org.eclipse.jpt.utility.model.event.PropertyChangeEvent arg0) {
  // TODO Auto-generated method stub

System.out.println("org.eclipse.jpt.utility.model.event.PropertyChangeEvent");

if (arg0!=null)
{
System.out.println("property name="+arg0.getPropertyName());
System.out.println("source="+arg0.getSource());
System.out.println("new value="+arg0.getNewValue()+": old="+arg0.getOldValue());


}
System.out.println("end org.eclipse.jpt.utility.model.event.PropertyChangeEvent");
}
l