Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Visibility of variabe
Visibility of variabe [message #1229387] Thu, 09 January 2014 10:43 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 97
Registered: June 2010
Member
I want to define a (edge creation) tool that creates two additional sockets on the entities that are to be connected by an element based edge. I'm not able to set the endpoints of the edge as I don't know how to refer to the newly created sockets.

So the domain model contains entities named Node, Socket and Edge. Nodes contain Sockets and Edges refer to sockets for their ednpoints.

The tool should accept two nodes as source and target. Upon invocation, the tool should create a Socket contained by the source a Socket contained by the target. Then, it should create an Edge and let its endpoints refer to the newly created Sockets.

My tool operation now looks like:
Change context (self.eContainer())
- Change context (var:source)
-- Create instance Socket
- Change context (var:target)
-- Create instance Socket
- Create instance Edge
-- Set Value (endpoints)


In the properties of the Create Socket instance operations, I defined variable names for the new instances (sourceSocket and targetSocket). When trying to refer to these while setting the endpoints value of the Edge, the system complaints with: unknown variable: sourceSocket.

It seems that the visibility of sourceSocket is limited to the scope of Create instance.

How can I refer to these instances later on. Or should I structure my tool definition in a different way?

Greetings,
Wilbert.
Re: Visibility of variabe [message #1229506 is a reply to message #1229387] Thu, 09 January 2014 15:33 Go to previous messageGo to next message
Alex Lagarde is currently offline Alex LagardeFriend
Messages: 185
Registered: May 2010
Senior Member

Hi Wilbert,

I think the operations you described should work, and if not this is a
bug. The visibilty of the variables defined through a CreateInstance
should not be limited to the CreateInstance scope.

Would you accept to raise a bugzilla issue with your ecore and VSM so
that we can try to reproduce the issue ?

Best regards,
Alex
Re: Visibility of variabe [message #1229528 is a reply to message #1229506] Thu, 09 January 2014 16:32 Go to previous messageGo to next message
Alex Lagarde is currently offline Alex LagardeFriend
Messages: 185
Registered: May 2010
Senior Member

Hi Wilbert,

please ignore my previous answer.

I checked with other Sirius commiters, and this is actually the expected
behavior. User-defined variables (such as variables defined inside a
CreationTool) are only visible for children, so what you describe as an
issue is actually the expected behavior.

The logic is the following: imagine these Model operations:
- If [condition/]
-- CreateInstance (variable:myInstance)
- Else
-- XX

The myInstance variable should not be accessible in the "Else" branch right?

While writing Operations on Tool, remember that any slibing instruction
should be executable before or after its other slibings. If an
instruction depends on another, it should be contained in it.

Sorry for my wrong previous answer,
Alex
Re: Visibility of variabe [message #1229792 is a reply to message #1229528] Fri, 10 January 2014 08:20 Go to previous messageGo to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 97
Registered: June 2010
Member
Hi Alex,

This is a very helpful remark:
Quote:

While writing Operations on Tool, remember that any slibing instruction
should be executable before or after its other slibings. If an
instruction depends on another, it should be contained in it.


It would have been nice if this concept would be explained in the documentation of the tool operations. Especially this sentence is misleading (quoted from the help information of Create Instance):

Quote:
The Variable Name property can be set to any valid variable name ( instance by default). The named variable is assigned with the newly created object, so that it can be accessed from the remaining operations in the tool.


Anyway, I appreciate your help in this.

Greetings,
Wilbert.
Re: Visibility of variabe [message #1229796 is a reply to message #1229792] Fri, 10 January 2014 08:29 Go to previous message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 97
Registered: June 2010
Member
Based on your help I now came up with:

Change context (self.eContainer())
- Create instance Edge (varname: instance)
-- Change context (var:source)
--- Create instance Socket (varname: sourceSocket)
-----Change context (var: instance)
------Set Value(endpoints=sourceSocket)
-- Change context (var:target)
--- Create instance Socket (varname: targetSocket)
-----Change context (var: instance)
------Set Value(endpoints=targetSocket)


Is there an easier way to do this? For instance, would it make sense to change the context and set the value of an attribute in one operation?

Greetings,
Wilbert.
Previous Topic:How to debug Model Operations
Next Topic:Incorrect Set Value operation on collection?
Goto Forum:
  


Current Time: Sat Nov 29 10:14:20 GMT 2014

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

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