Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Working with a container to group model elements by dragging
Working with a container to group model elements by dragging [message #1742943] Thu, 08 September 2016 17:30 Go to next message
Alex B. is currently offline Alex B.Friend
Messages: 20
Registered: June 2016
Junior Member
Hello everyone,

seems I got stuck again. :/

Please check the attached diagram. This is my scenario I wanted to create. But the insertion of the "correct" statements in odesign bring up some trouble for me.

My Model consits of ModelElement(s). ModelElement(s) for example can be instances of SpecialElement(s) and I want to group these elements having a recursion here. So a Group can either consist of groups or SpecialElement(s), which can be at the end of the tree only instances of ClassA and ClassB. The relation groupElements in Group is no containment reference in ecore. In my opinion it should be correct this way. If not, please correct me.

What I did in odesign by now was to creat a container node with the following attributes:
Id: whatever
Domain Class: Group
Semantic Candidates Expression: feature:modelelements
Children Presentation: Free Form

Afterwards and below the container node I created a sub node:
id: nodeId
Domain Class: SpecialElement
Semantic Candidates Expression: feature:groupElements

For both I created representations.

Now I created a container creation task:
id: createContainer
Container Mappings: Group (I was only able to select this single mapping using the dialog)
and in the Begin part:
Change Context var:container -> Create Instance Group with Reference Name modelElements and Type Name Group and Variable Name instance.

When I execute the odesign, add a container and try to drag an element of of ClassA or ClassB onto the container, I receive a forbid sign and the operation is not possible. What did I do wrong? - Is this possible what I want to achieve - showing elements in container elements by just dragging them on the container element?

Thank you for your help in advance. I hope there is a solution for my problem... Unfortunately the tutorials and documentation I went trough did not help much...

Regards
Alex
  • Attachment: diagram.png
    (Size: 9.57KB, Downloaded 200 times)
Re: Working with a container to group model elements by dragging [message #1744519 is a reply to message #1742943] Tue, 27 September 2016 16:10 Go to previous messageGo to next message
Alex B. is currently offline Alex B.Friend
Messages: 20
Registered: June 2016
Junior Member
Hi all,

at frist sorry for pushing but maybe someone got an idea by now...
I managed to create containers which are accordingly to the screenshot attached on this posting.

C0 is some kind of a root container. It is created with the diagram.
I added C1 and C2, both outside of C0. If I drop C1 onto C0, the drop seems to work since C1 is now part of C0, but still the "old" C1 exists outside C0. Why is that?
When I place further elements into C1 (which is inside C0) they are also shown in the other C1 container. So they seem to be some kind of mirroring each other. Does any one have a clue what I did wrong?

What I want to achieve is a infite container relationsship (for example as proposed in the blogpost by Melanie: http://melb.enix.org/sirius/reimport/) with the only difference, that on every level a container can contain further containers (Group - see my diagram I attached on the initial post) or other elements (subclasses of VerySpecialElement - see my diagram I attached on the initial post).

Maybe someone got an idea how to achieve that...

Thx and best regards
Alex

[Updated on: Tue, 27 September 2016 16:13]

Report message to a moderator

Re: Working with a container to group model elements by dragging [message #1744556 is a reply to message #1744519] Wed, 28 September 2016 09:09 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello Alex,

I think we missed your first post, sorry about that.

For the infinite containment, you need to reuse the same container mapping in the Import tab (also see the "Reuse mappings" part in the blogpost by Melanie). Then to be able to drag and drop a container from one parent to another, you will need to add a "Container Drop" tool (available among the "New Element Edition" in the contextual menus) otherwise you will only be able to move around a container without being able to change its parent. In this tool, you first add a "change context" operation and set it as "var:element". Then add a "move" operation and set it as "var:newSemanticContainer". This will move the drag container into the targeted container.

About your metamodel, are you sure that you need the metaclass group? If ModelElement had a containment reference on itself, you could create a ModelElement and later add ModelElement in it without having to create a group. Then SpecialElement and VerySpecialElement would not be needed anymore.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Working with a container to group model elements by dragging [message #1744570 is a reply to message #1744556] Wed, 28 September 2016 12:33 Go to previous messageGo to next message
Alex B. is currently offline Alex B.Friend
Messages: 20
Registered: June 2016
Junior Member
Hi Steve,

thanks for you answer.

Steve Monnier wrote on Wed, 28 September 2016 09:09

For the infinite containment, you need to reuse the same container mapping in the Import tab (also see the "Reuse mappings" part in the blogpost by Melanie). Then to be able to drag and drop a container from one parent to another, you will need to add a "Container Drop" tool (available among the "New Element Edition" in the contextual menus) otherwise you will only be able to move around a container without being able to change its parent. In this tool, you first add a "change context" operation and set it as "var:element". Then add a "move" operation and set it as "var:newSemanticContainer". This will move the drag container into the targeted container.

That is basically what I did before. I changed it in exact the way you proposed, but unfortunately I still have these two views which are mirroring each other. So maybe the problem is not the container drop itself. How is a container drop handled internally by Sirius? - I can imagine that a new container is created while the old one is deleted?
I am asking because I got the case, when a new instance of Group is created, I do the following things:
- change context to feature:eContainer
-- create Instance Group with reference name: modelelements
--- change context var:newlyCreatedGroup
---- move with new container expression: var:container and feature name: groupElements

I feel I need to do it that way, because I need the reference name to be set in my root class Model. Maybe my problem has anything to do with that?

Quote:
About your metamodel, are you sure that you need the metaclass group? If ModelElement had a containment reference on itself, you could create a ModelElement and later add ModelElement in it without having to create a group. Then SpecialElement and VerySpecialElement would not be needed anymore.

Thanks for the hint. I already thought about that, but unfortunately this excerpt is not representing my whole model. The rest of it requires to have a Group metaclass...

Maybe you got some ideas on that... I got this feeling that a working solution is not far anymore.
Thanks!

Best
Alex
Re: Working with a container to group model elements by dragging [message #1744585 is a reply to message #1744570] Wed, 28 September 2016 15:24 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Oh right! I replied too quickly.

You may have duplicates elements depending on how you created your mappings because the containment tree in your semantic model is different from how you want to display it. Here is how I visualize your mappings (if I understood correctly your metamodel and wanted diagram):
- You should have a first mapping (mapping A) with a domain based "VerySpecialElement" that have no group referencing them (VerySpecialElement in no group);
- Then, you should have a container mapping (mapping B) with a domain based "Group" that have also no group referencing them (first level group);
- Inside the previous container mapping, you should have a mapping (mapping C) with a domain based "VerySpecialElement" where the semantic expression would be "feature:groupElements" in order to display only the elements of this group:
- In the same container mapping, you should have a container mapping (mapping D) with a domain based "Group" where the semantic expression would be "feature:groupElements" in order to display the groups contained by this group. Also, this container mapping should reuse itself to display groups of second level and more. It should also reuse (mapping C) to display contained "VerySpecialElements" recursively (or you add a last mapping similar to mapping C in it).

In your drop tool you should not move the element. You should change context to var:newSemanticContainer and then (instead of the move) add a "Set" operation in order to set the groupElements reference adding the dropped element.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Working with a container to group model elements by dragging [message #1744607 is a reply to message #1744585] Wed, 28 September 2016 20:09 Go to previous messageGo to next message
Alex B. is currently offline Alex B.Friend
Messages: 20
Registered: June 2016
Junior Member
Hi Steve,

thank you for your answer. Hmm... I tried it the way you described, but it did not work unfortunately. :/ Still both views to one single instance are shown, even if I exactly followed your description.

May I ask you for a odesign file (including three tools: one for creating groups, the second for dropping elements onto a group and another for creating one subclass of VerySpecialElement as a node, e.g. ClassA) ? - That would be great! I attached the ecore project the way I modeled the metamodel.

One more thing: Can I really use the abstraction VerySpecialElement instead of the concrete classes ClassA and ClassB? I would have rather used the concrete types here.

Thank you for your help so far. I hope we will get this thing fixed soon, since I still got the feeling that we are nearly there.

Best
Alex

[Updated on: Wed, 28 September 2016 20:13]

Report message to a moderator

Re: Working with a container to group model elements by dragging [message #1744696 is a reply to message #1744607] Thu, 29 September 2016 14:29 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello Alex,

Unfortunately, I will not have time to create the odesign for you as we are pretty busy for the release of Sirius 4.1 next week.

I do not see what is missing in the previous mapping construction, probably a wrong precondition. I guess you can try to add the mappings one by one and see when you start to have duplicated elements in order to identify which mapping should not display elements.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

[Updated on: Thu, 29 September 2016 14:31]

Report message to a moderator

Re: Working with a container to group model elements by dragging [message #1744713 is a reply to message #1744696] Thu, 29 September 2016 15:33 Go to previous messageGo to next message
Alex B. is currently offline Alex B.Friend
Messages: 20
Registered: June 2016
Junior Member
Hi Steve,

okay I understand that. But would it be possible to have a look at the odesign file if I create it?

Thanks!

Best
Alex
Re: Working with a container to group model elements by dragging [message #1744855 is a reply to message #1744713] Fri, 30 September 2016 19:54 Go to previous message
Alex B. is currently offline Alex B.Friend
Messages: 20
Registered: June 2016
Junior Member
Dear Steve,

please find attached the ecore and odesign files. Could you please test it? I could not get your solution to work...

Since I could not get it to work, I would be very happy if someone could help me with that.

Thank you very much!

Best
Alex

[Updated on: Fri, 30 September 2016 19:56]

Report message to a moderator

Previous Topic:[Properties View] How to access a text fields value
Next Topic:Only one Edge between two nodes
Goto Forum:
  


Current Time: Fri Apr 26 09:45:07 GMT 2024

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

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

Back to the top