Developer Studio Kernel includes a sample plug-in project, which demonstrates the usage of the Web editor framework.
- Download the
samplewebeditor.zipfile and extract it to a desired workspace.
- In an Eclipse Luna SR2 instance (with WSO2 Developer Studio Kernel installed), click File > Import > Existing Projects into Workspace to import the project. After importing, the following project structure is created.
- As shown above, the
SampleWebEditorfolder contains a simple Web application (which only uses front end technologies), which is used as an editor for Developer Studio Kernel.
- In the
plugin.xmlfile, this Web application is added as an embedded Web application for Developer Studio Kernel by using the
org.wso2.developerstudio.embedded.webapextension point provided by Developer Studio Kernel.
SampleTextAreaWebEditor.javaeditor class is created for the Web application by extending the
org.wso2.developerstudio.eclipse.webui.core.editor.AbstractWebBasedEditorclass. Implement the
getWebAppIDabstract method and return the unique ID you passed to the extension point while adding the Web application in the previous step.
- Assign this editor to a particular file type to ensure that Eclipse launches this editor by default when opening that type of file. In the
plugin.xmlfile, this editor is registered using the
org.eclipse.ui.editorsextension point provided by Eclipse.
A new editor has been created and assigned to the files with the
.webeditor extension. (Note that binding the editor to a file using the content type of file rather than the extension type is also possible for more advanced use cases).
Follow the steps below to test the plug-in:
- Click Run > Run Configurations.
- Create a new run configuration for Eclipse Application.
- Run the plug-in using the created run configuration.
- Create an empty project in an open Eclipse instance.
- Create a new file with the
.webeditorextension under the project created in the previous step.
- Double-click the file and it opens in the sample Web based editor you created.