Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Difficulty with handling node creation / deletion in corner cases
Difficulty with handling node creation / deletion in corner cases [message #1700877] Tue, 07 July 2015 19:49 Go to next message
Ryan Schimpel is currently offline Ryan SchimpelFriend
Messages: 7
Registered: May 2015
Junior Member
Hi there,
I've been having some difficulty trying to implement a particular case using Sirius and I was wondering if you might have some thoughts as how to be go about it.

Essentially, I'm working with a tree structure in Sirius with the goal being able to easily add / remove nodes as well as change the parent of all the nodes and thereby the structure of the tree. While I've been fairly successful in general in doing so, there are certain cases which cause me trouble.

As the several problem cases are quite related, an answer to one of them would provide the template for implementing all of them. As such, I will only go into depth about one such case. Please look at the diagram below:

index.php/fa/22419/0/

Essentially, I am trying to add a new root to the tree, pushing everything else down a level; initially, it may appear to be simple but there are several complications. Firstly, unlike a more traditional tree, both the leaf nodes and internal nodes have their own type hierarchy so you're not just dealing with one type for each. Thirdly and probably most seriously, there is no real place where I can create the new node instance; since the container object CONTAINS the root node and hence the rest of the tree (since parent nodes contain their children), attempting to put it in the container object will make me lose the rest of the tree. In fact, containment greatly complicates things in my case. Note that the EMF models for this system are FIXED and changing them is not a viable option.

The real problem here is the lack of actual variables in Sirius that store state; these variables are essentially placeholders (macros) for expressions which are recomputed everytime they are accessed.

Is their any way to do what I'm suggesting without having to resort to an external action? If I need to use one, that's not the end of the world; however, if I had to create an action for each of the numerous types I need to support, that would be extremely unpleasant and a maintenance nightmare. Is there any utility function that I can use to generate instances, say using the name of the metamodel and class (i.e. "hierarchy.ValueNode")? This would mean that I would only need to make and maintain one such action (since the behavior should be the same among all nodes.)

Thanks for your help in advance and I look forward to hearing back from you.
  • Attachment: Diagram.jpg
    (Size: 102.55KB, Downloaded 300 times)
Re: Difficulty with handling node creation / deletion in corner cases [message #1701249 is a reply to message #1700877] Fri, 10 July 2015 08:59 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 267
Registered: July 2009
Senior Member
Le 07/07/2015 21:49, Ryan Schimpel a écrit :
> Hi there,
> I've been having some difficulty trying to implement a particular case using Sirius and I was wondering if you might have some thoughts as how to be go about it.
>
> Essentially, I'm working with a tree structure in Sirius with the goal being able to easily add / remove nodes as well as change the parent of all the nodes and thereby the structure of the tree. While I've been fairly successful in general in doing so, there are certain cases which cause me trouble.
>
> As the several problem cases are quite related, an answer to one of them would provide the template for implementing all of them. As such, I will only go into depth about one such case. Please look at the diagram below:
>
>
>
> Essentially, I am trying to add a new root to the tree, pushing everything else down a level; initially, it may appear to be simple but there are several complications. Firstly, unlike a more traditional tree, both the leaf nodes and internal nodes have their own type hierarchy so you're not just dealing with one type for each. Thirdly and probably most seriously, there is no real place where I can create the new node instance; since the container object CONTAINS the root node and hence the rest of the tree (since parent nodes contain their children), attempting to put it in the container object will make me lose the rest of the tree. In fact, containment greatly complicates things in my case. Note that the EMF models for this system are FIXED and changing them is not a viable option.
>
> The real problem here is the lack of actual variables in Sirius that store state; these variables are essentially placeholders (macros) for expressions which are recomputed everytime they are accessed.
>
> Is their any way to do what I'm suggesting without having to resort to an external action? If I need to use one, that's not the end of the world; however, if I had to create an action for each of the numerous types I need to support, that would be extremely unpleasant and a maintenance nightmare. Is there any utility function that I can use to generate instances, say using the name of the metamodel and class (i.e. "hierarchy.ValueNode")? This would mean that I would only need to make and maintain one such action (since the behavior should be the same among all nodes.)
>
> Thanks for your help in advance and I look forward to hearing back from you.
>

Hi,

I think you can create a sub variables in the extisting container
variable of the node creation tool to store the old root instance during
the creation of the new one.

I create a sample project to show this solution (based on an ecore
model). Steps to reproduce:
* Import the project newRootProject
* Open the representation named "diagram"
* Select the tool "New root" and click on "ContainerObject" : a new root
named RootB is inserted between ContainerObject and RootA.

Regards,

--
Laurent Redor - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Difficulty with handling node creation / deletion in corner cases [message #1701510 is a reply to message #1701249] Mon, 13 July 2015 18:48 Go to previous message
Ryan Schimpel is currently offline Ryan SchimpelFriend
Messages: 7
Registered: May 2015
Junior Member
Hi Laurent,

thank you for your prompt response.

After looking into your solution (a variable generated by [self.eSubpackages->first()/]), it doesn't appear that it will work for me. This is because, unlike in your metamodel, the types of the nodes specified in my (xcore) models do NOT derive from EPackage; both the class of the container (TopologyRoot) and the superclass for all nodes in hierarchy (Node) actually directly inherit from EObject. As such, I can't really use eSubpackages() in this scenario and thus, my options are quite limited.

Is there any other solution you can suggest, given that they are more or less just plain EObjects? Or do I have to resort to an external action to implement this?

Thanks in advance,
Ryan
Previous Topic:Edge Visualization & Creation Problems
Next Topic:Use Kieler Layout on Sirius Diagram
Goto Forum:
  


Current Time: Wed Jan 27 17:10:33 GMT 2021

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

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

Back to the top