Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] Create a property Listener
[EMF] Create a property Listener [message #767457] Sun, 18 December 2011 02:40 Go to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
Hello

i have two nodes.
Related in emfatic as follows:


@gmf.node(label="identifier", border.width="2", border.color="0,0,0", size="130,50", figure="rectangle", label.icon="false")
class Goal {
   ref AwayGoal[*]#ReferencedGoal isReferencedByAwayGoals;
   attr String name;
}

@gmf.node(label="identifier", border.width="1", border.color="0,0,0", size="130,50", label.icon="false", figure="rectangle")
class AwayGoal {
  ref Goal[1]#isReferencedByAwayGoals ReferencedGoal;
  attr String AwayGoalModuleIdentifier;
}


The Value 'AwayGoalModuleIdentifier' should now be set accordingly to the 'name' attribute of the Referenced Goal.
That means that it must be changed when the attribute 'name' of Goal is changed.
And it must be changed when the referenced Goal is changed as well.

What i now want is to add a ChangeListener to these objects.

I already tried to edit the respective generated methods.

This is setName of Goal and basicSetReferencedGoal of AwayGoal.
The first one (setName) works well...but the second one not.

So i want to implement a real Listener to these objects. Is this possible ?
Are there any examples ?

Greeting Snakebyte

[Updated on: Sun, 18 December 2011 02:41]

Report message to a moderator

Re: [EMF] Create a property Listener [message #767544 is a reply to message #767457] Sun, 18 December 2011 09:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Comments below.

On 18/12/2011 3:40 AM, Snakebyte wrote:
> Hello
>
> i have two nodes. Related in emfatic as follows:
>
>
>
> @gmf.node(label="identifier", border.width="2", border.color="0,0,0",
> size="130,50", figure="rectangle", label.icon="false")
> class Goal {
> ref AwayGoal[*]#ReferencedGoal isReferencedByAwayGoals;
> attr String name;
> }
>
> @gmf.node(label="identifier", border.width="1", border.color="0,0,0",
> size="130,50", label.icon="false", figure="rectangle")
> class AwayGoal {
> ref Goal[1]#isReferencedByAwayGoals ReferencedGoal;
> attr String AwayGoalModuleIdentifier;
> }
>
> The Value 'AwayGoalModuleIdentifier' should now be set accordingly to
> the 'name' attribute of the Referenced Goal.
> That means that it must be changed when the attribute 'name' of Goal
> is changed.
> And it must be changed when the referenced Goal is changed as well.
>
> What i now want is to add a ChangeListener to these objects.
>
> I already tried to edit the respective generated methods.
>
> This is setIdentifier of Goal and basicSetReferencedGoal of AwayGoal.
> The first one (setIdentifier) works well...but the second one not.
>
> So i want to implement a real Listener to these objects. Is this
> possible ?
All EObjects are Notifiers so you can add to their eAdapters list. You
might want to look at things like EContentAdapter and
ECrossReferenceAdapter as examples.
> Are there any examples ?
>
> Greeting Snakebyte
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] Create a property Listener [message #767602 is a reply to message #767544] Sun, 18 December 2011 13:13 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
Can you give me a little bit more example code for this ?
Im not really familiar with this.

Just for the change inside the node.
So if the Reference in awaygoal is changed, the String attribute inside this node should be changed.
Re: [EMF] Create a property Listener [message #767609 is a reply to message #767602] Sun, 18 December 2011 13:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
What have you done to try to answer this yourself? There's a whole EMF
book that explains all these concepts, as well as introductory overview
articles...

On 18/12/2011 2:13 PM, Snakebyte wrote:
> Can you give me a little bit more example code for this ?
> Im not really familiar with this.
>
> Just for the change inside the node.
> So if the Reference in awaygoal is changed, the String attribute
> inside this node should be changed.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] Create a property Listener [message #767640 is a reply to message #767609] Sun, 18 December 2011 14:54 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
I tried it like this :

http://wiki.eclipse.org/EMF/Recipes#Notification_Framework_Recipes

And i see that i can register Objects to each other like this.
Im not really familiar with this eAdapters, so i dont really know which code is executed now.
So i dont know how i can execute code, when such a notification ois fired...
i think i just need some more explanation.
Re: [EMF] Create a property Listener [message #767660 is a reply to message #767640] Sun, 18 December 2011 15:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
So you've looked at how EContentAdapter reacts to notification?

On 18/12/2011 3:54 PM, Snakebyte wrote:
> I tried it like this :
>
> http://wiki.eclipse.org/EMF/Recipes#Notification_Framework_Recipes
>
> And i see that i can register Objects to each other like this.
> Im not really familiar with this eAdapters, so i dont really know
> which code is executed now.
> So i dont know how i can execute code, when such a notification ois
> fired...
> i think i just need some more explanation.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] Create a property Listener [message #767669 is a reply to message #767660] Sun, 18 December 2011 16:29 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
I think not, but where i can find this information ?

I would not have asked here if i would have found a good information source about that.
The Api is really short, and i havent found a good tutorial.

[Updated on: Sun, 18 December 2011 16:31]

Report message to a moderator

Re: [EMF] Create a property Listener [message #767679 is a reply to message #767669] Sun, 18 December 2011 17:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Do you know about Ctrl-Shift-T?

On 18/12/2011 5:29 PM, Snakebyte wrote:
> I think not, but where i can find this information ?
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] Create a property Listener [message #767702 is a reply to message #767679] Sun, 18 December 2011 18:12 Go to previous message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
Yes i do.
I think i really was a little bit sick today.
I got it working now.

Thanks anyway Wink
Previous Topic:How to instantiate objects that have simple association relationships and not containment references
Next Topic:[EMF Compare] Unable to open textual diff popup for string EAttribute
Goto Forum:
  


Current Time: Fri Apr 26 16:40:56 GMT 2024

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

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

Back to the top