顯示具有 Eclipse 標籤的文章。 顯示所有文章
顯示具有 Eclipse 標籤的文章。 顯示所有文章
2015-03-26 14:39

Eclipse Git 基本操作

Git 只有本地端(local)跟遠端(remote)的分別,並不是 client 跟 server 的關係,只要是非專案本身的都可以稱為遠端,例如 A 與 B 專案都在自己的電腦裡,A 專案是可以將 B 專案設為遠端進行版本傳遞。

幾個基本日常操作的名稱意義:
  • commit: 將完成的程式提交到版本控制中
  • revert: 放棄修改,將程式回復
  • merge: 將兩個不同版本的程式進行合併
  • pull: 從遠端取回有差異的程式版本
  • push: 將本地端的版本傳到遠端
  • clone: 從遠端複製一個專案到本地



在專案建立 Git 版本控制


在一個專案上滑鼠右鍵選擇 [團隊]->[共享專案]



先建立 Git 儲存庫





將專案中的異動 commit 到 Git 版本控制


隨便建立幾個文件


在專案上右鍵選擇 [團隊]->[確定]


填寫 commit 的訊息,以及選擇要 commit 的檔案




程式回復到尚未修改時


在要回復的檔案右鍵選擇 [取代為]->[HEAD Revision]




版本合併


在專案上右鍵選擇 [團隊]->[Pull] 從遠端取回有差異的程式



當檔案出現衝突時會顯示紅色的標記,這時候檔案右鍵選擇 [團隊]->[Merge Tool]



接著就會出現合併的工具,修改完儲存關閉


最後檔案右鍵選擇 [團隊]->[Add to Index] 將檔案加到 commit 清單中




將本地端的版本傳到遠端






從遠端複製一個專案






指定來源的遠端


目的地目錄最好修改到 Workspace 中




2015-02-27 22:27

在 Eclipse 為 Tomcat Library 增加原始碼附件

在專案目錄下選擇 [Java Resources]->[Libraries]->[Apache Tomcat]->[xxx.jar]->[右鍵內容]


Java 程式碼附件 就可以連接程式原始碼


Javadoc 位置 則可以連接 Javadoc



其實剛剛的設定都記錄在:
{WorkSpace}/.metadata/.plugins/org.eclipse.jst.server.core/
org.eclipse.jst.server.tomcat.runtimeTarget.xml


內容如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<classpath>
  <source-attachment entry="D:/apache-tomcat-7.0.53/lib/commons-io-2.4.jar" runtime-id="Apache Tomcat v7.0" source-attachment-path="D:/apache-tomcat-7.0.53/src/commons-io-2.4-sources.jar">
    <attribute name="javadoc_location" value="jar:file:/D:/apache-tomcat-7.0.53/src/commons-io-2.4-javadoc.jar!/"/>
  </source-attachment>
  <source-attachment entry="D:/apache-tomcat-7.0.53/lib/commons-logging-1.1.3.jar" runtime-id="Apache Tomcat v7.0" source-attachment-path="D:/apache-tomcat-7.0.53/src/commons-logging-1.1.3-sources.jar">
    <attribute name="javadoc_location" value="jar:file:/D:/apache-tomcat-7.0.53/src/commons-logging-1.1.3-javadoc.jar!/"/>
  </source-attachment>
</classpath>


所以只要編寫 org.eclipse.jst.server.tomcat.runtimeTarget.xml 的內容,重新啟動 Eclipse 就會連結原始碼附件,當然這麼麻煩的事還是寫程式自動處理比較快樂,既然是用 Eclipse 寫 Java 當然是用 Ant 來處理是最好的。

首先幾個環境定義:
  • Server Src 路徑:D:/apache-tomcat-7.0.53/src
  • Server Lib 路徑:D:/apache-tomcat-7.0.53/lib
  • Runtime Id:Apache Tomcat v7.0
  • Jar 名稱:xxxxx.jar
  • Source 名稱:xxxxx-sources.jar
  • Javadoc 名稱:xxxxx-javadoc.jar


