Adding support for a new Ajax library

From Aptana Development

An Ajax library is added to Aptana in the same manner as any other Eclipse plugin. We've provided a number of extension points to allow users to customize this to their liking. This also allows user the flexibility provide anything from a simple set of documentation requiring no coding, to complete Java integration.

Contents

Example

A complete example is provided by downloading the example provided at: http://www.aptana.com/downloads/ajax_library_plugin_sample.zip

To modify the sample

  1. Download the zip file above
  2. Rename the folder to the name of your library (e.g. com.jquery.1.1.3.1). Change the version number in the folder name to reflect your library version
  3. Do a search and replace in all files for org.library.name.0.1 and replace with the folder name (e.g. com.jquery.1.1.3.1)
  4. Import the project into Aptana
  5. Search and replace LibraryName in all files with the name of your library (i.e. 'Ext 1.0')
  6. Search and replace libraryname in all files with the name of your library (lower case, i.e. 'ext')
  7. Search and replace OrganizationName with your organization name (i.e. Aptana, Inc.)
  8. You will see the snippets and scripts you are adding in your project appear automatically in the Snippets and Scripts views. Other items like help and library wizards will require you to deploy the plugin to test

There are a number of other references to libraryname located in folder names, etc. Just modify those to suit, making sure to match what is in the plugin.xml file with what you have in the project.

To test the plugin

  1. Drop the above folder into your Aptana/plugins folder
  2. Restart Aptana
  3. Note: that scripts and snippets can be tested even while working on the project inside Aptana. The other items need a Aptana restart to see changes

To share the plugin with others

  1. Zip the contents of the folder to a zip file, i.e. org.library.name.0.0.zip. Make sure you are not zipping the folder, but rather the contents of the folder (thus the contents should be at the root of the .zip file)
  2. Rename the file from .zip to .jar
  3. Drop the .jar file into an Aptana/plugins folder

Versioning hints

  1. You will want to update the last number (the build number) every time you make a minor change. We recommend making a new plugin for significant differences in library versions, i.e. two different plugins for prototype 1.4 and prototype 1.5.

Reference

 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.2"?>
 <plugin>
   <!-- This adds documentation to the help index. We point to the XML file
           which acts as a table of contents for the rest of the HTML documentation -->
   <extension
       point="org.eclipse.help.toc">
       <toc file="docs/index.xml"/>
   </extension>

   <!-- This is the root folder of any Aptana Monkey scripts the library wishes to provide. 
           Comment this out if you have no scripts you wish to add -->
   <extension
       point="org.eclipse.eclipsemonkey.scriptpath">
       <scriptpath directory="scripts"/>
   </extension>

   <!-- This is the root folder of any snippets the library wishes to contribute to the snippets
           pane. Comment this out if no snippets are available -->
   <extension
       point="com.aptana.ide.snippets.snippetspath">
       <snippetsinfo directory="snippets"/>
   </extension>

   <!-- This places an entry in the "New Ajax Library Project" Wizard. The PNG image (16x16) is the icon to display in
           the wizard, and the "libraries" folder is the root folder under which all contents will be copied into
           the user's project -->
   <extension
       point="com.aptana.ide.documentation.library">
       <libraryinfo
       directory="libraries"
       iconFile="icons/library.png"
       name="LibraryName"/>
       </extension>

   <!--  This extension point allows the user to contribute samples to the "samples" pane.
            * The PNG image (16x16) is the image to display next to the library name.
            * The "samples" directory is the root directory under which all samples live (note, no nesting of samples).
            * The "infoFile" is an HTML index file which can be used to provide additional information about the samples.
            * The preview handler can be left alone...that indicates we've created a special class that
               allows the user to preview a HTML sample without needing to import it as a project.

           The "includePath" sub element allows us to copy common code into a project when creating or previewing the sample,
           thus preventing use from needing to include the library in every sample.
   -->
   <extension
       point="com.aptana.ide.samples.samplespath">
       <samplesinfo
           directory="samples"
           iconFile="icons/library.png"
           infoFile="samples/index.html"
           name="LibraryName Samples"
           previewHandler="com.aptana.ide.documentation.samples.AjaxSamplesPreviewHandler">
           <include path="libraries/lib"/>                   
       </samplesinfo>
   </extension>

   <!--  The views extension point allows the library to contribute an HTML view to the IDE. Examples of this
            can be found in the EXT or jQuery projects where they provide documentation or external functionality.
        
            Note the special URL starting with bundleresource:// which allows us to specify a resource local to
            this plugin -->
   <extension
       point="org.eclipse.ui.views">
       <view
           category="com.aptana.ide.documentation"
           class="com.aptana.ide.core.ui.views.browser.DefaultBrowserView"
           icon="icons/library.png"
           id="com.aptana.ide.documentation.libraryname.sampleview"
           name="LibraryName Sample View">
           <description>bundleresource://org.library.name.0.0/views/sampleview/sampleview.html</description>
       </view>
   </extension>

   <!-- You can provide automatic code assist for your library by creating a scriptdoc library in XML and importing it
   -->
   <extension
       point="com.aptana.ide.editor.js.scriptdoc">
        <xml-file path="support/LibraryNameAPI.xml" user-agent="LibraryName" />
   </extension>  
</plugin>