Aptana Studio ヘルプ > はじめに > Scripting with Eclipse Monkey

Adding metadata to an Eclipse Monkey script

Adding metadata to your script tells Eclipse how it should run your script. The list below gives examples of the type of metadata that you can add to a script.

All metadata is optional; it simply helps your script run the way that you would like it to run.

The example below shows some of the common ways to use metadata. In this example, a script called "Fun with Monkey" can be run either via the Scripts > Fun with Monkey menu item, the Alt+M hotkey, and will also run the "main" routine when Eclipse loads. This script was written by Michelle Petersen, uses the Eclipse Public License 1.0, and codes against the DOM "sample.doms", which is available on the Aptana snippets web site. The instructions below give more details about how to use each piece of metadata.

/*
 * Menu: Fun with Monkey
 * Key: M3+M
 * Kudos: Michelle Petersen
 * License: EPL 1.0
 * DOM: http://snippets.aptana.com/sample.doms
 * OnLoad: main()
 */

Contents

Reference

Menu metadata

To add menu information to a script:

Example 1:

Menu: Fun with Monkey

In the above example, you can access the script via Scripts > Fun with Monkey.

Menu: my_submenu > Fun with Monkey

In the above example, you can access the script via Scripts > my_submenu > Fun with Monkey.

Key metadata

Use the Key keyword to add hotkey shortcuts to your scripts.

To assign hotkeys to your scripts:

Example:

The following example assigns the Alt+M key shortcut to a script:

Key: M3+M

Image metadata

Use the Image keyword to assign a small icon to appear on the toolbar for running your script. You can then just click the specified icon to run your script. Specify the path to your image location to set that image as your script icon.

Example:

Image: ../Images/iconComment.png

Listener metadata

Use the Listener keyword to add an event listener to your metadata. This will trigger your script to run on a specified event.

To assign an event listener to your script:

Example:

Listener: commandService().addExecutionListener(this);

DOM metadata

Use the DOM keyword to specify which DOM(s) you are scripting against.

To add DOM information to your script:

The following example downloads the DOM sample.doms from the Aptana snippets site:

DOM: http://snippets.aptana.com/sample.doms

onLoad metadata

Use the onLoad keyword to have your script run on startup.

Example:

The following example calls the main() function when Eclipse loads:

OnLoad: main()

Kudos metadata

Use the Kudos keyword to give yourself or the writer of the script credit for writing the script.

Example:

Kudos: Michelle Petersen

License metadata

Use the License keyword to specify the appropriate license for your script.

Example:

The following example uses the Eclipse Public License 1.0:

License: EPL 1.0

Related Topics