List with set and get [message #165727] |
Tue, 18 December 2007 09:58 |
Eclipse User |
|
|
|
Originally posted by: john.blutarsky.hotmail.com
Hello everyone,
I am trying to use property types other than String values, specifically I
want to use a List property (of Strings). I've successfully implemented
this and by default there is a GUI interface in the properties tab that
allows me to add and delete entries (this only seems to work with Lists of
Strings not other Lists of other types)
I would however prefer to use my own property interface but don't know
what API's I should be using are. For example, there is no 'get' or 'set'
as there would be for a String property. But as there already exists a GUI
that accomplishes this i would like to be able to just use these but I
don't know where they are located.
Would some one be able to tell me where the code for this would be?
Regards,
John
|
|
|
|
Re: (Solution) List with set and get [message #165930 is a reply to message #165787] |
Wed, 19 December 2007 14:34 |
Eclipse User |
|
|
|
Originally posted by: john.blutarsky.hotmail.com
Thanks for your reply.
I couldn't find this before so I went ahead and created my own methods for
setting the list string that I have.
To do this I just needed to edit the node.java file by adding :
void setWhatever(EList value);
and then edit the nodeImpl.java file by adding:
public void setWhatever(EList newWhatever) {
EList oldWhatever = whatever;
whatever = newWhatever;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
ActsimPackage.DIALOGUE_ELEMENT__WHATEVER, oldWhatever, whatever));
}
I could then use setWhatever to change the Whatever property of node.
Thanks for your help.
J
|
|
|
Re: (Solution) List with set and get [message #165938 is a reply to message #165930] |
Wed, 19 December 2007 15:09 |
Boris Blajer Messages: 217 Registered: July 2009 |
Senior Member |
|
|
Hi John,
Unfortunately, with this modification, the following sequence of calls
will not result in correct notifications from EMF:
yourObject.setWhatever(new BasicEList());
yourObject.getWhatever().add(...);
In fact, it will be possible to break the type invariants EMF normally
imposes (i.e., the list that is expected to contain Strings will contain
Integers).
A correct way would be something like this:
public void setWhatever(EList newWhatever) {
EList oldWhatever = new BasicEList();
oldWhatever.addAll(whatever);
boolean oldDeliver = eDeliver();
eSetDeliver(false);
try {
whatever.clear();
whatever.addAll(newWhatever);
} finally {
eSetDeliver(oldDeliver);
}
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
ActsimPackage.DIALOGUE_ELEMENT__WHATEVER, oldWhatever, whatever));
}
Best regards,
Boris
John Bluto wrote:
> Thanks for your reply.
>
> I couldn't find this before so I went ahead and created my own methods
> for setting the list string that I have.
>
> To do this I just needed to edit the node.java file by adding :
>
> void setWhatever(EList value);
>
> and then edit the nodeImpl.java file by adding:
>
> public void setWhatever(EList newWhatever) {
> EList oldWhatever = whatever;
> whatever = newWhatever;
> if (eNotificationRequired())
> eNotify(new ENotificationImpl(this, Notification.SET,
> ActsimPackage.DIALOGUE_ELEMENT__WHATEVER, oldWhatever, whatever));
> }
>
> I could then use setWhatever to change the Whatever property of node.
>
> Thanks for your help.
>
> J
>
|
|
|
Powered by
FUDForum. Page generated in 0.03221 seconds