Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » adding action to editparts
adding action to editparts [message #210216] Fri, 31 October 2008 19:25 Go to next message
Eclipse UserFriend
Originally posted by: kelvinng.db.gmail.com

Can someone give me a quick overview of how I can add context menu
actions to editparts?

I managed to get an action to show up for my editpart, but I'm trying
to place that in sub-menu in the context menu.

~Kelvin Ng
Re: adding action to editparts [message #210256 is a reply to message #210216] Sun, 02 November 2008 03:45 Go to previous messageGo to next message
Jeff is currently offline JeffFriend
Messages: 3
Registered: July 2009
Junior Member
hi Kelvin, I don't know whether that's what you want, wish help:

<extension point="org.eclipse.ui.popupMenus">
<?gmfgen generated="false"?>
<objectContribution
adaptable="false"
id="...your objectContribution id"
objectClass="...your editpart full class name">
<action
class="...your action full class name"
enablesFor="..."
icon="..."
id="your action id"
label="..."
menubarPath="...">
</action>
</objectContribution>
</extension>

as an action, you have to implement the interface IObjectActionDelegate




Kelvin Ng :
> Can someone give me a quick overview of how I can add context menu
> actions to editparts?
>
> I managed to get an action to show up for my editpart, but I'm trying to
> place that in sub-menu in the context menu.
>
> ~Kelvin Ng
>
Fw: Re: adding action to editparts [message #210404 is a reply to message #210256] Wed, 05 November 2008 11:06 Go to previous messageGo to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
Hello!

I've created the class that implements the action, added by me to the
edit part.

The question is: how to get a reference to the edit part in the run()
method (or anywhere else)? I need to know the values of some properties
of the domain element, which edit part is the "owner" of the popup.

So, how to do it better?

Thanks!

Viktor

Jeff пишет:
> hi Kelvin, I don't know whether that's what you want, wish help:
>
> <extension point="org.eclipse.ui.popupMenus">
> <?gmfgen generated="false"?>
> <objectContribution
> adaptable="false"
> id="...your objectContribution id"
> objectClass="...your editpart full class name">
> <action
> class="...your action full class name"
> enablesFor="..."
> icon="..."
> id="your action id"
> label="..."
> menubarPath="...">
> </action>
> </objectContribution>
> </extension>
>
> as an action, you have to implement the interface IObjectActionDelegate
>
>
>
>
> Kelvin Ng :
>> Can someone give me a quick overview of how I can add context menu
>> actions to editparts?
>>
>> I managed to get an action to show up for my editpart, but I'm trying
>> to place that in sub-menu in the context menu.
>>
>> ~Kelvin Ng
>>
Re: Fw: Re: adding action to editparts [message #210447 is a reply to message #210404] Wed, 05 November 2008 14:43 Go to previous messageGo to next message
Linda Damus is currently offline Linda DamusFriend
Messages: 85
Registered: July 2009
Member
Viktor,

The implementation in
org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDiagramMo delActionDelegate#getElements(ISelection)
might be what you're looking for. Your action delegate could extend
this one and inherit the behaviour.

Regards,
Linda


Viktor Kazakov wrote:
> Hello!
>
> I've created the class that implements the action, added by me to the
> edit part.
>
> The question is: how to get a reference to the edit part in the run()
> method (or anywhere else)? I need to know the values of some properties
> of the domain element, which edit part is the "owner" of the popup.
>
> So, how to do it better?
>
> Thanks!
>
> Viktor
>
> Jeff пишет:
>> hi Kelvin, I don't know whether that's what you want, wish help:
>>
>> <extension point="org.eclipse.ui.popupMenus">
>> <?gmfgen generated="false"?>
>> <objectContribution
>> adaptable="false"
>> id="...your objectContribution id"
>> objectClass="...your editpart full class name">
>> <action
>> class="...your action full class name"
>> enablesFor="..."
>> icon="..."
>> id="your action id"
>> label="..."
>> menubarPath="...">
>> </action>
>> </objectContribution>
>> </extension>
>>
>> as an action, you have to implement the interface IObjectActionDelegate
>>
>>
>>
>>
>> Kelvin Ng :
>>> Can someone give me a quick overview of how I can add context menu
>>> actions to editparts?
>>>
>>> I managed to get an action to show up for my editpart, but I'm trying
>>> to place that in sub-menu in the context menu.
>>>
>>> ~Kelvin Ng
>>>
Re: adding action to editparts [message #210476 is a reply to message #210216] Wed, 05 November 2008 18:58 Go to previous message
Tatiana Fesenko is currently offline Tatiana FesenkoFriend
Messages: 530
Registered: July 2009
Senior Member
Hi Kelvin,

I guess, the simpliest way to create a popup menu action is to add CustomAction
element to your GMFGen model (bug 174961):
1) Open GMFGen model
2) Select GenDiagram element. Create 'Context Menu' element inside it. Set
required 'context'(e.d. DiagramEditPart) and 'id' properties.
3) Create 'Custom Action' inside the newly created Context Menu. Set 'name'
and 'id' property. If you change 'Generate boilerplate implementation' from
'false' to 'true', action stub will be generated for you.
4) Generate diagram code

The functionality is just-implemented, it will be available in upcoming M3
build.
Best wishes,
Tanya.

> Can someone give me a quick overview of how I can add context menu
> actions to editparts?
>
> I managed to get an action to show up for my editpart, but I'm trying
> to place that in sub-menu in the context menu.
>
> ~Kelvin Ng
>
Previous Topic:Error opening diagram files
Next Topic:testing tool for the editor?
Goto Forum:
  


Current Time: Mon Jan 18 00:12:02 GMT 2021

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

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

Back to the top