說明:本文並不是教你如何建立一個嚮導,而是在你已經有個嚮導的前提下,怎麼通過比如功能表列File的New按鈕、快捷工具列New按鈕、資源管理員的New按鈕快速的啟動嚮導。並且已經通過擴充點建立了一個嚮導Smave Project。 通過File菜單和快捷工具列快速啟動嚮導
這個比較簡單,只需要在Perspective(透視圖)的實作類別裡加入layout.addNewWizardShortcut(String wizardID)就可以了;
效果如下圖所示:
在資源管理員中快速啟動嚮導
擴充資源管理員當然要用到CNF的擴充點了,此處要用到擴充點org.eclipse.ui.navigator.navigatorContent,我們需要擴充的是commonWizard這個element,看看官方是怎麼描述的:Defines a binding between an existing Eclipse New/Import/Export Wizard and a given set of items. Each valid binding determines which menu items will appear in the submenus for New/Import/Export in the context menu of a Common Navigator Viewer. Since Eclipse 3.2.1, the wizard menu items respect Eclipse Capabilities (see org.eclipse.ui.activites for more information).
也就是說New/Import/Export均可以通過此擴充點進行定製。
效果如下圖所示:
其它方式快速啟動嚮導
還有一種和嚮導相關的快捷啟動方式,如下:
像這種方式顯示該怎麼做呢。
其實這樣做是官方不推薦的,通過擴充點org.eclipse.ui.newWizards的primaryWizard實現,
我們先看一下官方描述:a means of declaring that a wizard is “primary” in the UI. A primary wizard is emphasized in the new wizard dialog. Please note that this element is not intended to be used by plug in developers! This element exists so that product managers may emphasize a set of wizards for their products.
通過描述我們可以看出Eclipse官方是不推薦外掛程式開發人員這樣做的。