[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Custom code for list of enums

Tomas,

You extend the list that's already being created right in place in the generated getter.


Tomas Zijdemans wrote:
Ah, I see :)

I created this:

class test extends BasicEList<InstantiationLevel> {
@Override
protected void didAdd(int index, InstantiationLevel newObject) {
    super.didAdd(index, newObject);
    System.out.println("didAdd :)");
    }
@Override
protected void didRemove(int index, InstantiationLevel oldObject) {
    super.didRemove(index, oldObject);
    System.out.println("didRemove :)");
    }
}

But, for the final step, how do I hook this to my EList?


Thanks for helping,

Tomas Zijdemans

Ed Merks wrote:
Tomas,

No, if you walk up the EDataTypeUniqueEList you'll see it inherits from BasicEList so I'm suggesting creating an anonymous derived inner class and specializing the didAdd method as a place to do the specialized processing that's needed when something is added to the list.


Tomas Zijdemans wrote:
Ed Merks wrote:

EMF's lists are derived from BasicEList or DelegatingEList and both provide methods like didAdd, didRemove that allow you to hook directly into the things that happen to modify the list much like overrides a setXyz method directly.

Are you talking about the eDynamicSet method? - couldn't find didAdd.

(my list is a EDataTypeUniqueEList<enumtype>)


Thanks,

Tomas Zijdemans



Tomas Zijdemans wrote:
Hi!

I want to execute some custom code when enumerators are set. I do this in their respective set<enumname> methods. But I have one enumerator which is multiple. EMF generates an EList with a get<enumname> method. How can I run my custom code when enumerators are added to this list? (since there is no inverseAdd case)

Best Regards,

Tomas Zijdemans