Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How do I pre-populate a sub-diagram?
How do I pre-populate a sub-diagram? [message #757857] Wed, 16 November 2011 05:01 Go to next message
Nigel Daniels is currently offline Nigel Daniels
Messages: 66
Registered: July 2009
Member
Hi,

I am working on a project in which I like to pre-populate a diagram with
some elements so that the user can focus on the task in hand. I already
have this working on the main diagram, in this case I have added a
static method *DiagramEditorUtil.createInitialLayout(DiagramEditPart
diagram) that is called by the diagram creation wizard to add and layout
the necessary elements.

When I tried to take the same approach for a sub-diagram (opened using
diagram partitioning) this approach fails. I tried to add the
appropriate method call to the OpenDiagramEditPolicy but the EditParts
that get returned are all DummyEditParts. It seems that the
OpenDiagramEditPolicy does not actually open the diagram itself.

Can anyone suggest where a better place may be to add my call? I cannot
see where in the GMF generated code the opening of the diagram happens,
so I suspect this is buried elsewhere in the stack. Is there a better
place for me to do this? I have been trying to identify a point in the
diagrams lifecycle where I could add the call? Specifically is there a
'do stuff once I'm opened' point that would make sense for me to use?

BTW. I have tried adding the elements directly to the model, and they do
get drawn. However I am not able to control the layout of elements in
using this approach. I still need to find a place suggested above to
control the layout.

I'd rather not leave the diagram looking a mess that the user then has
to sort out.

Thanks for any advice,

Nigel
Re: How do I pre-populate a sub-diagram? [message #757859 is a reply to message #757857] Fri, 18 November 2011 08:32 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel Daniels
Messages: 66
Registered: July 2009
Member
Hi,

further debugging turns up that when I form a request and execute a
command on the diagram EditPart when setting up the main diagram I can
see the other EditParts appear as children of the diagram. However when
I do the same thing with the sub-diagram nothing is added but the
command seems to have executed ok.

If any one else has got his to work I could really do with your advice,

Nigel

On 16/11/2011 10:01, Nigel Daniels wrote:
> Hi,
>
> I am working on a project in which I like to pre-populate a diagram with
> some elements so that the user can focus on the task in hand. I already
> have this working on the main diagram, in this case I have added a
> static method *DiagramEditorUtil.createInitialLayout(DiagramEditPart
> diagram) that is called by the diagram creation wizard to add and layout
> the necessary elements.
>
> When I tried to take the same approach for a sub-diagram (opened using
> diagram partitioning) this approach fails. I tried to add the
> appropriate method call to the OpenDiagramEditPolicy but the EditParts
> that get returned are all DummyEditParts. It seems that the
> OpenDiagramEditPolicy does not actually open the diagram itself.
>
> Can anyone suggest where a better place may be to add my call? I cannot
> see where in the GMF generated code the opening of the diagram happens,
> so I suspect this is buried elsewhere in the stack. Is there a better
> place for me to do this? I have been trying to identify a point in the
> diagrams lifecycle where I could add the call? Specifically is there a
> 'do stuff once I'm opened' point that would make sense for me to use?
>
> BTW. I have tried adding the elements directly to the model, and they do
> get drawn. However I am not able to control the layout of elements in
> using this approach. I still need to find a place suggested above to
> control the layout.
>
> I'd rather not leave the diagram looking a mess that the user then has
> to sort out.
>
> Thanks for any advice,
>
> Nigel
Re: How do I pre-populate a sub-diagram? [message #757860 is a reply to message #757859] Fri, 18 November 2011 08:59 Go to previous messageGo to next message
Nigel Daniels is currently offline Nigel Daniels
Messages: 66
Registered: July 2009
Member
One further finding, if I only add nodes to the diagram then even though
I do not see them added to the diagram EditPart the diagram continues to
open and the items I added are there. But because it seems my commands
are not executing until a later point I cannot access the compartments
to add and place nodes that should appear within those EditParts.

On 18/11/2011 13:32, Nigel Daniels wrote:
> Hi,
>
> further debugging turns up that when I form a request and execute a
> command on the diagram EditPart when setting up the main diagram I can
> see the other EditParts appear as children of the diagram. However when
> I do the same thing with the sub-diagram nothing is added but the
> command seems to have executed ok.
>
> If any one else has got his to work I could really do with your advice,
>
> Nigel
>
> On 16/11/2011 10:01, Nigel Daniels wrote:
>> Hi,
>>
>> I am working on a project in which I like to pre-populate a diagram with
>> some elements so that the user can focus on the task in hand. I already
>> have this working on the main diagram, in this case I have added a
>> static method *DiagramEditorUtil.createInitialLayout(DiagramEditPart
>> diagram) that is called by the diagram creation wizard to add and layout
>> the necessary elements.
>>
>> When I tried to take the same approach for a sub-diagram (opened using
>> diagram partitioning) this approach fails. I tried to add the
>> appropriate method call to the OpenDiagramEditPolicy but the EditParts
>> that get returned are all DummyEditParts. It seems that the
>> OpenDiagramEditPolicy does not actually open the diagram itself.
>>
>> Can anyone suggest where a better place may be to add my call? I cannot
>> see where in the GMF generated code the opening of the diagram happens,
>> so I suspect this is buried elsewhere in the stack. Is there a better
>> place for me to do this? I have been trying to identify a point in the
>> diagrams lifecycle where I could add the call? Specifically is there a
>> 'do stuff once I'm opened' point that would make sense for me to use?
>>
>> BTW. I have tried adding the elements directly to the model, and they do
>> get drawn. However I am not able to control the layout of elements in
>> using this approach. I still need to find a place suggested above to
>> control the layout.
>>
>> I'd rather not leave the diagram looking a mess that the user then has
>> to sort out.
>>
>> Thanks for any advice,
>>
>> Nigel
>
Re: How do I pre-populate a sub-diagram? [message #758324 is a reply to message #757860] Tue, 22 November 2011 13:15 Go to previous messageGo to next message
Hoang  is currently offline Hoang
Messages: 45
Registered: September 2011
Location: Milan
Member
This is a good idea. I am looking for the same solution for this problem.

Have you found the solution? Could you please post the sample code so that others can take a look at it?

Thanks.
Re: How do I pre-populate a sub-diagram? [message #758777 is a reply to message #758324] Thu, 24 November 2011 09:15 Go to previous message
Nigel Daniels is currently offline Nigel Daniels
Messages: 66
Registered: July 2009
Member
Hi Hoang,

I have not found a solution to the problem but I have found a
workaround. I created a command triggered by a pop-up menu item that
appears when the element I want to expand into a sub-diagram is
right-clicked. I have then manually implemented code that is similar to
the OpenDiagramBehaviour. I have also removed the original
OpenDiagramBehavior so I am programatically inserting the DiagramFacets
as I need them.

A side effect of this approach is this would allow me to open multiple
sub-diagrams from the same point. While it's a neat side effect it makes
the user experiance a bit less intuative than I would like.

I hope this helps,

Nigel

On 22/11/2011 18:15, Hoang wrote:
> This is a good idea. I am looking for the same solution for this problem.
> Have you found the solution? Could you please post the sample code so
> that others can take a look at it?
>
> Thanks.
Previous Topic:GMF + EMF + commandstack
Next Topic:Use of xxx.diagram.navigator package classes in GMF
Goto Forum:
  


Current Time: Thu Jul 24 21:50:39 EDT 2014

Powered by FUDForum. Page generated in 0.02329 seconds