When the secondary development of Teamcenter regular menu will be expanded, Eclipse provides two extension points for users to add menu items to the appropriate location. Both extension point to org.eclipse.ui.commands (referred to as Commands mode) and org.eclipse.ui.actionSets (referred to as Actions way), I wrote only way to achieve a Commands, why not refer to Actions the difference between this article and the Command of the Eclipse Action
Sub-menu main menu, the context menu, View Menu
Main menu extension:
<extension
point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu label="测试菜单" id="ceshi">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
<menuContribution locationURI="menu:ceshi">
<menu label="菜单一">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
<menuContribution locationURI="menu:ceshi">
<menu label="菜单二">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
</extension>
Results are as follows:
Context menu extension:
<extension
point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu label="上下文菜单" id="shang">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
</extension>
Results are as follows:
The entire plugin.xml document reads as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
icon="icon/alignmiddle.png"
id="com.service.handlers.handleone"
name="子菜单一"/>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.service.handlers.handleone"
commandId="com.service.handlers.handleone">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu label="上下文菜单" id="shang">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu label="测试菜单" id="ceshi">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
<menuContribution locationURI="menu:ceshi">
<menu label="菜单一">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
<menuContribution locationURI="menu:ceshi">
<menu label="菜单二">
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
<command
icon="icon/alignmiddle.png"
commandId="com.service.handlers.handleone">
</command>
</menu>
</menuContribution>
</extension>
</plugin>