emf.edit: a story of adapters

Post on 14-Jan-2015

405 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slides from my talk at Eclipse Con North America 2014 (https://www.eclipsecon.org/na2014/session/emfedit-story-adapters) So you need to build a Java application for desktop, mobile or web? You already know that EMF could be helpful in many ways because it handles the burden of writing the data classes (entities) and provides RESTful serialization of those data? Yeah, that is perfectly correct. But how does it help you with changing, or editing, your data? What is the point behind the so-called EMF.Edit framework? During this talk, you will learn how to build the foundations for a rich client application in any widget toolkit (SWT, JavaFX...). Among other things you will learn how to customize the generated EMF editor without messing up with the generated classes. You will learn how the content and label providers are working under the hood to help create your own beautiful, robust and maintainable applications. By the end of this talk you will finally untangle the gordian knot between Adapters, ItemProvider, AdapterFactory, ItemProviderAdapterFactory, AdapterFactoryLabelProvider, AdapterFactoryContentProvider, etc. This talk is dedicated to EMF rookies who know EMF as a generator of JavaBeans on Steroids and want to know more about the steroids themselves (the Adapter framework, the ItemProvider framework and the amazing helper classes around those two). This talk will be full of sample code and demo. All of this material is available on Github https://github.com/mbarbero/econ-na-2014-emf-edit.

TRANSCRIPT

EMF.EditA Story of Adapters

Mikaël BarberoObeo

Eclipse Con North America 2014March 20, 2014

© John W

ilhelm http://500px.com

/photo/59208448

Super Java Beans

© Rangizzz http://500px.com/photo/30648317

On Steroids© Max Ellis http://500px.com/photo/57968110

© Rangizzz http://500px.com/photo/43660830

Today’s Workout Routine

Connecting the Viewer

Changing the Labels

Changing the Content

Connecting the viewers

Exercise 1

Model View

Controller

Listening for Reacting to

CHANGES

notifies

adapts

Notifier Adapter

Listener pattern Notifier is the observable and Adapter is the observer

5

Notification Message from the Observable to the Observer

TreeViewer

Chain of notifications Explains the importance of calling dispose()

Adapter Factory Content

& Label Provider

Item Provider Adapter Factory

Item ProviderEObject

Update or Refresh Or how to be smart when notifying the viewer

TreeViewerAdapter

Factory Content & Label Provider

Item Provider Adapter Factory

Item ProviderEObject

#notifyChanged

Update or Refresh Or how to be smart when notifying the viewer

Provider type Singleton

Book Item

Provider

Book

Book Book

Provider type Stateful

Book Item

ProviderBook

Book

Book

Book Item

Provider

Book Item

Provider

TreeViewer

Composed Adapter Factory Look for the proper adapter factory for each type of object

Item Provider Adapter Factory

Item Provider Adapter Factory

Item Provider Adapter Factory

Adapter Factory Content

& Label Provider

Item Provider Adapter Factory

Item ProviderEObject

Code is Available

https://github.com/mbarbero/econ-na-2014-emf-edit

Tags demo1 and demo2

Changing the Labels

Exercise 2

XXXItemProvider#getText(Object) Easy

src

src-gen

Generation gap pattern Treat generated code as byte code

Item

Book Periodical BookOnTape

Video Cassette

TreeViewerAdapter

Factory Content & Label Provider

Item Provider Adapter Factory

Item ProviderEObject

Decorators of AdapterFactory and ItemProvider

TreeViewer

Decorators of AdapterFactory and ItemProvider

ItemAdapter

Factory Content & Label Provider

Item Provider Adapter Factory

ItemItem ProviderEObject

Code is Available

https://github.com/mbarbero/econ-na-2014-emf-edit

Tag demo3

Changing the Contents

Exercise 3

XXXItemProvider#getChildren(Object) Easy

TreeNode

Tree Model Wrap EObjects

EObjectdata

TreeViewer

Tree Model Wrap EObjects

ItemAdapter

Factory Content & Label Provider

Item Provider Adapter Factory

Item ItemItem ProviderEObject

Beware of too many notifications Make your item providers stateful

EObjectEObject

EObject

Beware of too many notifications Make your item providers stateful

Tree Node

Tree Node

Tree Node

Beware of too many notifications Make your item providers stateful

Tree NodeItem Provider

Tree NodeItem Provider

Tree NodeItem Provider

Beware of too many notifications Make your item providers stateful

EObject ItemProvider

Beware of too many notifications Make your item providers stateful

EObject ItemProvider

Beware of too many notifications Make your item providers stateful

Code is Available

https://github.com/mbarbero/econ-na-2014-emf-edit

Tag demo4

Connecting the Viewer

Changing the Labels

Changing the Content

Recap

Q & A

Mikaël Barbero mikael.barbero@obeo.fr +Mikaël Barbero @mikbarbero

Obeo http://www.obeo.fr

top related