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.
- Menu label
- Hotkey(s)
- Listener(s)
- Kudos to the writer(s)
- License information
- DOM URL
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:
- Add the keyword Menu to your metadata.
- All menu items will be available under the Scripts menu.
- Use standard Eclipse syntax for menu and submenu items.
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:
- Add the Key keyword to your metadata.
- Use the following modifier key(s) + ASCII key:
- M1 (Command or Ctrl)
- M2 (Shift)
- M3 (Option or Alt)
- M4 (Ctrl on Mac)
- Also recognized (not preferred): ALT, COMMAND, CTRL, and SHIFT
- See Eclipse site for more key codes: http://www.eclipse.org/dash/monkey-help.php?key=writing
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:
- Add the Listener keyword to your metadata. This will attach itself to the specified event.
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:
- Add the DOM keyword to you metadata.
- A DOM is similar to any other plug-in in that if you not already have a DOM installed, Eclipse will automatically download it for you.
- You can use either a built-in DOM or specify a DOM URL:
- Built-in: "window"
- DOM URL: http://<update-site>/<dom-plugin-ID>
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.
- Add the onLoad keyword to your metadata.
- Specify the name of the function that you want to call when Eclipse loads.
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.
- Add the Kudos keyword to your metadata.
Example:
Kudos: Michelle Petersen
License metadata
Use the License keyword to specify the appropriate license for your script.
- Add the License keyword to your metadata.
Example:
The following example uses the Eclipse Public License 1.0:
License: EPL 1.0