Skip to content

EMF.edit Support

Dim edited this page Apr 22, 2019 · 1 revision

EMF.edit Support

E(fx)clipse contains the useful emf.edit support for JavaFX. This function will be reuse in this DSL.

Here is a whole example for the Webpage generation.

Define a minimal working DSL for TreeViewFX

EMFSupport for WebsiteModel{
    packagePath: 'de.dc.javafx.emfsupport.website.model.ui' 
    modelItemProviderAdapterFactory: de.dc.javafx.emfsupport.website.model.provider.ModelItemProviderAdapterFactory
    modelFactory: de.dc.javafx.emfsupport.website.model.ModelFactory
    rootType: de.dc.javafx.emfsupport.website.model.Website
    useUndoRedo: true  
    showCommandStack: true 
    showPropertyView: true 
    generateDemo: true
} 
  • The packagePath will generate all the classes to the given path.
  • [Name]ItemProviderAdapterFactory is generated by the EMF Framework and can set on this field. This is needed for showing all information about the domain in the TreeItem
  • [Name]Factory is generated by EMF too and is needed to create domain instances
  • useUndoRedo from Efxclipse core libary for using undo and redo in TreeViewFX
  • generateDemo will create an example application for the TreeView

Adding add context menu to the tree viewer

EMFSupport for WebsiteModel{
    packagePath: 'de.dc.javafx.emfsupport.website.model.ui' 
    modelItemProviderAdapterFactory: de.dc.javafx.emfsupport.website.model.provider.ModelItemProviderAdapterFactory
    modelFactory: de.dc.javafx.emfsupport.website.model.ModelFactory
    rootType: de.dc.javafx.emfsupport.website.model.Website
    useUndoRedo: true  
    showCommandStack: true 
    showPropertyView: true 
    generateDemo: true

    contextMenus += addContextMenu(
        id:AddPage 
        parentType: de.dc.javafx.emfsupport.website.model.Website
        createType: de.dc.javafx.emfsupport.website.model.Page 
        modelPackage:de.dc.javafx.emfsupport.website.model.ModelPackage
    )
    contextMenus += addContextMenu(
        id:AddAuthor 
        parentType: de.dc.javafx.emfsupport.website.model.Page
        createType: de.dc.javafx.emfsupport.website.model.Author
        modelPackage:de.dc.javafx.emfsupport.website.model.ModelPackage
    )
} 

Based on the previous example dsl context menu will be added.

  • each context menu required a unique id
  • New items will be created for the parentType, e.g Pages will instanciate for Websites
  • createType is the new instance type, e.g. Page
  • modelPackage is generated by EMF and is required for the creation of new items

Clone this wiki locally