Eclipse通過Spket增加JQuery提示的方法
Eclipse安裝外掛程式支援jQuery智能提示
最近工作中用到jQuery外掛程式,需要安裝eclipse外掛程式才能支援jQuery智能提示,在網上搜尋了一下,常用的有三個外掛程式支援jQuery的智能提示:
1.jQueryWTP
2.Spket
3.Aptana
在安裝外掛程式之前需要先安裝eclipse,如果已經安裝了eclipse,可以直接看下面的外掛程式安裝方法,本人使用的Fedora 12,操作如下:
1.直接開啟”應用程式”-->”系統工具”-->”終端”
2.輸入命令”su”,這個命令是臨時切換到root使用者
3.輸入root使用者的密碼
4.輸入命令”yum install eclipse”
5.安裝成功後,就可以在”應用程式”-->”編程”-->”eclipse”,開啟查看版本為eclipse 3.5.1,當然也可以直接下載安裝,這裡就不再細說了,安裝完畢後就可以安裝相關外掛程式了.
以下分別介紹三個外掛程式的安裝方法:
一、jQueryWTP的安裝方法(官方):
step1:download jqueryWTP_version.jar
step2:find you Eclipse Plugin org.eclipse.wst.javascript.ui_xxxxxxx.jar,backup the plugin.
step3:double click the jar file or run with command java -jar jqueryWTP.version.jar
step4:on the opened swing UI,choose org.eclipse.wst.javascript.ui_xxxxxxx.jar,and output dir.
step5:click generate button.
step6:replace old org.eclipse.wst.javascript.ui_xxxxxxx.jar file with the generated file.
step7:restart eclipse.
step8:open a html file,edit js content.
jQueryWTP外掛程式項目的首頁:http://www.langtags.com/jquerywtp/
但是下載完jqueryWTP0.31foCN.jar後,根據安裝教程裡都提到了一個plugin目錄下的org.eclipse.wst.javascript.ui_xxxxxxx.jar檔案,但是我的eclipse目錄想壓根就找不到這個檔案,所以也要就不能使用jQueryWTP外掛程式智能提示.
後來仔細查看jQueryWTP外掛程式項目的首頁,有這麼一句話,Eclipse的WTP支援Javascript的代碼補全功能,但是很簡單,而且不支援jQuery,jQueryWTP的目的就是讓Eclipse WTP支援jQuery,需要說明的是該外掛程式對於MyEclipse等基於Eclipse WTP的工具也是支援的.
根據這句話可以猜想找不到plugin目錄下的org.eclipse.wst.javascript.ui_xxxxxxx.jar檔案的原因,可能是沒有安裝eclipse WTP外掛程式,由於下面兩種方法順利安裝並且支援jQuery智能提示,所以這裡的猜想還沒有經過驗證.
二、Spket的安裝方法(兩種方式):
1.線上安裝:Help->Install New Software...->Add...->Name: "Spket",
Location:http://www.spket.com/update/ 下載完畢重啟Eclipse.
2.手動安裝:到http://www.spket.com/download.html下載 Plugin 版本,目前的版本為1.6.17.下載解壓後直接放置於Eclipse的dropins目錄下,重啟Eclipse.
3.下載jQuery檔案,(要下載開發版本).
4.設定spket ,Window -> Preferences -> Spket -> JavaScript Profiles -> New,輸入“jQuery”點擊OK; 選擇“jQuery” 並點擊“Add Library”然後在下拉條中選取“jQuery”; 選擇 “jQuery”並點擊“Add File”,然後選中你下載的jQuery.js 檔案;設成Default;
5.設定js開啟檔案(這一步很重要,不設定的話,也不會有jQuery的智能提示), Window -> Preferences ->General-> Editors-> File Associations-> 選擇*.js,將Spket JavaScript Editor設為Default。
6.建立一個js檔案,jQuery自動提示。。
三、Aptana的安裝方法:
Aptana的安裝相對比較簡單,直接安裝完畢就支援jQuery的智能提示,而且智能提示功能也比較強大,按照下面的安裝就能使用,強烈建議初學者可以使用這種方法安裝:
1.線上安裝:Help->Install New Software...->Add...->Name: "Aptana",
Location:http://download.aptana.com/tools/studio/plugin/install/studio下載完畢重啟Eclipse,Aptana外掛程式安裝成功,支援javascript智能提示功能,但還不支援jQuery智能提示,需要再安裝支援jQuery智能提示的外掛程式.
2.Window->My Studio開啟Aptana的首頁,單擊首頁上面的Plugins,選擇Ajax下面的jQuery Support,單擊Get It即可安裝jQuery智能提示的外掛程式,如圖:
3.建立一個js檔案就會有jQuery智能提示了.
另外,如果這三個外掛程式都安裝成功的話,想選擇其中一個外掛程式使用,應該如果操作呢?方法如下:
Window->Preferences->General->Editors->File Associations,選擇”*.js”,再選擇”Aptana JS Editor”或”Spket JavaScript Editor”設定為預設即可.