EMF-Edit-Support is coming to JavaFX via e(fx)clipse

One of the brand new runtime features we will provide with the next release of e(fx)clipse is EMF-Edit-Support for JavaFX so that people who use EMF as their domain technology don’t have to write code by hand when they want to set up List, Tables and Trees in a JavaFX application.

An important side note in is that it is not BestSolution.at who has developed this feature but it has been contributed and is maintained by one of our early adopters (TESIS DYNAware).

As a start let’s take a look how you can set up a ListView:

EditingDomain editingDomain = ....;
AdapterFactory adapterFactory = ....;
Group rootNode = ....;

ListView<Object> listView = new ListView<>();
listView.setItems(new AdapterFactoryObservableList<Object>(adapterFactory, rootNode));

AdapterFactoryListCellFactory listCellFactory;
listCellFactory = new AdapterFactoryListCellFactory(adapterFactory);

Nice isn’t it? Let’s take a look at a more complex control:

Group rootNode = ....;
EditingDomain editingDomain = ....;
AdapterFactory adapterFactory = ....;

TreeView<Object> treeView = new TreeView<>();
treeView.setRoot(new AdapterFactoryTreeItem(rootNode, adapterFactory));
AdapterFactoryTreeCellFactory cellFact;
cellFact = new AdapterFactoryTreeCellFactory(adapterFactory);


Let’s add some DND support

cellFact.addCellCreationListener(new CellDragAdapter());
cellFact.addCellCreationListener(new EditingDomainCellDropAdapter(editingDomain));

And finally a nice little table:

Group rootNode = ....;
EditingDomain editingDomain = ....;
AdapterFactory adapterFactory = ....;

TableView<Object> tableView = new TableView<>();

TableColumn<Object, Object> firstNameColumn = new TableColumn<>("First Name");
firstNameColumn.setCellValueFactory(new ProxyCellValueFactory<Object, Object>());

AdapterFactoryTableCellFactory<Object, Object> firstNameCellFactory = 
   new AdapterFactoryTableCellFactory<>(adapterFactory, 0);

Now add some inline editing support:

firstNameCellFactory.addCellEditHandler(new EAttributeCellEditHandler(

That’s it for structured controls like List, Table and Tree but often you also need to bind an EMF-Feature e.g. to a TextField and this can be done like this:

Contact contact = ...;
EditingDomain editingDomain = ....;
EStructuralFeature feature = ContactsPackage.eINSTANCE.getContact_FirstName();

Property<String> property = EMFEditFXProperties.value(editingDomain, contact, feature);

If you want to see this in action I’ve recorded a small video for you.

You noticed that we have full undo/redo support available but for those of you who have used EMF-Edit that is not a suprise. As always you can find the sample code in our github repo.

This entry was posted in e(fx)clipse. Bookmark the permalink.

10 Responses to EMF-Edit-Support is coming to JavaFX via e(fx)clipse

  1. jankoehnlein says:

    Cool. Took me a while to understand why you’re doing all this stuff, unitl I tried JavaFX myself. EMFEdit finally gets the usability it deserves with your JavaFX approach (as opposed to SWT, RAP or GWT). Carry on the excellent work!

  2. Rober says:

    I can’t wait for the next release of e(fx)clipse. I’m working with EMF, and get JavaFX compatibility can be fantastic. Good work Tom!

  3. Pingback: e(fx)clipse 0.8.0 released | Tomsondev Blog

  4. Mauro Condarelli says:

    Hi Tom,
    thanks a lot for the good work!
    I am struggling because I need (not my choice) to integrate an EMF model in a standalone JavaFX application (NO e4, RCP, …, just a plain “public class Main extends Application”).
    Possibly using databinding.
    Is this possible at all?
    What is the minimal set of .jar necessary?
    Is there any example/documentation/tutorial available?
    I’m currently very perplexed about how to write the AdapterFactory apparently needed.
    Any pointer welcome.

  5. Pingback: GUI Generation with JavaFX | Uwe's Blog

  6. Tom, the github repo you mention does not seem to exist anymore… can I find the example somewhere else?

  7. Julian Skorka says:

    I know this was posted at December 13, 2012. So I found that code is changed but I could figure it out for EMF-Feature. But I’m struggle by ListView. So where I can find any update?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.