Post on 10-May-2015
description
Eclipse 4.0and e4
Chris AniszczykPrincipal Software Engineerzx@redhat.comhttp://aniszczyk.orghttp://twitter.com/caniszczyk
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)
Agenda
Why e4?
Eclipse 3.X and e4
e4 workbench model
Styling and Services
Compatibility Layer
Conclusion and Q&A
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
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
Eclipse Competition...
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.)
Eclipse is mature and huge...
8
Eclipse Competition...
Francois Schnell, http://www.flickr.com/photos/frenchy/30217773/
Foundations need to evolve...
Eclipse 4.0 SDKEarly Adopter Release
July 2010
11
12
e4 ExampleApplications
So, what’s wrong with Eclipse 3.X?
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...
8
If only Eclipse application development would be easier...
Eclipse e4 – Building blocks
Declarative Styling
Modeled Workbench
Rendering Engine
Dependency Injection
IEclipseContext
Core Services
The Modeled Workbench
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
The Model is FlexibleNo distinction between View/ Editor
Perspectives are optional
Stack / Sash are optional
Several windows easily possible
Flexible Toolbars
Parts in e4
Plain Old Java Objects (POJO‘s)
Before e4... inheritance ruled...
VIEW
VIEWPART
WORKBENCHPART
EVENTMANAGER
OBJECT
How is this model translated into UI components?
Model and UI Renderers
• The Workbench model is independent of a specific UI toolkit
I don’t care who draws me
Model
RenderersRenderer Factory
Eclipse default is the SWT Renderer
Can be selected at Startup via parameter
RenderersWidget RendererRenderer Factory
Returns for every model element
Widget Renderer• Each UI elements gets a renderer • Renderer manage Lifecycle of the UI-
Element– Creation– Model to widget binding– Rendering– Disposal
e4 and Styling
Styling in Eclipse 3.x
• UI styling via– The Presentation API– Custom Widgets
• Very limited
In reality all RCP apps look like the an IDE
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
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>
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;}
• Java
Label label = new Label(parent, SWT.NONE); label.setData("org.eclipse.e4.ui.css.id", "SeparatorLabel");
• CSS
#SeparatorLabel { color: #f08d00;}
Assign custom attributes
The e4 Programming Model
Dependency Injection• Inversion of control: The necessary
functionality is injected into the class
Java Class
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
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
CODE EXAMPLESrs-photo, http://www.flickr.com/photos/rs-foto/2129343084/sizes/l/
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;
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);
Services
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
Compatibility Layer
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
Eclipse 4.0 SDK
Thanks for listening!For further questions:caniszczyk@gmail.comhttp://aniszczyk.orghttp://twitter.com/caniszczyk
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...
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