Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to add additional Node info in Diagram on MouseOver (Hover)
How to add additional Node info in Diagram on MouseOver (Hover) [message #144830] Mon, 30 July 2007 17:37 Go to next message
Eclipse UserFriend
Originally posted by: christian.wittner.siemens.com

Hi,

I try to implement an additional information displayed when a user hovers
over a diagram element.
It should appear like the ConnectionArrows.
I tried to add a MouseMotionListener to the shape defined for the
ModelElementEditPart but this prevents the ConnectionArrows from
appearing. Can I re-throw/forward the event to the
ConnectionHandleEditPolicy ? I thought i perhaps have to add my own
EditPolicy. But I don't know which would be the correct Slot for it. And
if I would put it in the ConnectionHandleSlot I would replace the current
one. But I would like to add it, as I don't want to replace the current
behavior. I want to extend it.
What is the way I should do that? Should I derive my own
ConnectionHandleEditPolicy and have it triggering the display of
additional information for me?
I appreciate any suggestion how this mechanism I supposed to be used. I
see where the figure is edit to an element's EditPart but I don't know
where the EditPolicies are connected to the MouseEvents raised by the UI
representation of the Element.

Thx for any hint in adance,

Christian Wittner
Re: How to add additional Node info in Diagram on MouseOver (Hover) [message #144839 is a reply to message #144830] Mon, 30 July 2007 19:12 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Christian,

If you are extending the behavior of the current connection handles and
you want to reuse some of the pieces in the ConnectionHandle classes,
then you could create a subclass of the ConnectionHandleEditPolicy,
install it on the existing connection handles role, and modify it as you
require to popup your UI as well. You would probably want to start by
overriding the method showDiagramAssistant() to add you custom handle
figures.

However, if the additional information you want to popup is not similar
to the connection handles except for the fact that it pops up when you
hover on the shape, then I would suggest writing your own editpolicy and
installing it on a new editpolicy role. The editpolicy roles are meant
as a way to change existing behavior, so if you are adding new behavior
you can create a new role.

Both the ConnectionHandleEditPolicy and the PopupBarEditPolicy (the
little balloon on top of the shapes) subclass from
DiagramAssistantEditPolicy. This editpolicy will handle all the mouse
events for you and it would not interfere with the mouse events to the
ConnectionHandleEditPolicy so you wouldn't have to worry about that.

Regards,
Cherie

Christian Wittner wrote:
> Hi,
>
> I try to implement an additional information displayed when a user
> hovers over a diagram element.
> It should appear like the ConnectionArrows.
> I tried to add a MouseMotionListener to the shape defined for the
> ModelElementEditPart but this prevents the ConnectionArrows from
> appearing. Can I re-throw/forward the event to the
> ConnectionHandleEditPolicy ? I thought i perhaps have to add my own
> EditPolicy. But I don't know which would be the correct Slot for it. And
> if I would put it in the ConnectionHandleSlot I would replace the
> current one. But I would like to add it, as I don't want to replace the
> current behavior. I want to extend it.
> What is the way I should do that? Should I derive my own
> ConnectionHandleEditPolicy and have it triggering the display of
> additional information for me?
> I appreciate any suggestion how this mechanism I supposed to be used. I
> see where the figure is edit to an element's EditPart but I don't know
> where the EditPolicies are connected to the MouseEvents raised by the UI
> representation of the Element.
>
> Thx for any hint in adance,
>
> Christian Wittner
>
Re: How to add additional Node info in Diagram on MouseOver (Hover) [message #144893 is a reply to message #144839] Tue, 31 July 2007 02:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.wittner.siemens.com

Cherie,

Thanks for the advice.

The second options sounds like what I want. The only similarity is that I
want my Information to appear as the mouse hovers over the diagram element.
I thought there are only predefined slots I can use. How would I create a
role that is triggered when I mouse over an element? I have a vague idea
how to create a policy by deriving from DiagramAssistantEditPolicy but no
idea how to create a role/slot where to load it into.
Is there a tutorial of how to add own behavior to an element?

Best Regards,
Christian Wittner

Cherie Revells wrote:

> Christian,

> If you are extending the behavior of the current connection handles and
> you want to reuse some of the pieces in the ConnectionHandle classes,
> then you could create a subclass of the ConnectionHandleEditPolicy,
> install it on the existing connection handles role, and modify it as you
> require to popup your UI as well. You would probably want to start by
> overriding the method showDiagramAssistant() to add you custom handle
> figures.

> However, if the additional information you want to popup is not similar
> to the connection handles except for the fact that it pops up when you
> hover on the shape, then I would suggest writing your own editpolicy and
> installing it on a new editpolicy role. The editpolicy roles are meant
> as a way to change existing behavior, so if you are adding new behavior
> you can create a new role.

> Both the ConnectionHandleEditPolicy and the PopupBarEditPolicy (the
> little balloon on top of the shapes) subclass from
> DiagramAssistantEditPolicy. This editpolicy will handle all the mouse
> events for you and it would not interfere with the mouse events to the
> ConnectionHandleEditPolicy so you wouldn't have to worry about that.

> Regards,
> Cherie

> Christian Wittner wrote:
>> Hi,
>>
>> I try to implement an additional information displayed when a user
>> hovers over a diagram element.
>> It should appear like the ConnectionArrows.
>> I tried to add a MouseMotionListener to the shape defined for the
>> ModelElementEditPart but this prevents the ConnectionArrows from
>> appearing. Can I re-throw/forward the event to the
>> ConnectionHandleEditPolicy ? I thought i perhaps have to add my own
>> EditPolicy. But I don't know which would be the correct Slot for it. And
>> if I would put it in the ConnectionHandleSlot I would replace the
>> current one. But I would like to add it, as I don't want to replace the
>> current behavior. I want to extend it.
>> What is the way I should do that? Should I derive my own
>> ConnectionHandleEditPolicy and have it triggering the display of
>> additional information for me?
>> I appreciate any suggestion how this mechanism I supposed to be used. I
>> see where the figure is edit to an element's EditPart but I don't know
>> where the EditPolicies are connected to the MouseEvents raised by the UI
>> representation of the Element.
>>
>> Thx for any hint in adance,
>>
>> Christian Wittner
>>
Re: How to add additional Node info in Diagram on MouseOver (Hover) [message #144944 is a reply to message #144893] Tue, 31 July 2007 12:36 Go to previous message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Christian,

The role is only used as a mechanism to override editpolicies.
Editpolicies are installed on an editpart. When an editpart is sent a
request it asks ALL editpolicies if they want to provide a command. The
role is not relevant here.

In the case of your editpolicy, it won't be responding to a request.
Instead, you will be installing a mouse listener to catch mouse events
(actually this is all done in the superclass DiagramAssistantEditPolicy
for you). The editpart will activate and deactivate the editpolicy when
appropriate.

The role is important if you want to try to override an editpolicy that
is already installed (i.e. remove it and add yours instead). If nobody
is going to be extending your new diagram assistant, then it doesn't
matter what the role is, just create an identifier.

For a better explanation, take a look at the section titled
"EditPolicies" in the GEF documentation:
http://help.eclipse.org/help33/topic/org.eclipse.gef.doc.isv /guide/guide.html?resultof=%22%65%64%69%74%70%6f%6c%69%63%79 %22%20%22%65%64%69%74%70%6f%6c%69%63%69%22%20%22%72%6f%6c%65 %22%20

Regards,
Cherie

Christian Wittner wrote:
> Cherie,
>
> Thanks for the advice.
>
> The second options sounds like what I want. The only similarity is that
> I want my Information to appear as the mouse hovers over the diagram
> element.
> I thought there are only predefined slots I can use. How would I create
> a role that is triggered when I mouse over an element? I have a vague
> idea how to create a policy by deriving from DiagramAssistantEditPolicy
> but no idea how to create a role/slot where to load it into.
> Is there a tutorial of how to add own behavior to an element?
>
> Best Regards,
> Christian Wittner
>
> Cherie Revells wrote:
>
>> Christian,
>
>> If you are extending the behavior of the current connection handles
>> and you want to reuse some of the pieces in the ConnectionHandle
>> classes, then you could create a subclass of the
>> ConnectionHandleEditPolicy, install it on the existing connection
>> handles role, and modify it as you require to popup your UI as well.
>> You would probably want to start by overriding the method
>> showDiagramAssistant() to add you custom handle figures.
>
>> However, if the additional information you want to popup is not
>> similar to the connection handles except for the fact that it pops up
>> when you hover on the shape, then I would suggest writing your own
>> editpolicy and installing it on a new editpolicy role. The editpolicy
>> roles are meant as a way to change existing behavior, so if you are
>> adding new behavior you can create a new role.
>
>> Both the ConnectionHandleEditPolicy and the PopupBarEditPolicy (the
>> little balloon on top of the shapes) subclass from
>> DiagramAssistantEditPolicy. This editpolicy will handle all the mouse
>> events for you and it would not interfere with the mouse events to the
>> ConnectionHandleEditPolicy so you wouldn't have to worry about that.
>
>> Regards,
>> Cherie
>
>> Christian Wittner wrote:
>>> Hi,
>>>
>>> I try to implement an additional information displayed when a user
>>> hovers over a diagram element.
>>> It should appear like the ConnectionArrows.
>>> I tried to add a MouseMotionListener to the shape defined for the
>>> ModelElementEditPart but this prevents the ConnectionArrows from
>>> appearing. Can I re-throw/forward the event to the
>>> ConnectionHandleEditPolicy ? I thought i perhaps have to add my own
>>> EditPolicy. But I don't know which would be the correct Slot for it.
>>> And if I would put it in the ConnectionHandleSlot I would replace the
>>> current one. But I would like to add it, as I don't want to replace
>>> the current behavior. I want to extend it.
>>> What is the way I should do that? Should I derive my own
>>> ConnectionHandleEditPolicy and have it triggering the display of
>>> additional information for me?
>>> I appreciate any suggestion how this mechanism I supposed to be used.
>>> I see where the figure is edit to an element's EditPart but I don't
>>> know where the EditPolicies are connected to the MouseEvents raised
>>> by the UI representation of the Element.
>>>
>>> Thx for any hint in adance,
>>>
>>> Christian Wittner
>>>
>
Previous Topic:Puprose of EditHelper and EditHelperAdvice ?
Next Topic:Compartment with inherited classes
Goto Forum:
  


Current Time: Tue Jul 16 06:16:13 GMT 2024

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

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

Back to the top