Community
Participate
Working Groups
Hi, I am trying to implement a full-blown refactoring which is similar to the existing JDT "Refactor -> Pull Up" operation. I've been able to work my way through most of the LTK refactoring framework, however, I am stuck on a particular issue -- how to inject my refactoring into the existing JDT "Refactor" menu. Currently, I have my menu and action class appearing in the root of the workbench menu (using extension point org.eclipse.ui.actionSets) and in the root of the popup menus (using extension point org.eclipse.ui.popupMenus) for IMember objects in editors and views. Looking at how the the existing Refactor operations are defined in the org.eclipse.jdt.ui plugin, I can see extensions of org.eclipse.ui.command and org.eclipse.ui.actionSets defined and noticed the retarget attribute was set (which I am not familiar with). I'm somewhat new to plug-in development, so please bear with me if my questions have obvious answers: 1. How are the Refactor menu items injected into the popup menus for objects in editors and views? I didn't see an extension of org.eclipse.ui.popupMenus that corresponded to the Refactor operations. I'm thinking if I can understand how this was done, then maybe I can do something similar instead of extending both org.eclipse.ui.actionSets and org.eclipse.ui.popupMenus. Is this where the retarget attribute takes affect? 2. How do I inject my menu item(s) under the workbench Refactor menu and in the Refactor popup menu for objects in editors and views? I didn't see an extension point defined in org.eclipse.jdt.ui plugin that would enable me to add my own menu items to the Refactor menu. Thanks in advance!! Bevon Palod Response from Markus Keller: ============================ Hi Bevon The 'retarget' attribute in the 'actionSet > action' element tells the platform that it should create retargetable actions, which are shared between editors and views and can be activated per part via actionBars.setGlobalActionHandler(..); Unfortunately, there's currently no easy way for external refactorings to contribute to the JDT Refactor popup menus. The menus are populated programmatically in RefactorActionGroup. To add an entry to the main Refactor menu, you can try something like this: <extension point="org.eclipse.ui.actionSets"> <actionSet label="My Refactorings" description="Additional Refactorings" visible="true" id="zzPlug.refac2"> <menu label="Refac&tor" path="edit" id="org.eclipse.jdt.ui.refactoring.menu"> <separator name="undoRedoGroup"/> <separator name="reorgGroup"/> <separator name="codingGroup"/> <separator name="reorgGroup2"/> <separator name="typeGroup"/> <separator name="codingGroup2"/> <separator name="typeGroup2"/> <separator name="scriptGroup"/> </menu> <action definitionId="zzPlug.menus.my.refactoring" label="My Refactoring..." class="zzPlug.WorkbenchWindowActionDelegate1" menubarPath="org.eclipse.jdt.ui.refactoring.menu/typeGroup" id="zzplug.my.refactoring"> </action> </actionSet> </extension> For object contributions, do something like: <extension point="org.eclipse.ui.popupMenus"> <objectContribution objectClass="org.eclipse.jdt.core.IType" id="zzPlug.contribution1"> <action label="ZzPlug Popup..." class="zzplug.popup.actions.ZzPlugPopupAction" menubarPath="org.eclipse.jdt.ui.refactoring.menu/typeGroup" enablesFor="1" id="zzPlug.newAction"> </action> </objectContribution> </extension> I'm not aware of a way how you could extend the editor context menu. We hoped that the new menu contribution story would help resolving these issues, but it was not ready for 3.3, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=154130, https://bugs.eclipse.org/bugs/show_bug.cgi?id=15670, and proposal drafts: http://wiki.eclipse.org/index.php/Platform_UI_Command_Design http://wiki.eclipse.org/index.php/Menu_Contributions I'm sorry that I cannot give you a more positive answer. Please file a bug for JDT/UI, and we will try to solve this problem once the new menu contribution story is implemented. Regards, Markus
Markus' workaround works for the time being.
Maybe we can register the submenus with IEditorSite.registerContextMenu(..), but I'm not sure if that's intended for non-toplevel menus.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.