eclipse e4

51
Eclipse 4.0 and e4 Chris Aniszczyk Principal Software Engineer [email protected] http://aniszczyk.org http://twitter.com/caniszczyk

Upload: chris-aniszczyk

Post on 10-May-2015

10.514 views

Category:

Technology


0 download

DESCRIPTION

A presentation I gave at the AustinJUG.

TRANSCRIPT

Page 1: Eclipse e4

Eclipse 4.0and e4

Chris AniszczykPrincipal Software [email protected]://aniszczyk.orghttp://twitter.com/caniszczyk

Page 2: Eclipse e4

Howdy!• Hack Eclipse/OSGi/Git• Evangelist at Red Hat• Involved heavily at Eclipse

– Eclipse Foundation Board of Directors– Co-lead PDE and EGit

• Hacking on open source for a decade– Gentoo Linux, Eclipse, Fedora...

• I like running (5K @ ~18min)

Page 3: Eclipse e4

Agenda

Why e4?

Eclipse 3.X and e4

e4 workbench model

Styling and Services

Compatibility Layer

Conclusion and Q&A

Page 4: Eclipse e4

Lexicone4 is an Eclipse.org project for platform-related incubation, it’s not a product!

Eclipse 4.0 is a release that contains some technology from the e4 project

Page 5: Eclipse e4

Why e4?• Innovate or become irrelevant• Use e4 technologies as a

basis for Eclipse 4.X (some will show up in the 3.x stream)

• Engage the open source community

• Build a better Eclipse– Make it more flexible– Prepare for the web– Dynamic languages– Fix our mistakes

Page 6: Eclipse e4

Eclipse Competition...

Page 7: Eclipse e4

Why change?

“We’ve already built all our plug-ins.

The most important thing is don’t break us.”

(Yes, there is a compatibility layer.)

Page 8: Eclipse e4

Eclipse is mature and huge...

8

Page 9: Eclipse e4

Eclipse Competition...

Francois Schnell, http://www.flickr.com/photos/frenchy/30217773/

Foundations need to evolve...

Page 10: Eclipse e4

Eclipse 4.0 SDKEarly Adopter Release

July 2010

Page 11: Eclipse e4

11

Page 12: Eclipse e4

12

Page 13: Eclipse e4

e4 ExampleApplications

Page 14: Eclipse e4
Page 15: Eclipse e4
Page 16: Eclipse e4

So, what’s wrong with Eclipse 3.X?

Page 17: Eclipse e4

Problems with Eclipse 3.x

• Complex• Lots of API• Platform functionality

via singletons• Not easy to test• Not a consistent way to

define the UI• UI makes assumptions,

e.g. Editors / Views• Easy Skinning

• The browser is more powerful now... RIAs...

Page 18: Eclipse e4

8

If only Eclipse application development would be easier...

Page 19: Eclipse e4

Eclipse e4 – Building blocks

Declarative Styling

Modeled Workbench

Rendering Engine

Dependency Injection

IEclipseContext

Core Services

Page 20: Eclipse e4

The Modeled Workbench

Page 21: Eclipse e4

The e4 Workbench ModelEach application has its live model... think of the browser DOM...

• Built using EMF• Workbench window

– Menu with menu items – Window Trim, e.g.

toolbar with toolbar items

– Parts Sash Container• Parts

– Part Stack (CTabFolder)• Parts

– Handlers– Key Bindings– Commands

Page 22: Eclipse e4

The Model is FlexibleNo distinction between View/ Editor

Perspectives are optional

Stack / Sash are optional

Several windows easily possible

Flexible Toolbars

Page 23: Eclipse e4

Parts in e4

Plain Old Java Objects (POJO‘s)

Page 24: Eclipse e4

Before e4... inheritance ruled...

VIEW

VIEWPART

WORKBENCHPART

EVENTMANAGER

OBJECT

Page 25: Eclipse e4

How is this model translated into UI components?

Page 26: Eclipse e4

Model and UI Renderers

• The Workbench model is independent of a specific UI toolkit

I don’t care who draws me

Model

Page 27: Eclipse e4

RenderersRenderer Factory

Eclipse default is the SWT Renderer

Can be selected at Startup via parameter

Page 28: Eclipse e4

RenderersWidget RendererRenderer Factory

Returns for every model element

Page 29: Eclipse e4

Widget Renderer• Each UI elements gets a renderer • Renderer manage Lifecycle of the UI-

Element– Creation– Model to widget binding– Rendering– Disposal

Page 30: Eclipse e4

e4 and Styling

Page 31: Eclipse e4

