Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF, GEF overlapping interfaces
EMF, GEF overlapping interfaces [message #384452] Tue, 27 April 2004 13:44 Go to next message
Chris Heald is currently offline Chris HealdFriend
Messages: 40
Registered: July 2009
Member
We're using EMF to generate the model for a GEF application.
In order to receive notification from the model my editParts need to
implement org.eclipse.emf.common.notify.Adapter.

This hasn't been a problem before but now we are using EMF to generate the
Connection Model as well. Obviously the editPart for this model should
implement org.eclipse.gef.ConnectionEditPart.

However, both these interfaces have a getTarget() method which is required
to return objects of different types.

Any ideas?
Thanks for your help
Chris
Re: EMF, GEF overlapping interfaces [message #384458 is a reply to message #384452] Tue, 27 April 2004 14:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Chris,

That really bites hey. I think that JDK 1.5 would allow this kind of thing,
depending on the inheritance relation between the return types, but for 1.4 or
lower, there's nothing you can do except implement the interfaces with
different objects (that know about each other).


Chris Heald wrote:

> We're using EMF to generate the model for a GEF application.
> In order to receive notification from the model my editParts need to
> implement org.eclipse.emf.common.notify.Adapter.
>
> This hasn't been a problem before but now we are using EMF to generate the
> Connection Model as well. Obviously the editPart for this model should
> implement org.eclipse.gef.ConnectionEditPart.
>
> However, both these interfaces have a getTarget() method which is required
> to return objects of different types.
>
> Any ideas?
> Thanks for your help
> Chris


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF, GEF overlapping interfaces [message #384461 is a reply to message #384458] Tue, 27 April 2004 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

You don't need to have your editparts implement Adapter to receive
notification. We use this paradigm instead:


public clas MyEditpart extends SomeotherEditPart {

private Adapter emfAdapter = new AdapterImpl() {
public void notifyChanged(Notification notification) {
... do what is necessary for the notification, call
other methods within MyEditPart, etc.
}
};

public void activate() {
super.activate();
((EObject) getModel()).eAdapters().add(emfAdapter);
}

public void deactivate() {
super.deactivate();
((EObject) getModel()).eAdapters().remove(emfAdapter);
}

}

--
Thanks, Rich Kulp

Re: EMF, GEF overlapping interfaces [message #384483 is a reply to message #384461] Wed, 28 April 2004 06:54 Go to previous message
Chris Heald is currently offline Chris HealdFriend
Messages: 40
Registered: July 2009
Member
Genius!
Simple, elegant and best of all _should_ work.

Thanks very much :)
Chris


Rich Kulp wrote:

> You don't need to have your editparts implement Adapter to receive
> notification. We use this paradigm instead:


> public clas MyEditpart extends SomeotherEditPart {

> private Adapter emfAdapter = new AdapterImpl() {
> public void notifyChanged(Notification notification) {
> ... do what is necessary for the notification, call
> other methods within MyEditPart, etc.
> }
> };

> public void activate() {
> super.activate();
> ((EObject) getModel()).eAdapters().add(emfAdapter);
> }

> public void deactivate() {
> super.deactivate();
> ((EObject) getModel()).eAdapters().remove(emfAdapter);
> }

> }
Previous Topic:Pluggable Package Registry Implementation
Next Topic:Unable to use the model generated in the new launch configuration
Goto Forum:
  


Current Time: Thu Apr 18 00:28:25 GMT 2024

Powered by FUDForum. Page generated in 0.22942 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top