Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "CDT/Developer/FAQ/popupMenu"
m (New page: = Howto add menu items, submenu to CDT ''Source'' popup = The motivation of this page is to allow the plug-in developer to add more menus to the Source menu. It stem from spending two wor...) |
m (→References) |
||
Line 143: | Line 143: | ||
[http://www.ifs.hsr.ch/Projects/Projects/Cute C++ Unit Testing Easier] | [http://www.ifs.hsr.ch/Projects/Projects/Cute C++ Unit Testing Easier] | ||
− | |||
− | |||
− |
Revision as of 10:39, 8 February 2008
Contents
The motivation of this page is to allow the plug-in developer to add more menus to the Source menu. It stem from spending two working days trying to learn how to add a submenu with 3 items.
(insert image)
Plug-in used
Eclipse PDE 3.3.1.1
CDT 4.0.2
Plug-in in development (CUTE)
Steps
- add extension
- add contribution
- add menu
- add groups
- add action
extension
Extension allows Eclipse IDE to be added with modules for various purpose. org.eclipse.ui.popupMenus
will be required. For further information, see
Platform architecture
(insert image)
contribution
Contribution are for managing shared UI items. see Actions and contributions,object and viewer contribution A viewer Contribution was created with the targetID as #CEditorContext (insert image)
An option that may/may not be displayed. In this case, Test Code will not be shown, where as Add Test will be shown. Each menu requires an unique identifier, a label which may include mnemonic and a path. see Pop-up Menus The path is separated by /, and thus you can have an id with period within as shown. For CDT Source, the path is org.eclipse.cdt.ui.source.menu. For Test Code the group marker was omitted and thus defaulted to the group called additions (image)
Invalid path resulting in menu not shown (image 04menuA)
Paths are not cumulative, no menu (image 04menuB)
Right clicking for menu is no longer possible (image 04menuC)
Added to a new named group called abcd, just above additions,possible to appear after. (image 04menuD)
It appears that only one menu maybe added to additions, no Add Test shown (image 04menuE)
The working path that creates the submenu that I wanted org.eclipse.cdt.ui.source.menu/ch.hsr.ifs.cutelauncher.testCodeMenu
groups
Groupmarker are virtual entity used to represent the menu. It doesnt have any visual representation but action are attached to it.
action
Action do the processing work, the Action class doesnt have any UI, its UI is represented via popupMenus.
For the desired submenu, the menubarPath: org.eclipse.cdt.ui.source.menu/addTestMenu/addTestGroup
(image 05action) (image 05actionA-C)
(menu)/(menu)/(GroupMarker)
No menu shown as based on IWorkbenchActionConstants.MB_ADDITIONS which is empty at the moment. see popup menu
(image 05actionE)
plugin.xml extract
<extension point="org.eclipse.ui.popupMenus"> <viewerContribution id="ch.hsr.ifs.cutelauncher.cEditorContribution" targetID="#CEditorContext"> <action class="ch.hsr.ifs.cutelauncher.ui.sourceactions.NewTestFunctionActionDelegate" definitionId="cute_plugin.command1" id="ch.hsr.ifs.cutelauncher.addTestMemberSuiteAction" label="Add Test Member to Suite" menubarPath="org.eclipse.cdt.ui.source.menu/addTestMenu/addTestGroup"> </action> <action class="ch.hsr.ifs.cutelauncher.ui.sourceactions.NewTestFunctionActionDelegate" definitionId="cute_plugin.command1" id="ch.hsr.ifs.cutelauncher.addTestFunctorSuiteAction" label="Add Test Functor to Suite" menubarPath="org.eclipse.cdt.ui.source.menu/addTestMenu/addTestGroup"> </action> <action class="ch.hsr.ifs.cutelauncher.ui.sourceactions.NewTestFunctionActionDelegate" definitionId="cute_plugin.command1" id="ch.hsr.ifs.cutelauncher.addTestFunctionSuiteAction" label="Add Test Function to Suite" menubarPath="org.eclipse.cdt.ui.source.menu/addTestMenu/addTestGroup"> </action> <action class="ch.hsr.ifs.cutelauncher.ui.sourceactions.NewTestFunctionActionDelegate" definitionId="ch.hsr.ifs.cutelauncher.newTestFunctionCommand" id="ch.hsr.ifs.cutelauncher.newTestFunctionAction" label="New Test Function" menubarPath="org.eclipse.cdt.ui.source.menu/ch.hsr.ifs.cutelauncher.testCodeMenu"> </action> <menu id="ch.hsr.ifs.cutelauncher.testCodeMenu" label="Test Code" path="org.eclipse.cdt.ui.source.menu"> <groupMarker name="ch.hsr.ifs.cutelauncher.testCodeMenu"> </groupMarker> </menu> <menu id="addTestMenu" label="Add Test" path="org.eclipse.cdt.ui.source.menu/ch.hsr.ifs.cutelauncher.testCodeMenu"> <groupMarker name="addTestGroup"> </groupMarker> </menu> </viewerContribution> </extension>
ideas
Writing XML by hand is difficult. The wonderful wizards in Eclipse lighten the load, but troubleshooting are still extremely difficult. If only it were smart enough to know the different linkage.
popupMenus extension Designer similar to Visual Studio Menu editor[1].
References
Platform Plug-in Developer Guide > Reference > Extension Points Reference > Pop-up Menus