Eclipse 40 and Eclipse e4

2,966 views

Published on

Presentation for Java User Group Saxony

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,966
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Eclipse 40 and Eclipse e4

  1. 1. Eclipse 4.0 Application Platform <br />The unexpected simplicity of Eclipse RCP and Eclipse plugin development<br />26. August for JUG Saxony<br />Lars Vogel<br />http://www.vogella.de <br />Twitter: @vogella<br />
  2. 2. Eclipse 4.0 Application Platform -Agenda <br />What is Eclipse 4.0?<br />Whom does try to help?<br />Building blocks of Eclipse 4.0<br />Q&A<br />
  3. 3. What is an Eclipse RCP application?<br />Local running application using the native widget toolkit<br />Based on the Eclipse runtime and technology<br />
  4. 4. Your first RCP app in < 10 secs<br />
  5. 5. Eclipse e4 Scope<br />Make developmentfor Eclipseeasier<br />
  6. 6. Eclipse e4<br />Eclipse e4 is the incubator project which did produce the Eclipse 4.0 SDK <br />
  7. 7. How does Eclipse e4 help me?<br />
  8. 8. from Eclipse Developer<br />Eclipse E4<br />to Eclipse Developer<br />
  9. 9. So, what’s wrong with plugin and RCP development in Eclipse 3.X?<br />
  10. 10. Eclipse 3.x programming model<br />Complex<br />Lots of API<br />Platform functionality via singletons / static methods<br />Not easy to test<br />Not a consistent way to define the UI<br />
  11. 11. Inheritance in Eclipse 3.X<br />Object<br />EventManager<br />WorkbenchPart<br />ViewPart<br />View<br />
  12. 12. The smallest Eclipse RCP app in Eclipse 3.X<br />Already looks like the Eclipse IDE<br />Lots of boilerplate code <br />
  13. 13. If only Eclipse development would be easier, more visual appealing and easier to test.<br />13<br />
  14. 14. The first amazing change <br />Eclipse e4 uses Java 1.5 language features!<br />AAbout time I would say….<br />
  15. 15. Eclipse e4 – Building blocks<br />Modeled Workbench<br />Rendering Engine<br />Declarative Styling<br />Dependecy Injection<br />Context<br />Core Services<br />
  16. 16. The Modeled Workbench<br />
  17. 17. The e4 Workbench Model<br />e4 Workbench Model<br />EMF inside<br />
  18. 18. The e4 Workbench Model<br />Workbench window <br />Menu with menu items <br />Window Trim, e.g. toolbar with toolbar items <br />Parts Sash Container<br />Parts<br />Part Stack (CTabFolder)<br />Parts<br />Handlers<br />Key Bindings<br />Commands<br />
  19. 19. Model is Flexible<br />No distinction between View and Editor<br />Perspectives are optional<br />Stack / Sash are optional<br />Several windows possible<br />Flexible Toolbars <br />
  20. 20. Model removes the need for boilerplate code<br />Minimal Eclipse e4 app: zero classes<br />
  21. 21. Model URI’s<br />The Part in the Model<br />The Part’s URI<br />
  22. 22. Lessions learned from Java Web deelopment<br />The POJO* has won!<br />* Plain Old Java Objects<br />
  23. 23. Model Elements in e4<br />POJO‘s<br />
  24. 24. Usage of annotations<br />Annotations are used<br />To indicate which methods are called<br />
  25. 25. Model available at runtime<br />
  26. 26. Change the model at runtime<br />
  27. 27. Limits of the e4 application model<br />Only models the Application (frame)<br />Modeled Workbench<br />Content of the individual Parts not included in the model<br />
  28. 28. How is this model translated into UI components?<br />© Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de) <br />
  29. 29. Model and UI Renderers<br />Model<br />I don’t care who draws me<br />The Workbench model is independent of a specific UI toolkit<br />
  30. 30. Renderers<br />Widget Renderer<br />Renderer Factory<br />Returns for every model element <br />Standard SWT renderer can be exchanged<br />
  31. 31. Renderer: flexible but complex<br />
  32. 32. e4 CSS Styling<br />
  33. 33. In reality all RCP apps look like the an IDE <br />
  34. 34. Eclipse3.X - IDE feeling<br />Eclipse e4 – CSS Styling<br />Limitations for:<br /><ul><li> Menu bar background
  35. 35. Table headers </li></ul>e4 supports theme switching during runtime<br />
  36. 36. How to enable CSS Styling<br />Extension point "org.eclipse.e4.ui.css.swt.theme“ defines the style sheet<br /><extension<br /> point="org.eclipse.e4.ui.css.swt.theme"><br /> <theme<br />basestylesheeturi="css/styles.css"<br /> id="org.eclipse.e4.minimal.theme.standard"<br /> label=“Standard"><br /> </theme><br /></extension><br />
  37. 37. How to enable CSS Styling<br />Property "cssTheme” for extension point "org.eclipse.core.runtime.products" selects the initial theme<br /> <extension<br /> id="product"<br /> point="org.eclipse.core.runtime.products"><br /> <product<br /> application="org.eclipse.e4.ui.workbench.swt.E4Application"<br /> name="E4 Contacs Demo"><br /> ....<br /> <property<br /> name="cssTheme"<br /> value="org.eclipse.e4.demo.contacts.themes.darkgradient"><br /> </property><br /> .... <br />
  38. 38. Example CSS<br />Label {<br /> font: Verdana 8px;<br /> color: rgb(240, 240, 240);<br />}<br />Table {<br /> background-color: gradient radial #575757 #101010 100%;<br /> color: rgb(240, 240, 240);<br /> font: Verdana 8px;<br />}<br />ToolBar {<br /> background-color: #777777 #373737 #202020 50% 50%;<br /> color: white;<br /> font: Verdana 8px;<br />}<br />
  39. 39. Java<br />Label label = <br />new Label(parent, SWT.NONE);<br />label.setData("org.eclipse.e4.ui.css.id", <br />"SeparatorLabel");<br />CSS<br />#SeparatorLabel {<br /> color: #f08d00;<br />}<br />Assign custom attributes<br />
  40. 40. The e4 Programming Model<br />
  41. 41. Dependency Injection<br />Inversion of control: The necessary functionality is injected into the class<br />Java Class<br />
  42. 42. Dependency Injection in e4<br />JSR 330 compatible injection implementation<br />@javax.inject.Inject – Field, Constructor and Method injection<br />@javax.inject.Named – Specify a custom qualifier to context object (default is fully qualified classname of the injected type)<br />e4 specific annotations, e.g. @Optional <br />
  43. 43. Java Class<br /> Services are injected via the the e4 framework<br />publicclassListView {<br /> @Inject<br /> privateIEclipseContextcontext;<br />@Inject<br /> private Loggerlogger;<br /> @Inject<br /> publicListView(Composite parent) {<br />// ...<br />
  44. 44. Java Class<br />Model elements participate automatically in DI<br />AddOn as non visual model elements<br />Inject your own object is as simple as<br />ContextInjectionFactory.make(YourObject.class, context);<br />
  45. 45. Lifecycle for Parts<br /><ul><li>@PostConstruct: Called after Object created and Fields- and Methods-Injection finished
  46. 46. @PreDestroy: Called before the object is destroyed (e.g. the Part shown in the UI is removed)</li></li></ul><li>Lifecycle for Application<br /><ul><li>Registered at startup</li></li></ul><li>What can be injected?<br />
  47. 47. IEclipseContext<br />Stores information of possible Injection Values<br />OSGi Services part of the Context<br />Define your own services and use DI for them<br />
  48. 48. Example: Writing Handlers<br />Method identified via @Execute annotation<br />Can have any number of arguments<br />Use IServiceConstants for general context informations<br />public class AboutHandler {<br />@Execute<br /> public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){<br />MessageDialog.openInformation(<br /> shell, "About", "e4 Application example.");<br /> }<br />}<br />
  49. 49. Eclipse Application Services (“Twenty Things”)<br /><ul><li>Long-running operations
  50. 50. Progress reporting
  51. 51. Error handling
  52. 52. Navigation model
  53. 53. Resource management
  54. 54. Status line
  55. 55. Drag and drop
  56. 56. Undo/Redo
  57. 57. Accessing preferences
  58. 58. Preferences
  59. 59. Editor lifecycle
  60. 60. Receiving input
  61. 61. Producing selection
  62. 62. Standard dialogs
  63. 63. Persisting UI state
  64. 64. Logging
  65. 65. Interface to help system
  66. 66. Menu contributions
  67. 67. Authentication
  68. 68. Authorization
  69. 69. Don‘t forget: OSGi services are also available via dependency injection</li></li></ul><li>Contributions<br />
  70. 70. Contributions<br />Extension point “org.eclipse.e4.workbench.model”<br />Fragments – XMI snippets<br />Processor - Code<br />
  71. 71. Context Communication<br />Change the context<br />context.modify("selection", selection.getFirstElement());<br />Get Notified<br />@Inject<br />public voidsetPerson(@Named("selection") @Optional Person person) {<br />master.setValue(person);<br />}<br />
  72. 72. Eclipse e4 – There is more<br />XWT<br />Open Social Gadgets<br />Toolkit Model <br />JDT ???<br />
  73. 73. Summary<br />
  74. 74. Eclipse: Where to go from here:<br />Eclipse 4.0 SDK Tutorial<br />http://www.vogella.de/articles/EclipseE4/article.html<br />Tom Schindl’s Eclipse 4.0 SDK Tutorial<br />http://tomsondev.bestsolution.at/2010/07/28/eclipse-4-0-and-tutorial-on-writing-e4-rcp-application-released/<br />Eclipse Wiki<br />http://wiki.eclipse.org/<br />Eclipse RCP Tutorial<br />http://www.vogella.de/articles/RichClientPlatform/article.html<br />
  75. 75.
  76. 76. Thank you<br />For further questions:<br />Lars.Vogel@gmail.com<br />http://www.vogella.de<br />http://www.twitter.com/vogella<br />
  77. 77. Photo credits<br />All pictures are from http://www.sxc.hu/ to get them add the number to http://www.sxc.hu/photo/<br />Agenda http://www.sxc.hu/photo/1130028<br />Definition of RCP http://www.sxc.hu/photo/930468 <br />RCP Definition http://www.sxc.hu/photo/930468<br />Stopwatch http://www.sxc.hu/photo/634598<br />Fish in the bowl 839037<br />Guy looking from the right http://www.sxc.hu/photo/423354<br />Next guy 986700<br />Present1140205<br />Thinking guy 324541<br />Programming model / Hurt fingers 906072<br />Chess 958410<br />Praying Girl 646227<br />Funny guy http://www.sxc.hu/photo/1173019<br />Model 33012<br />Box 502457<br />Dancing girl 1187376<br />Excellent 866529<br />Dependencies http://www.sxc.hu/photo/182575<br />Extension http://www.sxc.hu/photo/721092<br />Model available at runtime 765733<br /><ul><li>House 494103
  78. 78. Thinking guy II 130484
  79. 79. Renderer 1211480
  80. 80. Factory 1255482
  81. 81. Painter 976984
  82. 82. Holding hands 607988
  83. 83. Beautiful eyes 933394
  84. 84. Funny Puppet 812138
  85. 85. Gummibärchen 191472
  86. 86. Tools / Programming model 1197009
  87. 87. Dependency injection 510413
  88. 88. Life cycle 1265027
  89. 89. File Drawer 613683
  90. 90. Books 1184809
  91. 91. Party people 1062451
  92. 92. Chart 963825
  93. 93. Wheat 939151
  94. 94. Summary http://www.sxc.hu/photo/1184807
  95. 95. Question http://www.sxc.hu/photo/418215
  96. 96. Reading material http://www.sxc.hu/photo/406547
  97. 97. Thank you http://www.sxc.hu/photo/986313</li></li></ul><li>License & Acknowledgements<br />This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License<br />See http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en_US<br />

×