Creating Editors for Core Extensions

From Skyway Wiki

Jump to: navigation, search

The following high level recipe describes the extension points and code required when creating Eclipse Editors that are used to modify an Extensions off of Skyway's Ecore model. This recipe will use Data Persistence extension (persistence.ecore) on the Domain Object(DataType) as an example, which adds JPA annotations to the Domain Object java class.

In org.skyway.integration.data.persistence:

These first 3 steps are the conclusion of Extending the Core Model and Adding Extended Types

  1. Add Plug-in Extension: ContentTypes
    1. Add the org.eclipse.core.runtime.contentTypes extension to the plugin.xml (Extensions tab) Give it an id.
    2. Right-click the new node and add a New > content-type
      • id: org.skyway.extension.data.persistence.datatypebinding
      • name: Domain Object Binding
      • base-type: org.skyway.extension.data.persistence
      • file-extensions: datatypebinding
  2. Add Plug-in Extension: ModelTypes. Provides additional information about the extended type, like file extension. The DataTypeBindingTypeDescriptor extends ExtendedSkywayTypeDescriptor.
    1. Add the org.skyway.core.modelTypes extension. Give it an id.
    2. Right-click > New > modelType
      • name: dataStoreBinding
      • typeDescriptor: org.skyway.integration.data.persistence.model.datatype.DataTypeBindingTypeDescriptor
  3. Add Plug-in Extension: ModelExtensionProvider. Sets the linkage between core and the extension.
    1. Add org.skyway.core.modelExtensionProvider. Give it an id.
    2. Tie it to org.skyway.integration.data.persistence.model.datatype.DataTypeBindingExtension
      • DataTypeBindingExtension extends AbstractModelExtension, and connects the core to the extension as well as contains synchronization methods (DataTypeBindingHelper) to keep the fields and relationships the same between the Domain Object (core) and JPA binding (extension).
  4. Develop the SWT UI
    1. DatabaseMappingPage (org.skyway.integration.data.persistence.ui.datatype.editor)
      • Extends org.skyway.core.ui.forms.ModelObjectFormPage
      • Sets up the overall GUI
      • initDataBindings method to bind EMF to SWT widget via Observables
      • setActive method that ensures SWT data is synchronized when opened
    2. Other classes in org.skyway.integration.data.persistence.ui.datatype.editor contain the SWT code to set up the UI. Use Skyway's SWT code in all plug-ins as a good reference and reuse mechanism.
  5. Add Plug-in Extension: editors
    1. Add org.eclipse.ui.editors extension to the plug-in
    2. Right-click > New > editor
      • id: org.skyway.designer.ui.datatype.DataTypeFormEditor
      • name: Domain Object Editor
      • icon: platform:/plugin/org.skyway.core.ui/icons/coretypes/small/DataType.gif
      • extensions: datatypebinding
      • class: org.skyway.designer.ui.datatype.editor.DataTypeFormEditor
      • contributor class: org.skyway.core.ui.forms.actions.CoreObjectEditorActionContributor
      • default: true
    3. Right-click the editor node > new > contentTypeBinding
      • contentTypeId: org.skyway.extension.data.persistence.datatypebinding
  6. Add Plug-in Extension: modelObjectFormPage
    1. Add org.skyway.ui.modelObjectFormPage
      • class: org.skyway.integration.data.persistence.ui.DataTypeFormPageExtension
      • name: org.skyway.core.ui.dataBaseMappingPage
      • coreType: org.skyway.core.model.data.impl.DataTypeImpl
      • formPageClas: org.skyway.integration.data.persistence.ui.datatype.editor.DatabaseMappingPage
      • enabled: true
      • description: Persistence Mapping
Personal tools