Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Provide own LayoutProvider
Provide own LayoutProvider [message #1738994] Tue, 26 July 2016 15:25 Go to next message
Frank Sorek is currently offline Frank SorekFriend
Messages: 22
Registered: February 2016
Junior Member
Hi everyone,

I have a few questions about the LayoutProvider. I know that Sirius offers the possibility to provide an own LayoutProvider. I tested a bit the functions and options. After deleting an element with a child (which is not removed), the child is re-arranged by the default Layout Provider. My intention is, that the child is re-arranged at the same position where it was before.

First question: By deleting the element, can I store the position of that element and the position of the child to calculate the logical(hope this is the right one) position?

Second question: Can I call a custom LayoutProvider in my services-class which handles the deletion?

Another question belongs to the creation of Container/Nodes. When I create a container, a child-node which shows the label ist also created. The problem is the position where the node is created. I want that the node inside the container is centered automatically. Can I use also a custom LayoutProvider in that case (also to resize the node, because the Size Computation Expression only allows square, but I need a rectangular node) to re-arrange the node inside to the position I want?

Thank you in Advance
Frank
Re: Provide own LayoutProvider [message #1738996 is a reply to message #1738994] Tue, 26 July 2016 15:54 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

You will find my answers below.

Regards,
Steve

[1]
https://www.eclipse.org/sirius/doc/developer/extensions-provide_custom-arrange-all.html

Le 26/07/2016 à 17:25, Frank Sorek a écrit :
> Hi everyone,
>
> I have a few questions about the LayoutProvider. I know that Sirius
> offers the possibility to provide an own LayoutProvider. I tested a bit
> the functions and options. After deleting an element with a child (which
> is not removed), the child is re-arranged by the default Layout
> Provider. My intention is, that the child is re-arranged at the same
> position where it was before.
> First question: By deleting the element, can I store the position of
> that element and the position of the child to calculate the logical(hope
> this is the right one) position?

Yes, you can store the position in the LayoutDataManager. You can access
using the registry
LayoutDataManagerRegistry.getSiriusLayoutDataManagers(diagram);

You can create a new LayoutData to store in the manager using
LayoutDataHelper.INSTANCE.createNodeLayoutData(gmfNode, editPart,
parentLayoutData);

This is the manager used to store the location on copy/paste layout action.

> Second question: Can I call a custom LayoutProvider in my services-class
> which handles the deletion?
I am not sure to understand what you want to do here. As I see it, the
deletion tool should take care of the semantic model update process
(here move the child model element, delete the parent model element). As
there is an update, your custom layout is later triggered and in that
case you need to move the children element where the parent was.

> Another question belongs to the creation of Container/Nodes. When I
> create a container, a child-node which shows the label ist also created.
> The problem is the position where the node is created. I want that the
> node inside the container is centered automatically. Can I use also a
> custom LayoutProvider in that case (also to resize the node, because the
> Size Computation Expression only allows square, but I need a rectangular
> node) to re-arrange the node inside to the position I want?
You can provide several LayoutProvider, or use one for different kind of
EditPart. In the UML2 example in the documentation[1], different
LayoutProviders are returned depending on the EditPart to layout.
>
> Thank you in Advance
> Frank


--
Steve Monnier - Obeo

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


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Provide own LayoutProvider [message #1739459 is a reply to message #1738996] Mon, 01 August 2016 22:05 Go to previous messageGo to next message
Frank Sorek is currently offline Frank SorekFriend
Messages: 22
Registered: February 2016
Junior Member
Thanks for your reply.

Now I know which tools I can use, but I don't know when to use them.
I have a custom LayoutProvider. In Debug Mode, I can see when the LayoutProvider is called, but it is not called in the time, I wish it would.

There a 2 szenarios where I want the LayoutProvider to do work.
First: When I hit the delete button or press del on my keyboard. I want to store the the position of the Element-to-delete and after the deletion I want to layout the childs of that element (with the method you told me)
Second: When I create a new Container (including a child-node for the label), I want the LayoutProvider to layout the child.

Re: Provide own LayoutProvider [message #1739471 is a reply to message #1739459] Tue, 02 August 2016 08:23 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

1/ For the deletion, you should create a delete tool, as the default behaviour is not enough. In this tool, before adding a remove operation, your should call a java service that will store the location of the selected element. The you will use the stored location in your custom layout.
2/ I am not sure to understand the "child-node for the label", as a container also have a label, why do you need a child node for it? Anyway, when you create the container it should trigger a call in your custom layout "layoutEditParts" method for your new container allowing you to access its children and layout them.


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Provide own LayoutProvider [message #1739535 is a reply to message #1739471] Tue, 02 August 2016 17:49 Go to previous messageGo to next message
Frank Sorek is currently offline Frank SorekFriend
Messages: 22
Registered: February 2016
Junior Member
No Message Body

[Updated on: Wed, 07 September 2016 18:08]

Report message to a moderator

Re: Provide own LayoutProvider [message #1739976 is a reply to message #1739535] Sat, 06 August 2016 11:36 Go to previous messageGo to next message
Frank Sorek is currently offline Frank SorekFriend
Messages: 22
Registered: February 2016
Junior Member
pls delete this post

[Updated on: Wed, 07 September 2016 18:09]

Report message to a moderator

Re: Provide own LayoutProvider [message #1742809 is a reply to message #1739976] Wed, 07 September 2016 18:22 Go to previous message
Frank Sorek is currently offline Frank SorekFriend
Messages: 22
Registered: February 2016
Junior Member
Note: Pls delete the two posts before.

My Deletion Tool is now working as wanted. But there is a problem with the Layout Provider. Because, it only worked for elements which has a depth up to 3. For Elements with a depth higher than 3, the Layout Provider is not even called. So I can not restore these elements. Is it possible to enlarge the depth?
Previous Topic:Tools defined in a disabled layer are active
Next Topic:Cannot add cross reference
Goto Forum:
  


Current Time: Thu Sep 26 07:56:03 GMT 2024

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

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

Back to the top