How to listen to emf model [message #211415] |
Fri, 10 March 2006 12:46 |
Eclipse User |
|
|
|
Originally posted by: shruthi.cn.in.bosch.com
Hello everybody,
I want to use EMF model for developing a GEF editor.
In the GEF sample "org.eclipse.gef.examples.shapes_3.1.0", the model and
the editparts uses java.beans.PropertyChangeListener and
java.beans.PropertyChangeSupport for notification on changes in the
property.
Now, in the generated EMF model and EMF.Edit framework classes, i saw that
EMF model also notifies using EMF's eNotify and notifyChanged.
notifyChanged, in turn fires event using fireNotifyChanged method. I also
saw that there is a function addListeners in
XXXXXItemProviderAdapterFactory.java in EMF.Edit framework inside the
providers package.
How can i make the EditParts listen to emf model?
Could anybody give a sample code for this. May be some links for EMF-GEF
working together would also help me. But sample code would be the best.
Thank you very much
Best Regards
Shruthi
|
|
|
|
Re: How to listen to emf model [message #211696 is a reply to message #211415] |
Wed, 15 March 2006 11:51 |
Thomas Maier Messages: 117 Registered: July 2009 |
Senior Member |
|
|
Hi Shruthi,
probably a question for the emf group but I was glad that somebody
answered when I posted to the uml2 group :), so here are some hints for
you (but beware I am also a newbie trying to find things out):
Your listener must implement org.eclipse.emf.common.notify.Adapter
In Adapter, there is "public void notifyChanged(Notification n)". This
gets called when something changes. There you can switch on the feature id:
switch (n.getFeatureID(Classifier.class))
{
case UML2Package.PROPERTY__NAME:
refreshVisuals();
break;
... etc ...
}
(This example is specific to the uml2 stuff.)
Notification has methods to find out what has changed and the old and
new values.
You register your listener like this:
eobject.eAdapters().add(listener);
To remove it, call
eobject.eAdapters().remove(listener);
Hope that gets you going, Thomas.
Shruthi schrieb:
> Hello everybody,
>
> I want to use EMF model for developing a GEF editor.
> In the GEF sample "org.eclipse.gef.examples.shapes_3.1.0", the model and
> the editparts uses java.beans.PropertyChangeListener and
> java.beans.PropertyChangeSupport for notification on changes in the
> property.
>
> Now, in the generated EMF model and EMF.Edit framework classes, i saw
> that EMF model also notifies using EMF's eNotify and notifyChanged.
> notifyChanged, in turn fires event using fireNotifyChanged method. I
> also saw that there is a function addListeners in
> XXXXXItemProviderAdapterFactory.java in EMF.Edit framework inside the
> providers package.
>
> How can i make the EditParts listen to emf model?
> Could anybody give a sample code for this. May be some links for EMF-GEF
> working together would also help me. But sample code would be the best.
>
> Thank you very much
> Best Regards
> Shruthi
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02732 seconds