6. Problems with the Eclipse 3.x programming model 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
7. If only Eclipse development would be easier and the UI would be more flexible. 7
12. Eclipse Modeling Framework (EMF) is fantastic because: De-facto standard for modeling in Eclipse Proven domain model technology Runtime small (1.5 MB) and highly optimized Tooling available Tap in to the EMF ecosystem (EMF-Compare, CDO, …) If I only had a consistent view and behavior of the Eclipse workbench If I only had a consistent view and behavior of the Eclipse workbench
13. The e4 Workbench Model Model „ UIElements.ecore“ is contained in plugin „org.eclipse.e4.ui.model.workbench“
14. The e4 Workbench Model Each application has it‘s live model 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
15. Model is Flexible No distinction between View and Editor Perspectives are optional Stack / Sash are optional Several windows easily possible Flexible Toolbars
16. Attention: In the context of e4 a View and an Editor are both so called “Parts”. Don’t get confused if I speak about “Parts”. If I only had a consistent view and behavior of the Eclipse workbench If I only had a consistent view and behavior of the Eclipse workbench
17. Defining the model Base Model provided by „Application.e4xmi“ Contributions possible via extension point“org.eclipse.e4.workbench.model” Model can be dynamically changed by User or Code User model changes can be stored User changes Model Components Application.e4xmi Application.e4xmi
18. Limits of the e4 application model Only models the Application (frame) Modeled Workbench Content of the view not part of the e4 model
22. Commands & Handlers Handlers have and id and a command have an URI for the implementing class, e.g.platform:/plugin/...SaveHandler Commands have and id and a name can be inserted in menus and toolbars Menus / Toolbar Use commands or DirectItems
41. Dependency Injection in e4 JSR 330 compatible injection implementation @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, e.g. @Optional
42. Java Class Services are injected via the the e4 framework publicclassListView { @Inject privateIEclipseContextcontext; @Inject private Loggerlogger; @Inject publicListView(Composite parent) { // ...
46. IEclipseContext Stores information of possible Injection Values Hierarchical Datastructure OSGi Services part of the Context Dynamic context information: Possibility to contribute an IContextFunction through DS to construct Objects on the fly
47. Writing Handlers Implement an Execute-Method Can have any number of arguments Use IServiceConstants for general context informations publicclassAboutHandler { public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){ MessageDialog.openInformation( shell, "About", "e4 Application example."); } }
80. Thank you For further questions: Lars.Vogel@gmail.com http://www.vogella.de http://www.twitter.com/vogella
81. e4: Where to go from here: Eclipse e4 Tutorial http://www.vogella.de/articles/EclipseE4/article.html Eclipse e4 Wiki http://wiki.eclipse.org/E4 Eclipse e4 Whitepaper http://www.eclipse.org/e4/resources/e4-whitepaper.php
82. License & Acknowledgements This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License See http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en_US Many slides are based on the work of: Tom Schindl and Kai Tödter Tom Schindl, BestSolution, see http://www.bestsolution.at Kai Tödter, Siemens AG