tomcat-xml-build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE project>
<project name="tomcat-xml-build" default="deploy-output-xml" basedir=".">

    <!-- 載入額外 ant-contrib 定義  [if,not,or,then,equals] -->
    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

    <property name="tomcat.id" value="Apache Tomcat v7.0" />
    <property name="tomcat.home" value="D:/apache-tomcat-7.0.53" />
    <property name="output.file" value="org.eclipse.jst.server.tomcat.runtimeTarget.xml" />
    <basename property="ant.filename" file="${ant.file}" />


    <path id="tomcat.lib">
        <fileset dir="${tomcat.home}/lib" includes="*.jar" />
    </path>


    <target name="build-xml">
        <echo>====================================================================</echo>
        <echo>開始建立 ${output.file}</echo>

        <echo file="${output.file}"><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<classpath>
<!-- Code Generate from "${ant.filename}" --></echo>

        <foreach target="loop-jar-file" param="jar-file">
            <path refid="tomcat.lib"/>
        </foreach>

        <echo file="${output.file}" append="true">
</classpath></echo>

        <echo>====================================================================</echo>
        <echo>完成產生 ${output.file}</echo>
    </target>


    <target name="loop-jar-file" if="jar-file">
        <echo level="info">${jar-file}</echo>

        <basename property="jar-name" file="${jar-file}" suffix=".jar"/>
        <if>
            <or>
                <available file="${tomcat.home}/src/${jar-name}-sources.jar"/>
                <available file="${tomcat.home}/src/${jar-name}-javadoc.jar"/>
            </or>
            <then>
                <echo>輸出  ${jar-name}</echo>
                <echo file="${output.file}" append="true">
  <source-attachment entry="${tomcat.home}/lib/${jar-name}.jar" runtime-id="${tomcat.id}" source-attachment-path="${tomcat.home}/src/${jar-name}-sources.jar">
    <attribute name="javadoc_location" value="jar:file://${tomcat.home}/src/${jar-name}-javadoc.jar!/"/>
  </source-attachment></echo>
            </then>
        </if>
    </target>



    <target name="deploy-output-xml" depends="build-xml">
        <echo>====================================================================</echo>
        <echo>部署 ${output.file} 到 .metadata</echo>

        <eclipse.convertPath resourcepath="workspace_loc:/" property="workspace_loc"/>
        <copy file="${output.file}" todir="${workspace_loc}/.metadata/.plugins/org.eclipse.jst.server.core" />
    </target>


    <target name="show-properties">
        <echoproperties />
    </target>

</project>


執行前需要 ant-contrib,然後啟動配置必須是[在工作區的同一個 JRE 中執行],這是因為用到 Eclipse Ant 所以提供的環境變數,執行完後重新啟動 Eclipse 就可以看到連結的附件。

2015-02-27 19:57

在 Eclipse 安裝 ant-contrib

先下載 ant-contrib,然後放置到
{eclipse_home}/plugins/org.apache.ant_XXXXXXX/lib

接者在 [視窗]->[喜好設定]->[Ant 執行時期]->[類別路徑]->[Ant 起始目錄項目]->[新增外部 JAR]->[選擇 ant-contrib.jar]


然後在要使用 ant-contrib 的 build.xml 中加入以下宣告:
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
2012-03-08 19:38

Aptana Unified Builder 卡住

Aptana 2 的建置器(Aptana Unified Builder)時不時就會卡住,通常會發生這種狀況的原因,就是專案中有某個檔案無法正常解析,或路徑不對造成的。

解決的辦法是先關閉『專案->自動建置』,然後將有問題的專案複製一份到新的工作區,然後用過濾法找出無效的檔案,然後先刪除再重新建立。
2011-12-21 19:03

[轉載] Aptana Scripting 一個背景處理的範例

轉載自:Monkeying with Eclipse | Info Support

/*
 * Menu: Info Support > Find commented code
 * Kudos: Peter Hendriks
 * License: EPL 1.0
 * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
 */
function main() {
    loadBundle("org.eclipse.core.jobs");

    var ProgressMonitorDialog = Packages.org.eclipse.jface.dialogs.ProgressMonitorDialog;
    var IRunnableWithProgress = Packages.org.eclipse.jface.operation.IRunnableWithProgress;

    var runnableWithProgress = new IRunnableWithProgress({ run: runCommentSearch });
    new ProgressMonitorDialog(window.getShell()).run(true, true, runnableWithProgress);

    window.getActivePage().showView("org.eclipse.ui.views.TaskList");
}

