Tutorial - My First Sphinx Project
Introduction
This tutorial will guide you through the development of a simple application based on Sphinx.
The resulting application is quite simple (1 class, 2 projects, few extension point contributions).
However, thanks to the power of Sphinx, it is really functional.
Our application is a model-based application.
For the purpose of this tutorial we will use the Extended Library Model Example provided by EMF.
Step 1: Getting the example meta-model
The example meta-model is provided by EMF.
It consists in three generated plug-ins.
Getting them is quite simple:
- Open menu ;
- Click ;
- Click to generate the three related projects, org.eclipse.emf.examples.library, org.eclipse.emf.examples.library.edit and org.eclipse.emf.examples.library.editor.
Step 2: Creating the plug-in with meta-model descriptor
The meta-model descriptor is a key-notion of Sphinx.
It consists in a class identifying a meta-model to be used in the workspace.
Each application based on Sphinx has to provide such a meta-model descriptor for each meta-model it uses.
Step 2.1: Creating the enclosing project
- Open menu and click ;
- Call it org.eclipse.sphinx.examples.library.ide and click ;
- Disable option and click on .
Step 2.2: Adding the plug-in dependencies
- Edit the MANIFEST.MF file in org.eclipse.sphinx.examples.library.ide/META-INF;
- In the tab, add the required plug-in org.eclipse.sphinx.emf.
Step 2.3: Creating the class
- Select the package contained by the org.eclipse.sphinx.examples.library.ide plug-in and create an new class (right-click, then );
- Call it EXTLibraryMMDescriptor;
- Provide its superclass org.eclipse.sphinx.emf.metamodel.AbstractMetaModelDescriptor;
- Click on .
Step 2.4: Creating the constructor
Edit the EXTLibraryMMDescriptor code to add the following default constructor:
public EXTLibraryMMDescriptor() {
super("org.eclipse.sphinx.examples.library", EXTLibraryPackage.eNS_URI);
}
Step 2.5: Contributing to the meta-model descriptor extension point
TODO: Explain the object of this extension point.
This plug-in contributes to the meta-model descriptor provided by Sphinx.
- Open the META-INF/MANIFEST.MF file;
- Select the tab;
- Click , uncheck option and select extension point org.eclipse.sphinx.emf.metaModelDescriptors; then click ;
- In org.eclipse.sphinx.emf.metaModelDescriptors add a new descriptor with the following property:
| id |
org.eclipse.sphinx.examples.extlibrary |
| class |
org.eclipse.sphinx.examples.library.ide.metamodel.EXTLibraryMMDescriptor |
Step 3: Creating the UI plug-in
Now we will create a second plug-in which deals with all what is related to the user interface.
This plug-in does not contain any code.
It only contributes to extension points of the Eclipse UI.
Step 3.1: Creating the enclosing project
- Open menu and click ;
- Call it org.eclipse.sphinx.examples.library.ide.ui and click ;
- Enable option and click .
Now the project exists and may contribute to extension points.
Step 3.2: Contributing to the navigator viewer
TODO: Explain the object of this extension point.
First, the UI plug-in contributes to the navigator viewer.
- Open the META-INF/MANIFEST.MF file;
- Select the tab;
- Click , uncheck option and select extension point org.eclipse.ui.navigator.viewer; then click ;
- In org.eclipse.ui.navigator.viewer add a new viewerContentBinding with the following property:
| viewerId |
org.eclipse.sphinx.examples.explorer.views.modelExplorer |
- In org.eclipse.sphinx.examples.explorer.views.modelExplorer add a new includes;
- In (includes) add a new contentExtension with the following property:
| pattern |
org.eclipse.sphinx.examples.library.ide.ui.navigatorContent.extendedlibrary |
Step 3.3: Contributing to the navigator content
TODO: Explain the object of this extension point.
The UI plug-in contributes to the navigator content.
- Click and select extension point org.eclipse.ui.navigator.navigatorContent; then click ;
- In org.eclipse.ui.navigator.navigatorContent add a new navigatorContent with the following properties:
| id |
org.eclipse.sphinx.examples.library.ide.ui.navigatorContent.extendedLibrary |
| name |
Extended Library Content |
| contentProvider |
org.eclipse.sphinx.emf.explorer.BasicExplorerContentProvider |
| labelProvider |
org.eclipse.sphinx.emf.explorer.BasicExplorerLabelProvider |
- In Library Content add a new triggerPoints;
- In (triggerPoints) add a new and;
- In (and) add a new instanceof with the following property:
| value |
org.eclipse.core.resources.IFile |
- In (and) add a new test with the following properties:
| property |
org.eclipse.sphinx.emf.isInScope |
| value |
true |
- In (and) add a new test with the following properties:
| property |
org.eclipse.sphinx.emf.metaModelIdMatches |
| value |
org\.eclipse\.sphinx\.examples\.extlibrary |
- In Library Content add a new possibleChildren;
- In (possibleChildren) add a new and;
- In (and) add a new instanceof with the following property:
| value |
org.eclipse.emf.ecore.EObject |
- In (and) add a new test with the following properties:
| property |
org.eclipse.sphinx.emf.classNameMatches |
| value |
org\.eclipse\.emf\.examples\.extlibrary\..* |
- In Library Content add a new dropAssistant with the following properties:
| id |
org.eclipse.sphinx.examples.library.ide.ui.navigatorContent.dropAssistant.extendedLibrary |
| class |
org.eclipse.sphinx.emf.explorer.BasicDropAdapterAssistant |
- In (possibleDropTargets) add a new instanceof with the following property:
| value |
org.eclipse.emf.ecore.EObject |
Step 3.4: Contributing to the Eclipse editors
TODO: Explain the object of this extension point.
The UI plug-in contributes to the Eclipse editors.
- Click and select extension point org.eclipse.ui.editors; then click ;
- In org.eclipse.ui.editors provides the following properties to the editor:
| id |
org.eclipse.sphinx.examples.library.ide.ui.editors.extendedLibrary |
| name |
Extended Library Example Editor |
| icon |
<path to a gif file used as an icon> |
| extensions |
Library, Writer, Book |
| class |
org.eclipse.sphinx.emf.editors.forms.BasicTransactionalFormEditor |
| contributorClass |
org.eclipse.sphinx.emf.editors.forms.BasicTransactionalEditorActionBarContributor |
- In Library Example Editor add a new contentTypeBinding with the following property:
| contentTypeId |
org.eclipse.emf.examples.library.extendedLibrary |
Step 3.5: Contributing to the Eclipse property contributor
TODO: Explain the object of this extension point.
The UI plug-in contributes to the property contributor.
- Click and select extension point org.eclipse.ui.views.properties.tabbed.propertyContributor; then click ;
- In org.eclipse.ui.views.properties.tabbed.propertyContributor provides the following properties to the propertyContributor:
| contributorId |
org.eclipse.sphinx.examples.library.ide.ui.editors.extendedlibrary |
| labelProvider |
org.eclipse.sphinx.examples.common.ui.providers.AppearanceExampleTabbedPropertySheetTitleProvider |
- In (propertyContributor) provides the following property to the propertyCategory:
Step 3.6: Contributing to the Eclipse property tab
TODO: Explain the object of this extension point.
The UI plug-in contributes to the property tab.
- Click and select extension point org.eclipse.ui.views.properties.tabbed.propertyTabs; then click ;
- In org.eclipse.ui.views.properties.tabbed.propertyTabs provides the following property to the propertyTabs:
| contributorId |
org.eclipse.sphinx.examples.library.ide.ui.editors.extendedLibrary |
- In (propertyTabs) provides the following properties to the propertyTab:
| label |
Advanced |
| category |
advanced |
| id |
org.eclipse.sphinx.examples.library.ide.ui.propertyTabs.advanced |
Step 3.7: Contributing to the Eclipse property sections
TODO: Explain the object of this extension point.
The UI plug-in contributes to the property sections.
- Click and select extension point org.eclipse.ui.views.properties.tabbed.propertySections; then click ;
- In org.eclipse.ui.views.properties.tabbed.propertySections provides the following property to the propertySections:
| contributorId |
org.eclipse.sphinx.examples.library.ide.ui.editors.extendedLibrary |
- In (propertySections) provides the following properties to the propertySection:
| tab |
org.eclipse.sphinx.examples.library.ide.ui.propertyTabs.advanced |
| id |
org.eclipse.sphinx.examples.library.ide.ui.propertySections.advanced |
| class |
org.eclipse.sphinx.emf.ui.properties.BasicTransactionalAdvancedPropertySection |
- In org.eclipse.sphinx.examples.library.ide.ui.propertySections.advanced add a new input with the following property: