org.eclipse.ui.actionSets擴展點

用於添加菜單、菜單項、工具欄按鈕。包含menu和action元素。

menu元素的label若爲中文,添加快捷方式爲"文件(&F)"括號內位快捷鍵;path爲菜單添加的位置(從根目錄開始插入菜單的位置,若省略,則默認將菜單加入additions命名組;
action元素相當於菜單項,label爲菜單項名"(新建(&N)";menuPath指定菜單欄中該操作的位置,以'/'定界路徑,如help/helpEnd,在help菜單的最後位置添加action,若省略了該選項,此操作將不會出現在菜單欄。toolbarPath指定工具欄中此操作的位置,以以'/'定界路徑,第一個標記表示工具欄標識(Normal表示是缺省的工具欄),第二個標記爲工具欄內的命名組,若不存在改組,則會創建。省略該選項,action將不會出現在工具欄。style控制菜單的樣式,有radio(帶點),toggle(帶鉤),push(普通)pulldown,初始狀態由state選項指定。

1創建獨立菜單的菜單項:
  <menu
               path="additions">
               id="menu1"
            <separator
                  name="separator1">
            </separator>
            <separator
                  name="separator2">
            </separator>
    </menu>

 <action
               label="新建(&amp;N)"
               menubarPath="menu1/seperator1"
               toolbarPath="save.group"
  </action>

2創建獨立菜單的二級菜單

  <menu
               path="additions">
               id="menu1"
            <separator
                  name="separator1">
            </separator>
            <separator
                  name="separator2">
            </separator>
    </menu>
  <menu
               path="menu1/additions">
               id="menu2"
            <separator
                  name="separator1">
            </separator>
            <separator
                  name="separator2">
            </separator>
    </menu>
 <action
               label="新建(&amp;N)"
               menubarPath="menu1/menu2/seperator1"
               toolbarPath="save.group"
  </action>
3創建現有工作臺菜單的菜單項及二級菜單項同上,只是將路徑設置爲現有的菜單。標準工作臺提供的菜單插入點有file,edit,navigate,project,window,help。每個菜單內部的每個菜單項都是插入點,以file菜單爲例,包含的插入點有:FileStart,New,Close,CloseAll,Save等等。

4工具欄上的位置由工具欄標識符(org.eclipse.ui.workbench.file,org.eclipse.ui.workbench.navigate,org.eclipse.ui.workbench.launchActionSet/Normal)和工具欄組標識符(new.group,save.group,pin.group)組成,如org.eclipse.ui.workbench.file/new.group在新建按鈕前添加工具,最常用的設置爲Normal/additions
發佈了6 篇原創文章 · 獲贊 0 · 訪問量 1147
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章