function runCommentSearch(monitor) {
    var files = resources.filesMatching(".*\\.java");
    monitor.beginTask("Searching for commented code...", files.length);
    try {
        var match;
        for each( file in files ) {
            monitor.subTask(file.getEclipseObject().getName());
            file.removeMyTasks();
            var previousLineCodeComment = false;
            for each( line in file.lines ) {
                if (monitor.isCanceled()) {
                    return;
                }
                if (match = line.string.match(/^.*\/\/.*[;{}]\s*$/)) {
                    if (!previousLineCodeComment) {
                        line.addMyTask("Commented code: " + match[0]);
                    }
                    previousLineCodeComment = true;
                } else {
                    previousLineCodeComment = false;
                }
            }
            monitor.worked(1);
        }
    } finally {
        monitor.done();
    }
}
2011-12-21 18:58

Aptana Scripting - Find TODOs 範例中的參數

/*
 * Menu: Editors > Find TODOs
 * Kudos: Ingo Muschenetz
 * License: EPL 1.0
 * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
 */

function main() {
    var files = resources.filesMatching(".*\\.js");
    var match;

    for each( file in files ) {
        file.removeMyTasks( );
        for each( line in file.lines ) {
            if (match = line.string.match(/\/\/TODO: (.*)/)) {
                line.addMyTask( match[1] );
            }
        }
    }
    window.getActivePage().showView("org.eclipse.ui.views.TaskList");
}

只列出當前文件的方法
var files = resources.filesMatching('.*/'+editors.activeEditor.textEditor.titleToolTip);

resources 部分的方法
filesMatching(".*\\.js")
filesMatchingForProject("Project Name",".*\\.js")
filesMatchingIgnoreCase(".*\\.js")
filesMatchingForProjectIgnoreCase("Project Name",".*\\.js")

file 部分的方法
size
lines
removeMyTasks()

line 部分的方法
lineNumber
string
addMyTask('Task String')
2011-12-21 18:46

Aptana Scripting 學習筆記

  • 在任何一個專案的頂層目錄,建立一個名稱為 scripts 或 monkey 的目錄
  • 在此目錄下建立副檔名為 *.js 或 *.em 的 JavaScript 的文件

一個空白文件的內容如下:
/*
 * Menu: Samples > Execute Snippet
 * Key: M1+M2+M3+F
 * Kudos: Jax Hu
 * License: EPL 1.0
 * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
 */

function main(){
}


快捷鍵的代號對應:
M1Control/Command
M2Shift
M3Alt/Option


一個可以用來顯示物件成員的函數:
/**顯示物件的成員
 * @param {Object} val 物件
 */
function var_dump(val){
    var name, value, temp=[];

    for (name in val) {
        try {
            value = (val[name]+'').
                replace("function",'<b style="color:#00f;">$&</b>');
        }catch (e) {
            value = (e+'').fontcolor('red');
        }
        temp.push('<b style="color:#707;">'+name+'</b> = '+value);
    }

    webView = views.getView("var_dump");
    webView.showView(true);
    webView.setTitle('var_dump');
    webView.setHTML(temp.join("<hr/>").fixed());
}


常用方法以及數值:
/*當前文件的位置
 * => D:/WorkSpace/my_project/test.js */
location

/*當前文件的名稱
 * => test.js */
editors.activeEditor.title

/*當前的文件內容*/
editors.activeEditor.source

/*當前文件的 URI 位址*/
editors.activeEditor.uri

/*儲存當前文件*/
editors.activeEditor.save();

/*對當前文件-開啟另存新檔的對話匡*/
editors.activeEditor.textEditor.doSaveAs()

/*對當前文件的目錄路徑
 * => D:/WorkSpace/my_project */
editors.activeEditor.textEditor.editorInput.file.parent.location

/*目前開啟的所有文件*/
editors.all[];

/*儲存全部編輯器,傳入 true 會開啟存檔提示*/
window.workbench.saveAllEditors(false);

/*重新開啟 Eclipse*/
window.workbench.restart();

/*關閉 Eclipse*/
window.workbench.close();

/* 開新的編輯器,可以透過這個開啟空白文件,或是已經存在的檔案,
 * 之後 editors.activeEditor 會轉到這個文件上 */
fileUtils.open('textile_to_redmine.txt');

/*取得當前的專案名稱*/
editors.activeEditor.textEditor.editorInput.file.project.name;

/*取得所有的專案*/
Packages.org.eclipse.core.resources.ResourcesPlugin.workspace.root.projects;
editors.activeEditor.textEditor.editorInput.file.workspace.root.projects


建立一個新的視圖,或開啟已存在的視圖:
webView = views.getView("my_view_name");

