Eclipse菜單:
menu:help?after=addtions
menu:navigate?after=open.ext2
menu:window?after=newEditor
menu:file?after=open.ext
org.eclipse.ui.menus屬性
- locationURI ---------- 標識用戶界面中與該菜單項關聯的命令將要出現的位置。
locationURI="[scheme]:[identifier]?[argument-list]"
locationURI屬性被分解為三個清晰的部分:模式(scheme)、標識符(identifier)和參數列表(argument list)
scheme標識添加項將要添加至的UI對象的類型。它可以是以下值的其中這一:
- menu———程序主菜單或視圖下拉菜單
- popup———視圖或編輯器的上下文菜單
- toolbar———程序主工具欄或視圖中的工具欄
identifier定義了將要添加至的菜單、彈出項或工具欄的唯一標識符。一些常用的標識符包括:
- org.eclipse.ui.main.menu———Eclipse主菜單的標識符
- org.eclipse.ui.main.toolbar———Eclipse主工具欄的標識符
- org.eclipse.ui.popup.any———任意上下文菜單的標識符。
agrument list。參數列表由可以是"before"或"after"的布局,一個等號(“=”),以及菜單 、彈出項或工具欄的一些項的標識符組成。標識符也可以是“additions”,表示元素應當被放置於給定菜單、彈出項或工具欄的默認位置 ("="等號后面可以接着一個acitonID,這樣子就布局到這個action的后面,實現分組布局)。
實例
<extension point="org.eclipse.ui.menus"> <menuContribution allPopups="false" locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions"> <toolbar id="cn.com.agree.ide.afa.navigation.saveToolbar"> <command commandId="org.eclipse.ui.file.save" icon="icons/save_edit.gif" label="Save" style="push" tooltip="Save"> </command> <command commandId="org.eclipse.ui.file.saveAll" icon="icons/saveall_edit.gif" label="Save All" style="push" tooltip="Save All"> </command> </toolbar> </menuContribution>
<menuContribution
allPopups="false" locationURI="toolbar:org.eclipse.ui.main.toolbar?after=cn.com.agree.ide.afa.navigation.saveToolbar"> <toolbar id="cn.com.agree.ide.afa.workbench.searchToolbar"> <command commandId="org.eclipse.search.ui.openSearchDialog" icon="icons/search.gif" label="Search" style="pulldown" tooltip="Search"> </command> </toolbar> </menuContribution> <menuContribution allPopups="true" locationURI="menu:org.eclipse.search.ui.openSearchDialog"> <command commandId="org.eclipse.search.ui.openFileSearchPage" icon="icons/search.gif" label="File Search" style="push" tooltip="File Search"> </command> </menuContribution>
紅色代碼是較好的org.eclipse.ui.menus應用實例,效果圖如下
快捷鍵
M1--------Ctrl
M2--------Shift
M3--------Alt
org.eclipse.ui.actionSets擴展點
toolbarPath指定工具欄中此操作的位置,以'/'定界路徑,第一個標記表示工具欄標識(Normal表示是缺省的工具欄),第二個標記為工具欄內的命名組(也可以是工具欄上的separator,這樣就能實現和org.eclipse.ui.menus整合布局),若不存在改組,則會創建。省略該選項,action將不會出現在工具欄。