Eclipse 40 - Eclipse Summit Europe 2010

1,917 views

Published on

Overview of Eclipse e4 on the EclipseSummit Europe 2010.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,917
On SlideShare
0
From Embeds
0
Number of Embeds
55
Actions
Shares
0
Downloads
51
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Eclipse 40 - Eclipse Summit Europe 2010

  1. 1. Anatomy of an e4 Application The unexpected Simplicity of RCP 4.x based Applications Lars Vogel http://www.vogella.de Twitter: @vogella Kai Tödter Siemens Corporate Technology Twitter: @kaitoedter
  2. 2. About Lars Works for SAP as product manager Privately active in the Open Source Community Eclipse committer, received the Eclipse Top Contributor community award 2010 Webmaster of http://www.vogella.de with more then 15 000 visitors per day Lars Vogel http://www.vogella.de Twitter: @vogella
  3. 3. About Kai • Software Architect/Engineer at Siemens Corporate Technology • Eclipse RCP expert and OSGi enthusiast • Open Source advocate • Committer at e4 and Platform UI • E-mail: kai.toedter@siemens.com • Twitter: twitter.com/kaitoedter • Blog: toedter.com/blog
  4. 4. Anatomy of an e4 Application - Agenda
  5. 5. Eclipse e4 Scope Make development for Eclipse easier
  6. 6. Eclipse e4 Eclipse e4 is the incubator project which did produce the Eclipse 4.0 SDK
  7. 7. Eclipse 4.0 SDK Early adapter release!!! No frozen API‟s
  8. 8. Eclipse RCP 4.x Architecture Operating System Java Virtual Machine Runtime (Equinox, OSGi) Workbench Model, Rendering Engine, CSS Styling, Dependency Injection, Services 4.0 Workbench PDE EMF Core UI Core (JFace, SWT) JDT Additional Platform Bundles 3.x Compatibility Layer 8
  9. 9. How does Eclipse e4 help me?
  10. 10. from Eclipse Developer to Eclipse Developer Eclipse E4
  11. 11. So, what’s wrong with plugin and RCP development in Eclipse 3.X?
  12. 12. Eclipse 3.x programming model • Complex • Lots of API • Platform functionality via singletons / static methods • Not easy to test • Not a consistent way to define the UI
  13. 13. The smallest Eclipse RCP app in Eclipse 3.X Already looks like the Eclipse IDE Lots of boilerplate code
  14. 14. 15 If only Eclipse development would be easier, more visual appealing and easier to test.
  15. 15. The first amazing change Eclipse e4 uses Java 5 language features! AAbout time I would say….
  16. 16. Eclipse e4 – Building blocks Declarative Styling Modeled Workbench Rendering Engine Dependency Injection Context Core Services
  17. 17. The Modeled Workbench
  18. 18. The e4 Workbench Model
  19. 19. The e4 Workbench 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
  20. 20. Model is Flexible No distinction between View and Editor Perspectives are optional Stack / Sash are optional Several windows possible Flexible Toolbars
  21. 21. Model removes the need for boilerplate code Minimal Eclipse e4 app: zero classes
  22. 22. Model URI’s The Part in the Model The Part’s URI
  23. 23. POJO„s
  24. 24. Annotations are used To indicate which methods are called
  25. 25. Model available at runtime
  26. 26. • Only models the Application (frame) Limits of the e4 application model Modeled Workbench Content of the individual Parts not included in the model
  27. 27. The e4 Programming Model
  28. 28. It‘s like OSGi made easys
  29. 29. • Inversion of control: The necessary functionality is injected into the class
  30. 30. • by the e4 DI container DI Container rules them all
  31. 31. • JSR 330 compatible injection implementation – @javax.inject.Inject – Field, Constructor and Method – @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
  32. 32. public class ListView { @Inject private IEclipseContext context; @Inject private Logger logger; @Inject public ListView(Composite parent) { // ... Dependencies are injected via the the e4 framework
  33. 33. DI and model Elements
  34. 34. AddOns (Model Elements) Model Elements without UI„s Usually register to model changes
  35. 35. What about non-model elements? Non-Model Element Can he also join the DI game?
  36. 36. ContextInjectionFactory. make(your.class,context)
  37. 37. 1056766 There is more... then DI
  38. 38. Annotations for Handlers • @Execute: • @CanExecute • Handlers can be POJO‟s too
  39. 39. Lifecycle for Parts • Parts • @PostConstruct: Called after Object created and Fields- and Methods-Injection finished • @PreDestroy: Called before the object is destroyed (e.g. the Part shown in the UI is removed)
  40. 40. Lifecycle for Application • Class registered at startup • @PostContextCreate • @ProcessAdditions • @ProcessRemovals @Presave
  41. 41. – Stores information of possible Injection Values – OSGi Services part of the Context – Define your own services and use DI for them – Put your own stuff into the context
  42. 42. • Method identified via @Execute annotation – Can have any number of arguments – Use IServiceConstants for general context informations public class AboutHandler { @Execute public void execute( @Named(IServiceConstants.ACTIVE_SHELL) Shell shell){ MessageDialog.openInformation( shell, "About", "e4 Application example."); } }
  43. 43. Context Communication Change the context context.modify("selection", selection.getFirstElement()); Get Notified @Inject public void setPerson( @Named("selection") @Optional Person person) { master.setValue(person); }
  44. 44. e4 Services (aka “The 20 Things”) e4 services: • Core • User Interface • Advanced • Domain-Specific Most of these services are injected using DI, see also: http://wiki.eclipse.org/E4/Eclipse_Application_Services
  45. 45. 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  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
  46. 46. Contributions
  47. 47. Contributions The Workbench Model is dynamic - Other bundles can make contributions Contributors need to know the id of the element they want to contribute to
  48. 48. Contributions Extension point “org.eclipse.e4.workbench.model” There are two kind of contributions Static fragments – XMI snippets Dynamic processors - Processor - Code
  49. 49. e4 CSS Styling
  50. 50. In reality all RCP apps look like the IDE
  51. 51. Eclipse 3.X - IDE feeling Eclipse e4 – CSS Styling Limitations for: • Menu bar background • Table headers e4 supports theme switching during runtime
  52. 52. How to enable CSS Styling Extension point "org.eclipse.e4.ui.css.swt.theme“ defines the style sheet <extension point="org.eclipse.e4.ui.css.swt.theme"> <theme basestylesheeturi="css/styles.css" id="org.eclipse.e4.minimal.theme.standard" label=“Standard"> </theme> </extension>
  53. 53. How to enable CSS Styling Property "cssTheme” for extension point "org.eclipse.core.runtime.products" selects the initial theme <extension id="product" point="org.eclipse.core.runtime.products"> <product application="org.eclipse.e4.ui.workbench.swt.E4Application" name="E4 Contacs Demo"> .... <property name="cssTheme" value="org.eclipse.e4.demo.contacts.themes.darkgradient"> </property> ....
  54. 54. Example CSS Label { 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; }
  55. 55. © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de) How is the model translated into UI components?
  56. 56. Model and UI Renderers • The Workbench model is independent of a specific UI toolkit I don’t care who draws me Model
  57. 57. Renderers Widget RendererRenderer Factory Returns for every model element Standard SWT renderer can be exchanged
  58. 58. Renderer: flexible but complex
  59. 59. Eclipse e4 – There is more XWT Open Social Gadgets JDT ???
  60. 60. Summary Eclipse 4.0 is fantastic
  61. 61. e4: Where to go from here: Eclipse e4 Wiki http://wiki.eclipse.org/E4 Eclipse 4.0 Application Tutorial – Lars Vogel http://www.vogella.de/articles/EclipseE4/article.html Eclipse 4.0 Application Tutorial – Tom Schindl http://tomsondev.bestsolution.at/2010/07/28/eclipse-4-0-and-tutorial-on-writing-e4- rcp-application-released/
  62. 62. Thank you For further questions: Lars.Vogel@gmail.com kai.toedter@siemens.com http://www.vogella.de http://twitter.com/kaitoedter http://www.twitter.com/vogella
  63. 63. Photo credits • Open Door http://www.sxc.hu/photo/1228296 • Guy http://www.sxc.hu/photo/423354 • Corn http://www.sxc.hu/photo/939151 • About time guy http://www.sxc.hu/photo/1173019 • Thinking man http://www.sxc.hu/photo/ 324541 • Cool but hurts http://www.sxc.hu/photo/ 906072 • WWW http://www.sxc.hu/photo/987822 • Present http://www.sxc.hu/photo/1140205 • Happy figure http://www.sxc.hu/photo/125901 • Chess http://www.sxc.hu/photo/ 958410 • Pill box http://www.sxc.hu/photo/ 510413 • Syringe / Injection: http://www.sxc.hu/photo/ 468493 • Smiley http://www.sxc.hu/photo/ 1211480 • Lock http://www.sxc.hu/photo/ 352344 • Life Cycle http://www.sxc.hu/photo/1265027 • Powerful but complex http://www.sxc.hu/photo/607988 • Baby photo not yet published • Excellent http://www.sxc.hu/photo/866529 • Thank you picture http://www.sxc.hu/photo/ 986313 • Runtime model http://www.sxc.hu/photo/ 765733 • Adding numbers http://www.sxc.hu/photo/ 1117095 • Renderer http://www.sxc.hu/photo/976984 • Binder: http://www.sxc.hu/photo/443042 • Praying Girl http://www.sxc.hu/photo/646227 • Box: http://www.sxc.hu/photo/502457 • Screws http://www.sxc.hu/photo/1148064 • House with compartments http://www.sxc.hu/photo/494103 • Smiling Face 884146 • Ballons 1056766 • Bucket 807354 • Boy at beach 1139530 • Stacked stones http://www.sxc.hu/photo/998524 • Thinking Guy http://www.sxc.hu/photo/130484 • Drawing Hand http://www.sxc.hu/photo/264208 • Waiter http://www.sxc.hu/photo/157966 • Dancing Girt http://www.sxc.hu/photo/1187376 • Books http://www.sxc.hu/photo/1184809

×