/*顯示視圖*/
webView.showView(true);

/*設定標題*/
webView.setTitle("My View Title");

/*設定內容的HTML*/
webView.setHTML('<h1>OK</h1>');

/*或指定內容的網址*/
webView.url = "http://www.google.com";
webView.addEventListener("LocationChanging", function(event){
    var location = event.innerEvent.location;

    // Print out the location to the Java console
    Packages.java.lang.System.out.println("You clicked on: " + location);
});


替換選擇的文字區段:
/*選擇的起始位置*/
var starting = editors.activeEditor.selectionRange.startingOffset;

/*選擇的結束位置*/
var ending = editors.activeEditor.selectionRange.endingOffset;

/*選擇的文字內容*/
var text = editors.activeEditor.source.substring(starting, ending);

/*文字跳脫處理,或其他自訂的處理*/
text = escape(text);

/*替換選擇的文字*/
editors.activeEditor.applyEdit(starting, ending-starting, text);

/*重新選擇文字區段*/
editors.activeEditor.selectAndReveal(starting, text.length);


檔案存取:
var file = new File("myFile.txt");
file.createNewFile();
file.write("Date: ");
var text = file.readLines();


Web 資料請求的方式:
var req = new WebRequest();
req.open("GET", "http://xml.weather.yahoo.com/forecastrss?p=94103");
var text = req.send();
2011-12-21 15:05

[轉載] Aptana Scripting File.js Class Document

轉載自:Koders Code Search: File.js - JavaScript
/**
 * File.js
 *
 * Adding this file to your Active Libraries will give you code assist for the
 * Aptana Studio scripting engine.
 *
 * @author Kevin Lindsey
 * @version 1.0
 */

/**
 * This object represents a file or a directory in the file system
 *
 * @constructor
 * @param {String} name
 *      The relative or absolute path to a file or directory
 */
function File(name) {}

/*
 * Properties
 *

/**
 * Get the absolute path for this file or directory
 *
 * @type {String} Returns the absolute path to this file or directory
 */
File.prototype.absolutePath = "";

/**
 * Get the file's base name. This is the filename only without the extension.
 * If the file does not have an extension, then this will return the full
 * name
 *
 * @type {String} Returns this file's base name
 */
File.prototype.baseName = "";

/**
 * Determine if this file is readable
 * 
 * @type {Boolean} Returns true if this File is readable
 */
File.prototype.canRead = false;

/**
 * Determine if ths file is writable
 * 
 * @type {Boolean} Returns true if this File is writable
 */
File.prototype.canWrite = false;

/**
 * Determine if this file or directory exists in the file system
 *
 * @type {Boolean} Returns true if this File exists in the file system
 */
File.prototype.exists = false;

/**
 * Returns the file extension of this File
 *
 * @type {String} Returns the last instance of "." and the text after it.
 *      An empty string will be returned if no extension if found. The return
 *      value includes the '.'
 */
File.prototype.extension = "";

/**
 * Determines if thie File is a file in the file system
 *
 * @type {Boolean} Returns true if this File is a file in the file system
 */
File.prototype.isFile = false;

/**
 * Determines if this File is a directory in the file system
 *
 * @type {Boolean} Returns true if this File is a directory in the file
 *      system
 */
File.prototype.isDirectory = false;

/**
 * Returns a list of File objects for all files in the File. This is equivalent
 * to listing out all files in a directory
 *
 * @type {Array} Returns an array of File objects, one for each file and
 *      directory in this File
 */
File.prototype.list = [];

/**
 * Returns the file's name without path information
 *
 * @type {String} Returns the file's name
 */
File.prototype.name = "";

/**
 * Returns a new File object of this object's parent directory
 *
 * @type {File} Returns this file's parent File
 */
File.prototype.parentFile = {};

/**
 * Returns the character used to separate directories on the underlying OS
 *
 * @type {String} Returns the directory separator
 */
File.prototype.separator = "";

/*
 * Methods
 */

/**
 * Create a new file in the file system at the location specified by this
 * object
 *
 * @return {Boolean} Returns true if the file was created successfully.
 */
File.prototype.createNewFile = function() {};

/**
 * Return all lines from this File's text file
 * 
 * @return {Array} Returns an array of strings, one for each line in the file.
 */
File.prototype.readLines = function() {};


//eof
2011-12-21 15:05

[轉載] Aptana Scripting PrintStream.js Class Document

