Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » List with set and get
List with set and get [message #165727] Tue, 18 December 2007 09:58 Go to next message
Eclipse UserFriend
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: List with set and get [message #165787 is a reply to message #165727] Tue, 18 December 2007 17:49 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
hi john,

the PropertyTab is plain EMF Code. Look at the EMF tutorials or Eclipse
Property Sheet tutorials for this.

-stefan

John Bluto wrote:
> 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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
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
>
Previous Topic:Hiding elements
Next Topic:Making model changes when changes are made in a connection
Goto Forum:
  


Current Time: Sat Apr 27 02:30:03 GMT 2024

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

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

Back to the top