Styling in Eclipse 3.x

• UI styling via– The Presentation API– Custom Widgets

• Very limited

Page 32: Eclipse e4

In reality all RCP apps look like the an IDE

Page 33: Eclipse e4

Eclipse 3.X - IDE feeling

Eclipse e4 – CSS Styling

Example from Kai Toedter

Some elements cannot currently not be styled:

• Menu bar background• Table headers

e4 supports theme switching during runtime

Page 34: Eclipse e4

How to enable CSS StylingProperty "applicationCSS” in extension point org.eclipse.core.runtime.products

<extension id="product" point="org.eclipse.core.runtime.products"> <product application="org.eclipse.e4.ui.workbench.swt.application" name="E4 Contacs Demo"> <property name="applicationCSS" value="platform:/plugin/contacts/css/dark.css"> </property> </product></extension>

Page 35: Eclipse e4

Example CSSLabel { font: Verdana 8px; color: rgb(240, 240, 240);}

Table { background-color: gradient radial #575757 #101010 100%; color: rgb(240, 240, 240); font: Verdana 8px;}

ToolBar { background-color: #777777 #373737 #202020 50% 50%; color: white; font: Verdana 8px;}

Page 36: Eclipse e4

• Java

Label label = new Label(parent, SWT.NONE); label.setData("org.eclipse.e4.ui.css.id", "SeparatorLabel");

• CSS

#SeparatorLabel { color: #f08d00;}

Assign custom attributes

Page 37: Eclipse e4

The e4 Programming Model

Page 38: Eclipse e4

Dependency Injection• Inversion of control: The necessary

functionality is injected into the class

Java Class

Page 39: Eclipse e4

Dependency Injection in e4

• JSR 330 compatible injection implementation (think Google Guice)– @javax.inject.Inject – Field,

Constructor and Method injection– @javax.inject.Named – Specify a custom

qualifier to context object (default is fully qualified classname of the injected type)

• e4 specific annotations... @Optional

Page 40: Eclipse e4

public class ListView {

@Inject private IEclipseContext context; @Inject private Logger logger;

@Inject public ListView(Composite parent) { // ...

Services are injected via the the e4 framework

Java Class

Page 41: Eclipse e4

CODE EXAMPLESrs-photo, http://www.flickr.com/photos/rs-foto/2129343084/sizes/l/

Page 42: Eclipse e4

4.x

3.x

Access preference values

IPreferenceStore store = IDEWorkbenchPlugin.getDefault() .getPreferenceStore();

boolean saveBeforeBuild = store .getBoolean(SAVE_BEFORE_BUILD);

@Inject@Preference(SAVE_BEFORE_BUILD)boolean saveBeforeBuild;

Page 43: Eclipse e4

4.x

3.x

Associate help context with control

getSite() .getWorkbenchWindow() .getWorkbench() .getHelpSystem().setHelp( viewer.getControl(), some_id);

@Inject

IWorkbenchHelpSystem helpSystem;

...

helpSystem.setHelp( viewer.getControl(), some_id);

Page 44: Eclipse e4

Services

Page 45: Eclipse e4

Eclipse Application Services (“Twenty Things”)

Long-running operations

Progress reporting Error handling Navigation model Resource management Status line Drag and drop Undo/Redo Accessing preferences

Editor lifecycle Receiving input Producing selection Standard dialogs Persisting UI state Logging Interface to help

system Menu contributions Authentication Authorization

Don‘t forget: OSGi services are also available via dependency injection

Page 46: Eclipse e4

Compatibility Layer

Page 47: Eclipse e4

Compatibility Layer

• Compatibility layer centers around org.eclipse.ui.workbench– Contains code to host 3.x API on e4

• Note: The 3.x workbench API with some exceptions...– org.eclipse.ui.presentations– org.eclipse.ui.themes– Activities and Capabilities

• API clean plug-ins will run fine

Page 48: Eclipse e4

Eclipse 4.0 SDK

Page 50: Eclipse e4

Where to go from hereEclipse e4 Website

http://www.eclipse.org/e4

Eclipse e4 Wikihttp://wiki.eclipse.org/E4

Eclipse e4 Whitepaper http://www.eclipse.org/e4/resources/e4-whitepaper.php

Eclipse 4.1 will most likely shipas part of the Indigo release...

Page 51: Eclipse e4

License & Acknowledgements• This work is licensed under:

– http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en_US

• Thank you...– Boris Bokowski, IBM– Tom Schindl, BestSolution– Kai Tödter, Siemens AG– Lars Vogel, SAP AG