轉載自:Koders Code Search: PrintStream.js - JavaScript
/**
 * PrintStream.js
 *
 * Adding this file to your Active Libraries will give you code assist for the
 * Aptana Studio scripting engine.
 *
 * @author Kevin Lindsey
 * @version 1.0
 */

/**
 * This object represents an underlying Java PrintStream
 *
 * @constructor
 *
 /
function PrintStream() {}

/*
 * Methods
 */

/**
 * Print the given text to the underlying stream
 *
 * @param {String} text
 *      The text to send to the stream
 */
PrintStream.prototype.print = function(text) {};

/**
 * Print the given text to the underlying stream followed by end-of-line
 *
 * @param {String} text
 *      The text to send to the stream
 */
PrintStream.prototype.println = function(text) {};


//eof
2011-12-21 15:04

[轉載] Aptana Scripting Editor.js Class Document

轉載自:Koders Code Search: Editor.js - JavaScript
/**
 * Editor.js
 *
 * Adding this file to your Active Libraries will give you code assist for the
 * Aptana Studio scripting engine.
 *
 * @author Kevin Lindsey
 * @version 1.0
 */

/**
 * Editor
 *
 * @constructor
 * @extends {EventTarget}
 */
function Editor() {}

/*
 * Properties
 */

/**
 * Get/set the position of the cursor in this editor
 * 
 * @type {Number} The current cursor offset position
 */
Editor.prototype.currentOffset = 0;

/**
 * Get the File object that this editor is editing
 *
 * @type {File} Returns a File object or undefined
 */
Editor.prototype.file = {};

/**
 * Get the language MIME type for this editor
 * 
 * @type {String} Returns this editors language type
 */
Editor.prototype.language = "";

/**
 * Get the lexemes associated with this editor
 *
 * @type {Array} Returns an array of Lexemes
 */
Editor.prototype.lexemes = [];

/**
 * Get the line delimiter for this editor
 * 
 * @type {String} Returns the editor's line terminator
 */
Editor.prototype.lineDelimiter = "";

/**
 * Get the source associated with this editor
 *
 * @type {String} Returns the source text in this editor
 */
Editor.prototype.source = "";

/**
 * Get the length of the source in this editor
 * 
 * @type {Number} Returns the number of characters in this editor's document
 */
Editor.prototype.sourceLength = 0;

/**
 * Get the number of columns in a tab
 * 
 * @type {Number} Returns the number of spaces that equal one tab
 */
Editor.prototype.tabWidth = 0;

/**
 * Get the zero-based line number of the line at the top of the editor
 * 
 * @type {Number} The top-most line's index
 */
Editor.prototype.topIndex = 0;

/**
 * Get/set the editor's word wrap setting. Setting this to true turns on word
 * wrapping.
 * 
 * @type {Boolean} The word wrap setting.
 */
Editor.prototype.wordWrap = false;

/*
 * Methods
 */
 
/**
 * Apply an edit to the current document. This function allows you to delete
 * and insert text in one operation, if desired.
 *
 * @param {Number} offset
 *      The offset within the source where this edit is to take place
 * @param {Number} deleteLength
 *      The number of characters to remove before inserting the new text
 * @param {String} insertText
 *      The new text to insert at the given offset
 */
Editor.prototype.applyEdit = function(offset, deleteLength, insertText) {};

/**
 * Get the zero-based line number at the specified character offset
 * 
 * @param {Number} offset
 *       The character offset within the editor's document
 */
Editor.prototype.getLineAtOffset = function(offset) {};

/**
 * Scroll the editor to bring the current selection or caret position into
 * view.
 */
Editor.prototype.showSelection = function() {};


//eof
2011-12-21 15:04

[轉載] Aptana Scripting Global.js Document

轉載自:Koders Code Search: Global.js - JavaScript
/**
 * Global.js
 *
 * Adding this file to your Active Libraries will give you code assist for the
 * Aptana Studio scripting engine.
 *
 * @author Kevin Lindsey
 * @version 1.0
 */
 
/*
 * Properties
 */

/**
 * Retrieve the Editors object to access editors and editor events
 *
 * @type {Editors} Returns the global Editors object
 */
var editors = {};

/**
 * Retrieve the error print stream.
 *
 * @type {PrintStream} Returns the output stream used to display errors
 */
var err = {};

