Contributing to the Samples view
From Aptana Development
Contents |
Contributing to the Samples view
- Extension point contained located at com.aptana.ide.samples/schema/samplespath.exsd
Internal Examples
- com.aptana.ide.documentation
- Contributes JavaScript Toolkits samples
- com.aptana.ide.framework.apollo
- Contributes Adobe AIR samples
Extension point syntax
<extension point="com.aptana.ide.samples.samplespath">
<samplesinfo
directory="samples"
iconFile="icons/mysamples.png"
infoFile="samples/index.html"
name="My Samples"
projectHandler="com.xyz.MySampleHandler"
previewHandler="com.xyz.MyPreviewHandler">
<nature id="com.xyz.my.nature"/>
<include path="libraries/lib"/>
</samplesinfo>
</extension>
- samplesinfo - root element for contributing samples. Each element of this type will appear as a top-level node in the Samples view with the attribute 'name' as the label
- directory - directory containing the actual samples. Each directory directly under this attribute will be treated a sample node in the Samples view.
- iconFile - icon to display in the Samples View
- infoFile - Optional help file that will load in the internal Aptana browser
- name - label that will appear as a top-level element in the Samples view
- projectHandler - Class that must implement com.aptana.ide.samples.handlers.IProjectCreationHandler and must have a public default constructor. An instance of this class will be called each time a project is creating around one of the samples for this entry.
- previewHandler - Class that must implement com.aptana.ide.samples.handlers.IPreviewHandler and must have a default public constructor. An instance of this class will be called each time a preview is requested for one of the samples in this entry.
- nature - one or more nature ids that will be set on the project created in this samples entry.
- include path - one or more sets of common code that will be copied into the sample when it is either previewed or imported as a project.
Important notes
- Both the project creation handler and the preview handler should catch errors internally and present any error information to the user.
Samples Folder Structure
- samples/
- /index.html. This is used as the "table of contents" for the samples listed below
- sample1/... This is the first sample
- sample2/... This is the second sample
The extension point allows for the inclusion of a "library" folder which is common code across all samples (say jquery, ext, etc). This prevents code duplication.
Each sample should have an index.html or index.php if possible. This makes the sample easier to preview, both locally, and on the Cloud.
Sample Project Handler
This project handler is run for every iPhone project created. In this case we crate a new launch configuration.
public class IPhoneProjectCreationHandler implements IProjectCreationHandler
{
/**
* @see com.aptana.ide.samples.handlers.IProjectCreationHandler#projectCreated(org.eclipse.core.resources.IProject)
*/
public void projectCreated(IProject project)
{
//Add to launch configurations
iPhoneLaunchAdder.addiPhoneLaunch(project.getName());
// ...
}
}
Sample Preview Handler
A complete example is somewhat long, and situation dependent, but for an example, find class com.aptana.ide.documentation.samples.AjaxSamplesPreviewHandler.


