顯示具有 Aptana 標籤的文章。 顯示所有文章
顯示具有 Aptana 標籤的文章。 顯示所有文章
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-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 會變成吃效能的怪物,最好依工作性質分成幾個不同類型的開發環境。
2008-06-07 09:13

Aptana 中文亂碼問題(Snippets,Code Assist Profiles)

Aptana 中文亂碼雖然這已經不是問題了,而且也有很多網站提出解決方法了:

Windows選單→ Preferences → General → Content Types,選擇 Text ,在下方指定默認編碼為UTF-8,並添加文件類型,如*.js

如果文檔的編碼不是UTF-8就指定成相應的編碼。不過還是建議使用UTF-8編碼

雖然這個已經解決了,可是 SnippetsCode Assist Profiles 這兩個工具欄卻還是有亂碼的問題,所有的註解和說明都變成亂碼,在 Shan 的提點下找到亂碼的根源,發現原來是 Aptana 在讀檔時採用雙位元檢查,造成檔案編碼跑掉,改善的方法就是將這兩個工具欄的檔案改成 Big5 編碼格式(windows)

PS:Linux 則使用 UTF-8