Eclipse 支持 HTML&JSExtJS&jQuery 代碼智能提示


安裝HTML插件GEF和EclipseHTMLEditor

一、GEF下載安裝

進到網頁http://www.eclipse.org/gef/downloads/

點6.2M的那個。會進入下載頁面

http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/3.7.2/R201201171043/GEF-ALL-3.7.2.zip

點擊紅色框內鏈接下載,鏈接地址如下:

http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/3.7.2/R201201171043/GEF-ALL-3.7.2.zip&url=http://download.actuatechina.com/eclipse/tools/gef/downloads/drops/3.7.2/R201201171043/GEF-ALL-3.7.2.zip&mirror_id=385

GEF-ALL-3.7.2.zip解壓出來

把features目錄下的全部拷貝到eclipse/features下,把plugins目錄下的文件全部拷貝到eclipse/plugins下。

 

二、安裝EclipseHTMLEditor

進入頁面http://sourceforge.jp/projects/amateras/downloads/51002/tk.eclipse.plugin.htmleditor_2.1.0.jar/

點擊紅色框內下載地址,鏈接地址如下:

http://sourceforge.jp/frs/redir.php?m=iij&f=%2Famateras%2F51002%2Ftk.eclipse.plugin.htmleditor_2.1.0.jar

把該文件tk.eclipse.plugin.htmleditor_2.1.0.jar拷貝到eclipse/plugins下。

 

三、重啟Eclipse

菜單選擇File->New->Other->Amateras->html新建html文件

注:plugins下沒有tk.eclipse.plugin.htmleditor_2.1.0.jar就沒有Amateras選項

點“Next“

點“Finish”,自動創建文件內容,

然后在輸入一個<符號,自動出來相關的HTML標記供選擇,非常方便.

 

 

 

 

 

安裝JS插件Spket

一、安裝Spket

第一種方法:網上更新方式

1.插件首頁:http://www.spket.com

2.插件名稱:Spket IDE

3.更新連接(Update Site):http://www.agpad.com/update

更新安裝方法:

1.【Help】-【Install New Software】 

2.點擊【Add】

3.在【Add Repository]】的【Name】中輸入一個名稱(什么名稱都行),【Location】中輸入http://www.agpad.com/update --> 【OK】

4.選擇【Spket IDE】-【Next】-【Next】

5.選中【I accept the terms of the license agreements】-【Finish】

安裝完之后,要求重啟Eclipse。

 

二、配置Spket

注意:如果在安裝spket過程中,你的eclipse或者Myeclipse是打開的,請重啟eclipse或者Myeclipse。以便初始化插件,下面才會在Preferences中看到 Spket選項。

基本步驟如下:

1)【Windows】→ 【Preferences】 → 【Spket】

可以看到,默認是沒有授權的,需要破解,

到網上搜索“spket1.6.23破解補丁”,將剛下載的com.spket.ui_1.6.23.jar替換plugins目錄下原來的com.spket.ui_1.6.23.jar即可。重啟Eclipse,再次進到【Windows】→ 【Preferences】 → 【Spket】。

說明破解成功。

三、JS代碼智能提示測試

這時已經支持JS的語法智能提示了。選擇菜單New-àFile建立一個test.js文件,

點“Finish”自動進入代碼編輯界面,智能提示效果.

如果沒有出現智能提示,需要設置js默認打開方式: Window → Preferences → General→ Editors→ File Associations頁面的Associations editors 更改為Spket JavaScript Editor (把spket設為js默認的編輯器)。

或者可以在打開js的時候右鍵設置打開方式(Open With) 為 Spket JavaScript Editor(default) (把spket設為js默認的編輯器)。


新建*.js 就可以使用"." 或者Ctrl+.或者Alt+/或者Alt+.進行提示了; 如果是在jsp上面寫JS進行提示使用快捷鍵shift+alt+/

 

 

 

 

安裝ExtJS插件

在上面安裝好Spket的基礎上,接着配置

一、【Spket】→ 【JavaScript Profiles】 → 【New】, 輸入“ExtJS”點擊OK; 

二、選擇“ExtJS” 並點擊“Add Library”然后在下拉條中選取“ExtJS”;

三、選擇 “ExtJS”並點擊“Add File”,然后在你的./ext-2.x/source目錄中選取“ext.jsb” 文件

(注意:官網新版本里已經沒有ext.jsb文件,需要從網上尋找ext-jsb-3.0.0.zip替換ext.jsb)

《Ext JS 4.0在eclipse/myeclipse中使用spket插件設置自動提示的方法》

http://hi.baidu.com/lyw596517091/blog/item/c5314f6f2977cbe8f636545c.html

解決方法:

在網上下載一個叫ext-jsb-3.0.0.zip的文件,我在http://ishare.iask.sina.com.cn/f/19219739.html?f里找到了,下載地址為http://119.147.148.26/6/ishare.down.sina.com.cn/19596728.zip?ssig=eUt7ruWwSb&Expires=1338739200&KID=sina,ishare&ip=1338600134,219.134.165.&fn=ext-jsb-3.0.0.zip,下完后解壓開來,把里面的ext.jsb文件復制到Ext JS目錄的src文件夾下(注:這里一定要放對,不然也是不會自動提示),然后按照上面的步驟做。

