|
Re: Programmatically create nodes [message #1728908 is a reply to message #1728862] |
Fri, 08 April 2016 12:31 |
|
On 04/08/2016 07:49 AM, Martin Jedlicka wrote:
> Hi,
Hi Martin,
What is your need behind this ?
Sirius is based on GMF but it is no really intended for adding graphical
elements out of the classic mechanism "odesign file + semantic model =
diagram's graphical elements "
Nodes and their bounds are defined in the GMF model but in a Sirius
diagram displaying elements defined in a odesign it's more complicated.
With the semantic model and with what is defined in the odesign
(NodeMappings, containerMappings etc), Sirius produces a model composed
of DNode, DNodeContainer, DEdge etc.
Next, Sirius builds the GMF model based on that Sirius model.
You can take a look in
org.eclipse.sirius.diagram.business.internal.sync.DDiagramSynchronizer.refresh(IProgressMonitor).
This action refreshes the Sirius model according to the semantic model
and the odesign.
The GMF model is created using the CanonicalSynchronizer (see
org.eclipse.sirius.diagram.ui.internal.refresh.diagram.DDiagramCanonicalSynchronizer.synchronize())
>
> How to programmatically on display (in the Sirius) to create a node and
> set the location and size?
>
> Thanks.
>
> Martin
Regards,
--
Florian - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Re: Programmatically create nodes [message #1729364 is a reply to message #1729363] |
Wed, 13 April 2016 12:08 |
|
You can retrieve the GMF Node related to the DNode and set its Bounds
(node.getLayoutConstraint()). All the layout constraints are stored in
the GMF model.
On 04/13/2016 01:53 PM, Martin Jedlicka wrote:
> My main problem is that I do not know how to programmatically set the
> location of the node.
> DNode interface has methods to set the size (height and width), but not
> the location setting.
>
> I need to implement custom layout provider (class GridLayoutProvider),
> but I do not know how distribute the nodes in the diagram. I need
> specific nodes put on specific location.
>
> An example?
>
> Thank you very much.
--
Florian - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
Re: Programmatically create nodes [message #1729692 is a reply to message #1729682] |
Mon, 18 April 2016 07:38 |
|
Hi Martin,
It seems that you change the GMF Node bounds within the
getLayoutNodeProvider method. This method is not intended to execute the
layout and your code is probably called outside of a Transactional
Command (which is not authorized in the Sirius context).
Take a look on
org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.CompositeDownTopProvider
for instance. getLayoutNodeProvider returns a
AbstractLayoutEditPartProvider and this last has to provides the Command
that will be executed to perform the layout.
On 04/18/2016 07:57 AM, Martin Jedlicka wrote:
> Hi Florian,
>
> can you please write how to modify my code to set location of the nodes
> (previous post)?
>
> Thank you very much.
>
> Martin
Regards,
--
Florian - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
|
|
Re: Programmatically create nodes [message #1729903 is a reply to message #1729828] |
Wed, 20 April 2016 07:53 |
|
On 04/19/2016 01:56 PM, Martin Jedlicka wrote:
> Hi Florian,
Hi Martin,
In your code you are still modifying the GMF Bounds into the
getLayoutNodeProvider method. This method returns an
AbstractLayoutEditPartProvider that should do this job. In the
org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.CompositeDownTopProvider.getLayoutNodeProvider(IGraphicalEditPart)
method, there is not direct modification of the GMF Bounds.
> I also tried the following code, but still nothing.
>
>
> CompoundLayoutProvider clp = new CompoundLayoutProvider();
> processDiagramLayoutProvider = getProcessDiagramLayoutProvider(container);
> clp.addProvider(processDiagramLayoutProvider);
> this.layoutProvider = new ArrangeAllOnlyLayoutProvider(clp);
>
Try to set a breakpoint to make sure this code is properly called.
>
> Where is the mistake?
> Sorry for the questions, but I'll still get it.
Providing custom layouts is not an easy task which is unfortunately not
very well documented.
The best thing to do is still observing the existing code in debug mode
to understand how it works.
>
> Thanks.
>
> Martin
Regards,
--
Florian - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04099 seconds