/**
 * This is a reference to the only instance of this object. All scripts run in
 * their own protected scope. However, this Global is accessible from all
 * scripts. Properties placed on "global" will be accessible to all scripts
 *
 * @type {Global} Returns a reference to the global scope
 */
var global = {};

/**
 * Retrieve the Menus object to access menus and menu events
 *
 * @type {Menus} Returns the global Menus object
 */
var menus = {};

/**
 * Retrieve the standard output print stream.
 *
 * @type {PrintStream} Returns the standard output stream
 */
var out = {};

/**
 * Retrieve the View object to access views and view events
 *
 * @type {Views} Returns the global Views object
 */
var views = {};

/*
 * Methods
 */

/**
 * Display an alert dialog with the given message
 *
 * @param {String} message
 *      The message to display in the dialog
 */
var alert = function(message) {};

/**
 * Execute a string in the current shell. This is experimental and may be
 * removed in a future version of the scripting environment
 *
 * @param {String} command
 *      The command to execute in the shell
 * @return {Object} Returns an object with the following properties: code,
 *      stdout, stderr. Code is the return code from the command. Stdout
 *      contains any text that was emitted to standard out while it was
 *      executing. Likewise, stderr contains any errors that were emitted.
 */
var execute = function(command) {};

/**
 * Call Java's System.getProperty.
 *
 * @param {String} property
 *      The name of the property to retrieve
 * @return {String} Returns the specified property value or the string
 *      "undefined" if the property does not exist
 */
var getProperty = function(property) {};

/**
 * Include a JavaScript file into the current script's scope. this is used to 
 * load dependent libraries into the script that invokes this function.
 * 
 * @param {String} filename
 *      The name of the file to include in the script
 */
var include = function(filename) {};

/**
 * Load a library into the scripting environment. Each script loaded with this
 * function will be assigned a unique ID and, if it exists, the init() function
 * will be invoked. This gives each script the ability to initialize itself and
 * to setup any event listeners it wishes to subscribe to.
 *
 * Each script will exist in its own scope; however, this Global is also
 * included in the scope chain. All variables and functions defined in the
 * script will not collide with any other scripts.
 *
 * Shared properties can be placed on the "global" property. All scripts loaded
 * via this function will then be able to see those properties. This can be
 * used to share data between scripts.
 *
 * @param {String} filename
 *      The file system path to the script to load
 * @return {String} Returns a unique string identifier for the loaded script.
 *      This identifier can be used later to invoke functions within the
 *      script; however, this is more for internal use at this point. If the
 *      script fails to load, this will return undefined.
 */
var loadBundle = function(filename) {};


//eof
2011-12-21 15:04

[轉載] Aptana Scripting Editors.js Class Document

轉載自:Koders Code Search: Editors.js - JavaScript
/**
 * Editors.js
 *
 * Adding this file to your Active Libraries will give you code assist for the
 * Aptana Studio scripting engine.
 *
 * @author Kevin Lindsey
 * @version 1.0
 */

/**
 * Editors
 *
 * @constructor
 */
function Editors(){}

/*
 * Properties
 */

/**
 * Get all editors currently being displayed
 *
 * @type {Array} Returns an array of Editor instances, one for each open editor
 */
Editors.prototype.all = [];

/**
 * Get the currently active editor
 *
 * @type {Editor} Returns the currently active editor or undefined if no editor is open
 */
Editors.prototype.activeEditor = {};

/*
 * Methods
 */

/**
 * Get the object that represents all editors of a given type. This is
 * typically used to register event handlers for a given event type for
 * all editors of a specified language.
 *
 * @param {String} type
 *      The editor type to retrieve. Currently, this is the MIME type for the
 *      language the editor supports.
 * @return {EditorType} Returns the editor type for the given MIME type or
 *      undefined if no editor type exists for the given MIME type
 */
Editors.prototype.getEditorType = function(type) {};

/**
 * Open the specified filename in a new editor
 *
 * @param {String} filename
 *      The name of the file to open in the file system
 * @return {Editor} Returns a new Editor object for the newly opened editor
 */
Editors.prototype.open = function(filename) {};


//eof
2010-12-08 13:45

SVN connection settings for Eclipse

建立 SVN 連結



將現有專案 commit 到 SVN 上



開啟 SVN keywords PS:這個功能是由 client 處理的
選取專案 -> 右鍵 -> 內容



在專案下建立以下內容,然後 commit 到 SVN 上
<?php
// SVN-keywords-test.php
/*
$Id$
$Date$
$Revision$
$Author$
$HeadURL$
*/

參考來源:
Subversion中的关键字替换
关键字替换
如何结合使用 Subversion 和 Eclipse
在eclipse下的SVN插件配置忽略文件和文件夹
2010-10-07 18:04

讓 Eclipse Task tag 能用在任何文件類型上

之前為了找能夠在 SQL File 中使用 Task tag 套件花了不少時間,最後發現 Mylyn 的套件中有一個針對所有專案下 DTD 跟 XML 的 Task tag 功能,索性利用這個功能讓 SQL 也支援 Task tag。

因為這個功能只支援 XML 格式的註解 <!-- 至 -->,所以只要巧妙的利用這個特性就可以達到我們要的功能。


首先在『內容類型 → DTD』中加入 *.sql 。



再來在 SQL file 的起始處加入 -- <!--



在結尾處加上 -- -->



開啟『專案 → 內容』啟用 Task Tags,並將 『Filters』中的 XML 取消。



我希望可以標出所有資料表的定義,所以在這裡我加入 TABLE 這個關鍵字。



接著就可以看到很快樂的結果了。



當然在 Task View 中也會列出所有的標記。
2010-09-03 03:28

用 Eclipse CDT 編譯 CppSQLite3

工作上為了讓 sqlite 可以在 platform 上執行,所以必須從完整的 source code 開始編譯,對於不怎麼熟悉 Makefile 的我這真是一件麻煩的事,還好以前有玩過 CDT,索性就利用他可以自動建立 Makefile 的功能來做。

不過我是使用 Eclipse 3.2 版的 CDT,Eclipse 3.5 的 CDT 裡的 Makefile 我不太會用,也沒有時間去找文章。


這裡我下載了兩個檔案:
SQLite -> sqlite-source-3_7_2.zip
CppSQLite -> CppSQLite_3_1_demo_and_src.zip


首先建立動態連結庫
  1. 新增 "Managed Make C++ Project" 專案 -> 名稱 "cppsqlite"

  2. 在 Project Type 中選擇 Shared Library

  3. 在專案下新增 src 資料夾

  4. 複製 sqlite-source-3_7_2.zip 中所有的 source code 至 src 除了 shell.ctclsqlite.c

  5. 再複製 CppSQLite_3_1_demo_and_src.zip 中的 CppSQLite3.hCppSQLite3.cpp

  6. 開啟:專案 -> 內容

  7. 增加 Defined symbols 變數 -> SQLITE_CORE


  8. 在 C++ 跟 C 的 Optimization 的參數中增加 -fPIC 最佳化參數


  9. 按下『確定』後就會開始編譯,檔案有點多要稍微等一下



再來建立主程式專案
  1. 新增 "Managed Make C++ Project" 專案 -> 名稱 "sqlite-test"

  2. 在 Project Type 中選擇 Executable

  3. 在專案下新增 src 資料夾

  4. 複製 CppSQLite_3_1_demo_and_src.zip 中的 CppSQLite3Demo.cpp 至 src

  5. 開啟:專案 -> 內容

  6. 新增 Include paths -> "../../cppsqlite/src"
    這個設定是在告知編譯時額外 Include 的進來 Header(*.h) 的路徑。


  7. 新增連結路徑:
    Library search path -> "../../cppsqlite/Debug"
    Libraries -> cppsqlite
    這個設定是給 gcc 在做連結時需要的搜尋路徑,以及需要連結的對象名稱


  8. 按下『確定』後就會開始編譯

  9. 接著要將 cppsqlite.dll 複製到 sqlite-test/Debug 下
    Windows 的 lib 名稱為 "cppsqlite.dll"
    Linux 的 lib 名稱為 "libcppsqlite.so"

  10. 然後就可以執行 sqlite-test.exe 了 (一整個就很快樂)
專案範例:sqlite-test.zip
2010-08-28 19:42

Eclipse + PHPEclipse + Aptana 安裝

要安裝 Eclipse 說實在的還需要一點經驗
首先 Eclipse 是 Base 在 Java 上的應用程式,所以先到 Java.com 去下載 Java Runtime Environment。
再來到 Eclipse Downloads 去下載 Eclipse 主程式。


這裡我還是用我熟悉 3.5 版本 Eclipse Galileo 做範例,既然 Web 開發那就直接下載 Eclipse for PHP Developers 這個有封裝 PDT 的 Package
Downloda : eclipse-php-galileo-win32.zip



再來我們先來去找中文語言包 Eclipse Babel Project Downloads
Downloda :
BabelLanguagePack-eclipse-zh_TW_3.5.0.v20100814074441.zip
BabelLanguagePack-tools.mylyn-zh_TW_3.5.0.v20100814074441.zip
BabelLanguagePack-tools.pdt-zh_TW_3.5.0.v20100814074441.zip
BabelLanguagePack-tptp.platform-zh_TW_3.5.0.v20100814074441.zip
BabelLanguagePack-rt.equinox-zh_TW_3.5.0.v20100814074441.zip

下載好後將全部解壓縮就可以了,然後執行 eclipse.exe



先來安裝 PHPEclipse,進入 -> 說明 -> Install New Software
在 Work with 貼上 PHPEclipse 的線上安裝路徑,然後按下 Enter,選項出現後選擇 PHPEclipse,下一步 下一步 同意 完成 (因為是線上安裝,所以會有點久)
http://phpeclipse.sourceforge.net/update/stable/1.2.x/



再來安裝 Aptana,進入 -> 說明 -> Install New Software
在 Work with 貼上 Aptana 的線上安裝路徑,然後按下 Enter,選項出現後選擇 Aptana Studio,下一步 下一步 同意 完成
http://download.aptana.com/tools/studio/plugin/install/studio



最後來安裝我常用的套件
  • Database Developers:可以撰寫 SQL script 跟連接 Database
  • Subversive:用來連接 SVN 的 Client 套件
  • RSE:可以連接 SSH 跟 SFTP 的遠端連接套件

進入 -> 說明 -> Install New Software
在 Work with 的選項中選擇 Galileo - http://download.eclipse.org/releases/galileo,然後按下 Enter,然後就會出現一堆官方套件選擇
  • Data Tools Platform Enablement Extender SDK
  • Data Tools Platform Extender SDK
  • Subversive SVN Integration for the Mylyn Project
  • Subversive SVN Team Provider
  • Remote System Explorer End-User Runtime
  • Remote System Explorer User Actions

一樣 下一步 下一步 同意 完成

重開之後會跳出 Subversive 的選項,OS 是 Windows 的話選擇下面的選項:
  • JavaHL 1.5.4 Win32 Binaries
  • JavaHL 1.6.0 Win32 Binaries
  • Native JavaHL 1.5 Implementation
  • Native JavaHL 1.6 Implementation
  • Subversive SVN Connectors



因為額外多裝了一些官方套件,順便來去下載語言包
BabelLanguagePack-datatools-zh_TW_3.5.0.v20100814074441.zip
BabelLanguagePack-technology.subversive-zh_TW_3.5.0.v20100814074441.zip



最後最後中肯的建議,別在單一一個 Eclipse 上加太多套件,不然 Eclipse 會變成吃效能的怪物,最好依工作性質分成幾個不同類型的開發環境。
2010-07-16 22:41

用 Eclipse 寫 Wiki

在 Eclipse 中的 Mylyn 內建 WikiText 這個編輯器
讓你在 Eclipse 中也可寫 Wiki 文件
這真是一件快樂的事 至少可以不用去面對那永遠對不準的 word


WikiText 提供下列五種格式的 wiki 編寫
*.textile, *.tracwiki, *.mediawiki, *.twiki, *.confluence


首先在專案中建立副檔名為 .textile 的純文字文件



寫下這簡單的 wiki 文件
h1(#id). 標題1

* 無序列表
* 無序列表
** 無序列表
** 無序列表
*** 無序列表

h2. 標題2

# 有序列表
# 有序列表
## 有序列表 jhgjhgjgjgj

h3. 標題3

p. 文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落,文字段落

h4. 標題4

h4. 標題4

h5. 標題5

h3. 標題3

h6. 標題6



在[概要]中會出現文件中所有的標題,在編輯時還可以使用[折疊](天阿!一整個就太快樂了)



編輯完後在文件上按右鍵選擇[WikiText->Generate HTML]就會自動產生 html 檔



接著用 Browser 開啟剛剛生成的 html 就可以看到美美的文件了



當然也可以自訂自己想要的樣式,在[視窗->喜好設定->一般事項->編輯器->文字編輯器->WikiText]中就可以設定自己想要的樣式了



參考來源:
Getting Started With WikiText | Eclipse Zone
Help - Eclipse SDK: Mylyn WikiText User Guide