添加完ext.jsb后的效果如下圖:

四、設置新的ExtJS Profile,選中並點擊“JavaScript Profiles” 對話框右手邊的“Defalut”按鈕;

五、重啟Eclipse,創建或打開JS文件並輸入: Ext這樣就可設置Ext Code代碼自動完成的功能(注意使用Spket JavaScript Editor打開)。

 

 

 

 

 

Jquery代碼智能提示

一、下載jquery

先從http://docs.jquery.com/Downloading_jQuery下載一個 jquery-1.6.2.js的版本,然后參考前面ExtJS的步驟,添加Jquery的Profile

二、自定義靜態函數

a)自義js,CommMethod.js

/**

 * 通用方法

 * @returns {CommMethod}

 */

function CommMethod (){                 

         this.isEmpty=function(str){

                   return CommMethod.isEmpty(str);

         }

}

 

/**

 * 為空檢查

 * @param {} str

 * @return {Boolean}

 */

CommMethod.isEmpty=function(str){

         if(str==undefined||str==null||str=='null'||str==''){

                   return true;

         }

         return false;

}

 

/**

 * get非空數據

 * @param {} str

 * @return {Boolean}

 */

CommMethod.getNotNull=function(str){

         if(this.isEmpty(str)){

                   return '';

         }

         return str;

}

 

CommMethod.trim=function(str) {

        return str.replace(/(^\s*)|(\s*$)/g, "");

}

 

b)配置CommMethod.js到spket里

c)開發中代碼使用效果,代碼自動提示及輔助輸入

d)注意事項,

生效說明:需重啟eclipse,且每次新增CommMethod.js函數時也需重啟eclipse,否則可能不起作用。

 

三、類方式使用

a)自定義js,map.js

/**

 * javascript map

 */

function Map() {

         this.elements = new Array();

 

         //獲取MAP元素個數 

         this.size = function() {

                   return this.elements.length;

         }

 

         //判斷MAP是否為空 

         this.isEmpty = function() {

                   return (this.elements.length < 1);

         }

 

         //刪除MAP所有元素 

         this.clear = function() {

                   this.elements = new Array();

         }

 

         //向MAP中增加元素(key, value)  

         this.put = function(_key, _value) {

                   this.elements.push({

                            key : _key,

                            value : _value

                   });

         }

 

         //刪除指定KEY的元素,成功返回True,失敗返回False 

         this.remove = function(_key) {

                   var bln = false;

                   try {

                            for (var i = 0; i < this.elements.length; i++) {

                                     if (this.elements[i].key == _key) {

                                               this.elements.splice(i, 1);

                                               return true;

                                     }

                            }

                   } catch (e) {

                            bln = false;

                   }

                   return bln;

         }

 

         //獲取指定KEY的元素值VALUE,失敗返回NULL 

         this.get = function(_key) {

                   try {

                            for (var i = 0; i < this.elements.length; i++) {

                                     if (this.elements[i].key == _key) {

                                               return this.elements[i].value;

                                     }

                            }

                   } catch (e) {

                            return null;

                   }

         }

 

         //獲取指定索引的元素(使用element.key,element.value獲取KEY和VALUE),失敗返回NULL 

         this.element = function(_index) {

                   if (_index < 0 || _index >= this.elements.length) {

                            return null;

                   }

                   return this.elements[_index];

         }

 

         //判斷MAP中是否含有指定KEY的元素 

         this.containsKey = function(_key) {

                   var bln = false;

                   try {

                            for (var i = 0; i < this.elements.length; i++) {

                                     if (this.elements[i].key == _key) {

                                               bln = true;

                                     }

                            }

                   } catch (e) {

                            bln = false;

                   }

                   return bln;

         }

 

         //判斷MAP中是否含有指定VALUE的元素 

         this.containsValue = function(_value) {

                   var bln = false;

                   try {

                            for (var i = 0; i < this.elements.length; i++) {

                                     if (this.elements[i].value == _value) {

                                               bln = true;

                                     }

                            }

                   } catch (e) {

                            bln = false;

                   }

                   return bln;

         }

 

         //獲取MAP中所有VALUE的數組(ARRAY) 

         this.values = function() {

                   var arr = new Array();

                   for (var i = 0; i < this.elements.length; i++) {

                            arr.push(this.elements[i].value);

                   }

                   return arr;

         }

 

         //獲取MAP中所有KEY的數組(ARRAY) 

         this.keys = function() {

                   var arr = new Array();

                   for (var i = 0; i < this.elements.length; i++) {

                            arr.push(this.elements[i].key);

                   }

                   return arr;

         }

}

 

b)配置map.js到spket里

c)開發中代碼使用效果,代碼自動提示,及智能提示

d)注意事項:

生效說明:需重啟eclipse,且每次新增map.js函數時也需重啟eclipse,否則可能不起作用。

 

通過以上方式,就可以使自定義的js代碼跟jquery庫一樣像java開發一樣有自動提示,從而方便開發,並可使javascript的代碼按類來處理。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM