Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Add actions from different plugins
Add actions from different plugins [message #334974] Fri, 13 March 2009 04:43 Go to next message
Ravi is currently offline RaviFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

How to programmatically add actions from two different plug-ins to the
same menubarPath in a popup menu?

In the first plug-in (lets call plug-in A), I create a menu and add an
action in the popup menu.

From a second plug-in (lets call plug-in B), I need to add an action
"Action 2" to the menubarPath "MenuID/SeparatorName". How can this be
achieved?

Basically, I want to achieve the below -
MenuName -> Action 1 (MenuName and Action 1 is from plug-in A)
Action 2 (Action 2 is from plug-in B)

Thanks.
Re: Add actions from different plugins [message #334989 is a reply to message #334974] Fri, 13 March 2009 17:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

With actions, this only works for
org.eclipse.ui.popupMenus/objectContributions

With commands you can more easily create submenus and contribute to them
separately.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Add actions from different plugins [message #335002 is a reply to message #334989] Sat, 14 March 2009 23:21 Go to previous messageGo to next message
Ravi is currently offline RaviFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks for the response, Paul.

I read through the example of using commands to create submenus and
commands in views.

I added the below in the plugin.xml to dynamically add a command. In the
class TestCompoundContributionItem, method getContributionItems(), I
return a contribution item. I also implemented the handler class. This
command shows up in all popup menus. How can I filter for specific
resource objects?

<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions ">
<dynamic
class="com.actions.TestCompoundContributionItem"
id="com.actions.TestCompoundContributionItem">
</dynamic>
</menuContribution>
</extension>

<extension
point="org.eclipse.ui.commands">
<category
id="com.actions.TestCommandCategory"
name="Test Command Category">
</category>
<command
categoryId="com.actions.TestCommandCategory"
id="com.actions.TestCommand"
name="Test Command">
</command>
</extension>

<extension
point="org.eclipse.ui.handlers">
<handler
class="com.actions.TestHandler"
commandId="com.actions.TestCommand">
</handler>
</extension>

Extending the above, how can I create a submenu and then add a command
(action) to the submenu in a popup menu? Which call back do I need to
implement?

Just to be clear, here is what I plan to achieve in the popup menu. On a
right-click in the package explorer,
plug-in A should create a submenu (lets say SubMenuName) and add an action
("Action 1")
plug-in B should an action ("Action 2") to the submenu created by plug-in A

Appreciate your help.

Paul Webster wrote:

> With actions, this only works for
> org.eclipse.ui.popupMenus/objectContributions

> With commands you can more easily create submenus and contribute to them
> separately.

> PW
Re: Add actions from different plugins [message #335285 is a reply to message #335002] Mon, 30 March 2009 17:42 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You would probably use a
locationURI="popup:org.eclipse.ui.popup.any?after=additions " to add the
submenu, say with an id="plugin.A.submenu" (probably add an "additions"
separator).

Then any plugin can contribute to that submenu with
locationURI="popup:plugin.A.submenu?after=additions"

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:[DataBinding] Binding to multiple objects
Next Topic:Releng to checkout SDK head and build it from sources?
Goto Forum:
  


Current Time: Thu Apr 25 13:37:55 GMT 2024

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

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

Back to the top