Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Connection Handles
Connection Handles [message #76470] Fri, 10 November 2006 12:28 Go to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Hello,

I'm currently trying to activate the connection handles in my editor,
following the guide on
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/connectionCreationAssistantTutoria l.html
which is accessible through the new Documentations section in the Wiki.

But I'm having some problems with the "Create Connection to new Element"
functionality. I followed the guide and implemented the given methods
(getTypesForSource/Target) with creating a list and filling this list with
the element types. All of these types are displayed correctly in the list,
but the creation only works for ONE element type. For all the other
elements both the connection and the opposite end's element are created,
but the end elements seems not to be inserted in its container and doesn't
appear on the diagram, too (with the connection leading to the upper left
corner, as usual).

I have no clue why it works for this one element type but not for the
others, since there is nothing special about this element. No specific
contributions to the editpart or policy or whatever...

Well, actually I did not follow the guide in all points. I did not override
the provides-method, since I think the super method will do, too. In the
guide, the method returns false, if a feature shall not be supported and
else super, so this can't be the point, can it?
Second, I did not extend the existing extension point in the xml. But this
seems not to be the problem either, since as I said it works for one of the
elements...

Do you have any ideas what could be the reason for this behavior?

thanks,
tobias
Re: Connection Handles [message #76606 is a reply to message #76470] Fri, 10 November 2006 14:40 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Tobias,

If the list of element types and connection types is displayed
correctly, then your Modeling Assistant Provider is probably fine. The
issue seems to be with the creation of the connection.

Here are some things to try...

Do you have palette tools for the connection types that are not working
in the connection handles? If so, try using this palette tool to create
the connection from the shape on which the handles appear and the new
shape that gets created for the other end? If this works, then the
issue must be with the command that creates the other end and the
connection.

You can confirm that the issue is not with the connection handles
specifically by using the palette tool to create a connection from the
shape on which the handles appear to diagram space. The same popup
should appear as when you drag the connection handle (except there will
be no choice of connection types) and you will most likely have the same
issue.

The ContainerNodeEditPolicy is where the command is created to show the
popup, create the other end, and create the connection in your scenario.
I would suggest adding the following breakpoints to debug your code:
1. CreateViewAndOptionallyElementCommand.doExecuteWithResult() -- We
know the new target end is being created (because it appears on the
diagram), but confirm that the result of this command is being set to
the new node created by stepping into the setResult() code from here.
2. DeferredCreateConnectionViewAndElementCommand.doExecuteWithR esult()
-- Now, the targetViewAdapter variable should hold the new node created
by the previous command. Step through this code to confirm that the
source and target editparts are both correct.

I hope this helps.

- Cherie


tobias wrote:
> Hello,
>
> I'm currently trying to activate the connection handles in my editor,
> following the guide on
> http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/connectionCreationAssistantTutoria l.html
> which is accessible through the new Documentations section in the Wiki.
>
> But I'm having some problems with the "Create Connection to new Element"
> functionality. I followed the guide and implemented the given methods
> (getTypesForSource/Target) with creating a list and filling this list with
> the element types. All of these types are displayed correctly in the list,
> but the creation only works for ONE element type. For all the other
> elements both the connection and the opposite end's element are created,
> but the end elements seems not to be inserted in its container and doesn't
> appear on the diagram, too (with the connection leading to the upper left
> corner, as usual).
>
> I have no clue why it works for this one element type but not for the
> others, since there is nothing special about this element. No specific
> contributions to the editpart or policy or whatever...
>
> Well, actually I did not follow the guide in all points. I did not override
> the provides-method, since I think the super method will do, too. In the
> guide, the method returns false, if a feature shall not be supported and
> else super, so this can't be the point, can it?
> Second, I did not extend the existing extension point in the xml. But this
> seems not to be the problem either, since as I said it works for one of the
> elements...
>
> Do you have any ideas what could be the reason for this behavior?
>
> thanks,
> tobias
>
Re: Connection Handles [message #76810 is a reply to message #76606] Fri, 10 November 2006 18:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Thank you for your response.

I finally found the one little difference: In the EditPart of the one Type
it worked fine with I (luckily) forgot to install my customized
GraphicalNodeEditPolicy, overriding
getConnectionAndRelationshipCompleteCommand with super, except for the line
"cc.compose( new CommandProxy(viewCommand) );" being removed. This is
necessary for fixing the well-known duplicate-edges-bug. I'll try to adapt
this method so that it will skip the above said line only in special cases.
This should work, shouldn't it?

But can you give me advice, how to judge from the given Request wheather the
connection shall connect to an existing element or a new end shall be
created? I'm having some troubles debugging it, because I'm always brought
to the debugging screen as soon as I start the connection...

tobias

Cherie Revells wrote:
> Tobias,
>
> If the list of element types and connection types is displayed
> correctly, then your Modeling Assistant Provider is probably fine. The
> issue seems to be with the creation of the connection.
>
> Here are some things to try...
>
> Do you have palette tools for the connection types that are not working
> in the connection handles? If so, try using this palette tool to create
> the connection from the shape on which the handles appear and the new
> shape that gets created for the other end? If this works, then the
> issue must be with the command that creates the other end and the
> connection.
>
> You can confirm that the issue is not with the connection handles
> specifically by using the palette tool to create a connection from the
> shape on which the handles appear to diagram space. The same popup
> should appear as when you drag the connection handle (except there will
> be no choice of connection types) and you will most likely have the same
> issue.
>
> The ContainerNodeEditPolicy is where the command is created to show the
> popup, create the other end, and create the connection in your scenario.
> I would suggest adding the following breakpoints to debug your code:
> 1. CreateViewAndOptionallyElementCommand.doExecuteWithResult() -- We
> know the new target end is being created (because it appears on the
> diagram), but confirm that the result of this command is being set to
> the new node created by stepping into the setResult() code from here.
> 2. DeferredCreateConnectionViewAndElementCommand.doExecuteWithR esult()
> -- Now, the targetViewAdapter variable should hold the new node created
> by the previous command. Step through this code to confirm that the
> source and target editparts are both correct.
>
> I hope this helps.
>
> - Cherie
>
>
> tobias wrote:
>> Hello,
>>
>> I'm currently trying to activate the connection handles in my editor,
>> following the guide on
>>
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/connectionCreationAssistantTutoria l.html
>> which is accessible through the new Documentations section in the Wiki.
>>
>> But I'm having some problems with the "Create Connection to new Element"
>> functionality. I followed the guide and implemented the given methods
>> (getTypesForSource/Target) with creating a list and filling this list
>> with the element types. All of these types are displayed correctly in the
>> list, but the creation only works for ONE element type. For all the other
>> elements both the connection and the opposite end's element are created,
>> but the end elements seems not to be inserted in its container and
>> doesn't appear on the diagram, too (with the connection leading to the
>> upper left corner, as usual).
>>
>> I have no clue why it works for this one element type but not for the
>> others, since there is nothing special about this element. No specific
>> contributions to the editpart or policy or whatever...
>>
>> Well, actually I did not follow the guide in all points. I did not
>> override the provides-method, since I think the super method will do,
>> too. In the guide, the method returns false, if a feature shall not be
>> supported and else super, so this can't be the point, can it?
>> Second, I did not extend the existing extension point in the xml. But
>> this seems not to be the problem either, since as I said it works for one
>> of the elements...
>>
>> Do you have any ideas what could be the reason for this behavior?
>>
>> thanks,
>> tobias
>>
Re: Connection Handles [message #76840 is a reply to message #76810] Fri, 10 November 2006 18:50 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Tobias,

If I understand the duplicate edges bug correctly, you are just
overriding the GraphicalNodeEditPolicy to temporarily fix this bug and
your fix is to create a new element for the connection, but not the
view. Is that correct? The same fix should apply regardless of whether
the connection is being created with the palette tool, connection
handle, to a new end, or existing end (in theory). Why do you need to
know whether the connection shall connect to an existing element or a
new end?

Here's a little debugging tip...
Add a breakpoint property to your breakpoint in
getConnectionAndRelationshipCompleteCommand() that looks like this:
request.getSourceEditPart() != request.getTargetEditPart()
You are probably hitting your breakpoint early because the creation tool
is asking the source shape to create a connection to itself.

- Cherie


tobias wrote:
> Thank you for your response.
>
> I finally found the one little difference: In the EditPart of the one Type
> it worked fine with I (luckily) forgot to install my customized
> GraphicalNodeEditPolicy, overriding
> getConnectionAndRelationshipCompleteCommand with super, except for the line
> "cc.compose( new CommandProxy(viewCommand) );" being removed. This is
> necessary for fixing the well-known duplicate-edges-bug. I'll try to adapt
> this method so that it will skip the above said line only in special cases.
> This should work, shouldn't it?
>
> But can you give me advice, how to judge from the given Request wheather the
> connection shall connect to an existing element or a new end shall be
> created? I'm having some troubles debugging it, because I'm always brought
> to the debugging screen as soon as I start the connection...
>
> tobias
>
> Cherie Revells wrote:
>> Tobias,
>>
>> If the list of element types and connection types is displayed
>> correctly, then your Modeling Assistant Provider is probably fine. The
>> issue seems to be with the creation of the connection.
>>
>> Here are some things to try...
>>
>> Do you have palette tools for the connection types that are not working
>> in the connection handles? If so, try using this palette tool to create
>> the connection from the shape on which the handles appear and the new
>> shape that gets created for the other end? If this works, then the
>> issue must be with the command that creates the other end and the
>> connection.
>>
>> You can confirm that the issue is not with the connection handles
>> specifically by using the palette tool to create a connection from the
>> shape on which the handles appear to diagram space. The same popup
>> should appear as when you drag the connection handle (except there will
>> be no choice of connection types) and you will most likely have the same
>> issue.
>>
>> The ContainerNodeEditPolicy is where the command is created to show the
>> popup, create the other end, and create the connection in your scenario.
>> I would suggest adding the following breakpoints to debug your code:
>> 1. CreateViewAndOptionallyElementCommand.doExecuteWithResult() -- We
>> know the new target end is being created (because it appears on the
>> diagram), but confirm that the result of this command is being set to
>> the new node created by stepping into the setResult() code from here.
>> 2. DeferredCreateConnectionViewAndElementCommand.doExecuteWithR esult()
>> -- Now, the targetViewAdapter variable should hold the new node created
>> by the previous command. Step through this code to confirm that the
>> source and target editparts are both correct.
>>
>> I hope this helps.
>>
>> - Cherie
>>
>>
>> tobias wrote:
>>> Hello,
>>>
>>> I'm currently trying to activate the connection handles in my editor,
>>> following the guide on
>>>
> http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/connectionCreationAssistantTutoria l.html
>>> which is accessible through the new Documentations section in the Wiki.
>>>
>>> But I'm having some problems with the "Create Connection to new Element"
>>> functionality. I followed the guide and implemented the given methods
>>> (getTypesForSource/Target) with creating a list and filling this list
>>> with the element types. All of these types are displayed correctly in the
>>> list, but the creation only works for ONE element type. For all the other
>>> elements both the connection and the opposite end's element are created,
>>> but the end elements seems not to be inserted in its container and
>>> doesn't appear on the diagram, too (with the connection leading to the
>>> upper left corner, as usual).
>>>
>>> I have no clue why it works for this one element type but not for the
>>> others, since there is nothing special about this element. No specific
>>> contributions to the editpart or policy or whatever...
>>>
>>> Well, actually I did not follow the guide in all points. I did not
>>> override the provides-method, since I think the super method will do,
>>> too. In the guide, the method returns false, if a feature shall not be
>>> supported and else super, so this can't be the point, can it?
>>> Second, I did not extend the existing extension point in the xml. But
>>> this seems not to be the problem either, since as I said it works for one
>>> of the elements...
>>>
>>> Do you have any ideas what could be the reason for this behavior?
>>>
>>> thanks,
>>> tobias
>>>
>
Re: Connection Handles [message #76856 is a reply to message #76810] Fri, 10 November 2006 18:56 Go to previous message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

OK, I found out that when I want to create a new Element, request.location
is null. So what I do now is skipping that ominous line if the location is
not null. Result: Works fine for creating Connections to existing elements
(no duplicate lines) and for creating connections to new top level
elements.

But it seems that with this approach I can not have both: When I create
connections to new nested Elements (with the connections contained some
levels higher) the duplicate connections are back...

But if the connection's view is created twice... where is the other one
created? Maybe one could remove this and keep the other one instead...

Any other ideas? I mean, this HAS to work somehow... *g*

tobias

tobias wrote:
> Thank you for your response.
>
> I finally found the one little difference: In the EditPart of the one Type
> it worked fine with I (luckily) forgot to install my customized
> GraphicalNodeEditPolicy, overriding
> getConnectionAndRelationshipCompleteCommand with super, except for the
> line "cc.compose( new CommandProxy(viewCommand) );" being removed. This is
> necessary for fixing the well-known duplicate-edges-bug. I'll try to adapt
> this method so that it will skip the above said line only in special
> cases. This should work, shouldn't it?
>
> But can you give me advice, how to judge from the given Request wheather
> the connection shall connect to an existing element or a new end shall be
> created? I'm having some troubles debugging it, because I'm always brought
> to the debugging screen as soon as I start the connection...
>
> tobias
>
> Cherie Revells wrote:
>> Tobias,
>>
>> If the list of element types and connection types is displayed
>> correctly, then your Modeling Assistant Provider is probably fine. The
>> issue seems to be with the creation of the connection.
>>
>> Here are some things to try...
>>
>> Do you have palette tools for the connection types that are not working
>> in the connection handles? If so, try using this palette tool to create
>> the connection from the shape on which the handles appear and the new
>> shape that gets created for the other end? If this works, then the
>> issue must be with the command that creates the other end and the
>> connection.
>>
>> You can confirm that the issue is not with the connection handles
>> specifically by using the palette tool to create a connection from the
>> shape on which the handles appear to diagram space. The same popup
>> should appear as when you drag the connection handle (except there will
>> be no choice of connection types) and you will most likely have the same
>> issue.
>>
>> The ContainerNodeEditPolicy is where the command is created to show the
>> popup, create the other end, and create the connection in your scenario.
>> I would suggest adding the following breakpoints to debug your code:
>> 1. CreateViewAndOptionallyElementCommand.doExecuteWithResult() -- We
>> know the new target end is being created (because it appears on the
>> diagram), but confirm that the result of this command is being set to
>> the new node created by stepping into the setResult() code from here.
>> 2. DeferredCreateConnectionViewAndElementCommand.doExecuteWithR esult()
>> -- Now, the targetViewAdapter variable should hold the new node created
>> by the previous command. Step through this code to confirm that the
>> source and target editparts are both correct.
>>
>> I hope this helps.
>>
>> - Cherie
>>
>>
>> tobias wrote:
>>> Hello,
>>>
>>> I'm currently trying to activate the connection handles in my editor,
>>> following the guide on
>>>
>
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/connectionCreationAssistantTutoria l.html
>>> which is accessible through the new Documentations section in the Wiki.
>>>
>>> But I'm having some problems with the "Create Connection to new Element"
>>> functionality. I followed the guide and implemented the given methods
>>> (getTypesForSource/Target) with creating a list and filling this list
>>> with the element types. All of these types are displayed correctly in
>>> the list, but the creation only works for ONE element type. For all the
>>> other elements both the connection and the opposite end's element are
>>> created, but the end elements seems not to be inserted in its container
>>> and doesn't appear on the diagram, too (with the connection leading to
>>> the upper left corner, as usual).
>>>
>>> I have no clue why it works for this one element type but not for the
>>> others, since there is nothing special about this element. No specific
>>> contributions to the editpart or policy or whatever...
>>>
>>> Well, actually I did not follow the guide in all points. I did not
>>> override the provides-method, since I think the super method will do,
>>> too. In the guide, the method returns false, if a feature shall not be
>>> supported and else super, so this can't be the point, can it?
>>> Second, I did not extend the existing extension point in the xml. But
>>> this seems not to be the problem either, since as I said it works for
>>> one of the elements...
>>>
>>> Do you have any ideas what could be the reason for this behavior?
>>>
>>> thanks,
>>> tobias
>>>
Previous Topic:DiagramEditor.isDirty() + FileDiagramModificationListener
Next Topic:extendedPO2 model
Goto Forum:
  


Current Time: Thu Jul 18 03:44:37 GMT 2024

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

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

Back to the top