一款軟件,如果希望用戶能夠快速的上手,完善的幫助系統必不可少。幫助中要包含操作指南,相關的疑難解答,軟件的配置,維護等信息。優秀的文檔可以節省用戶的時間精力,也為維護人員省去了不少麻煩。
Eclipse的幫助系統可以說是十分優秀,功能全面,界面美觀,操作便利,而且和Eclipse IDE結合的十分緊密,用戶在任何時候都可以通過F1來體會這一點。
在RCP中,也可以利用Eclipse Help構建自己的幫助系統。Eclipse 幫助系統包括靜態,動態和上下文敏感的幫助,這些都可以應用到RCP中。
在RCP中,加入幫助,也是通過plugin,如果要幫助要依賴于指定的plugin,也可以做成fragment的形式,這里是以plugin的形式。
要實現完整的幫助功能,需要依賴于以下插件:
1.
org.apache.lucene
2.
org.eclipse.help.appserver
3.
org.eclipse.help.base
4.
org.eclipse.help.ui
5.
org.eclipse.help.webapp
6.
org.eclipse.tomcat
7.
org.eclipse.ui.forms
1
在RCP的幫助菜單中加入Help Contents
在RCP的ActionBarAdvisor.makeActions()方法中實例化Help Constents Action,并注冊到工作臺中。
com.mi.pwdgate.ApplicationActionBarAdvisor.makeActions()
helpContentsAction = ActionFactory.HELP_CONTENTS.create(window);
register(helpContentsAction);
在Help Menu的About Action前面加入此helpContentsAction,在fillMenuBar()中實現。
com.mi.pwdgate.ApplicationActionBarAdvisor.fillMenuBar()
MenuManager helpMenu = new MenuManager("&Help","help");
helpMenu.add(helpAction);
helpMenu.add(aboutAction);
現在運行RCP時,可以看到
Help > Help Contents
菜單項。運行RCP
時,要選中上面列出的plugin
。
2
加入幫助內容
幫助文件就是一組html
格式的文件,要加入到幫助系統中必須要有一個定義幫助文件結構的配置文件,是xml
格式。幫助文件的內容需要資料人員制作成標準的html
文件即可。為了美觀性,也可以加入css
。
1)
在plugin.xml
文件中加入擴展點
plugin.xml
<extension point="org.eclipse.help.toc">
<toc file="toc.xml" primary="true"/>
<toc file="tocgettingstarted.xml"/>
</extension>
此擴展點告訴幫助系統所有的toc文件,toc文件中定義的幫助的顯示結構,它們顯示在幫助對話框的左邊。這個擴展點標示了2個toc 文件,它們都是位于幫助的頂級。其中toc.xml標示為primary,保證其在幫助對話框中永遠顯示。
插件根目錄下的toc.xml文件,
toc.xml
<toc label="Pass Gate User Guide" topic="html/toc.html">
<topic label="Getting started" href="doc/gettingstarted.html"/>
<topic label="Copy" href="doc/copy.html"/>
<topic label="Preferences" href="doc/preferences.html">
<topic label="Policy" href="doc/preferences_policy.html"/>
<topic label="User Interaction" href="doc/preferences_ui.html"/>
</topic>
<topic label="Import" href="doc/imexport_import.html"/>
<topic label="Export" href="doc/imexport_export.html"/>
<topic label="Credits" href="doc/credits.html"/>
</toc>
幫助文件結構
執行RCP后,可以在幫助對話框中看到剛才加入的幫助內容
3
加入上下文敏感幫助
如果希望能夠和用戶進行良好的交互,上下文敏感的幫助就必不可少。當用戶執行特定的操作,或者在操作某個程序界面,只要點擊幫助件,就可以得到與此相關的幫助內容。在Windows是F1,在GTK是Ctrl+F1。在Eclipse3.1以前,是以Infopops的形式出現,就是彈出一個黃色的框框,從Eclipse3.1,默認的形式是Help View。
下面在PassGateView中加入上下文敏感幫助
com.mi.pwdgate.view. PassGateView. createPartControl()
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
"
pwdgatehelp.PassGateView");
其中" pwdgatehelp.PassGateView"是上下文的id,系統使用這個id在上下文表中尋找要顯示的內容。上下文表由org.eclipse.help.contexts擴展點定義。在plugin文件中加入如下內容。
plugin.xml
<extension point="org.eclipse.help.contexts">
<contexts file="contexts.xml"/>
</extension>
contexts.xml文件中定義了上下文id和顯示內容的映射。
contexts.xml
<contexts>
<context id="PassGateView">
<description>This is Password Gate View</description>
<topic
label="Password Gate"/>
href="
doc/gettingstarted.html"
<topic
label="Preference"/>
href="doc/preferences.html"
</context>
</contexts>
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
"pwdgatehelp.PassGateView");
中,上下文id, PassGateView對應contexts.xml中的context id, pwdgatehelp對應幫助插件的plugin id。
運行RCP,在Password Gate View 按F1,自動打開Help View。
用PDE的導出Wizard到處該幫助plugin,就生成了一個獨立的幫助plugin,可以直接放在自己的RCP產品的plugins目錄下。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
