![Page 1: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/1.jpg)
EclipseCon 2015
Advanced features of the Eclipse 4 API for RCP and IDE development
![Page 2: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/2.jpg)
Lars Vogel
Eclipse Platform UI Co-Lead
e4 Committer
Java Champion
Founder of vogella GmbH which offers Eclipse and Android consulting and training support
Author of several Eclipse and Android books and
vogella.com website with more than 1,5 million visits per month.
Lars Vogel
![Page 3: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/3.jpg)
Part 1- extending the IDE with e4
![Page 4: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/4.jpg)
3/20/15
The Goal
![Page 5: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/5.jpg)
Eclipse application modularity with fragments and processors
![Page 6: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/6.jpg)
Model fragments – xmi snippets contribute to the runtime model (declaratively)
Model processors – Java classes to change the model (programmatically)
![Page 7: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/7.jpg)
Contribute to ID and Feature
ID in your main Application.e4xmi
Feature to contribute too
![Page 8: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/8.jpg)
3/20/15
Prerequisites
Eclipse 4 IDE still uses a lot 3.x plug-ins
BUT
maps the 3.x Elements to E4 Application-Model
Modelspy
![Page 9: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/9.jpg)
3/20/15 ● Use Menu Contributions, Toolbar
Contributions, Trim Contributions to extend the IDE with e4 menus and toolbars
● Works in the IDE and 3.x and 4.x RCP applications
The trick is to use the correct ID and model element
![Page 10: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/10.jpg)
3/20/15
Steps
● Find the Element ID of the parent
● Plugin-Spy / Plugin-Menu-Spy● Model-Spy
● Attach your E4 Elements to this parent via fragment.e4xmi
![Page 11: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/11.jpg)
3/20/15
Exercises....
![Page 12: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/12.jpg)
3/20/15
Samples for the usage of e4 API
● https://github.com/vogellacompany/➢ Saneclipse – Templates and Defaults for Coding➢ Codemodify – JUnit 4 migration tool➢ PreferenceSpy – See changed preferences in a
Table➢ ...
● ….
![Page 13: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/13.jpg)
Planned enhancement: Contribute via X-Path
● Bug 324954 - [Model] Allow model fragments to use XPath-Syntax to decide where to contribute
● https://bugs.eclipse.org/324954
![Page 15: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/15.jpg)
Event service
Software Component
Event provider does not know anything about the receivers
Provider
Part activated
Label changed
Children saved
more events...
@Injectprivate IEventBroker broker;
![Page 16: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/16.jpg)
18
Dependency injection looks in the EclipseContext
Window
Perspective
Part
Part
Application
![Page 17: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/17.jpg)
OSGi
Window
Perspective
Part
Part
Application
IEclipseContext
dynamically queried
Window
Part
Actually DI uses other sources as well, for example the OSGi service registery
![Page 18: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/18.jpg)
Events
@Inject @Optional @EventTopic(“key1”) Type t;
EventBus
![Page 19: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/19.jpg)
Receiving Events (types)
@Inject@Optionalpublic void receive(@EventTopic("key1") Todo o) {
// do something}
@Inject@Optionalpublic void receive(@EventTopic("key1") String o) {
// do something}
![Page 20: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/20.jpg)
Eclipse communication
Events listed in org.eclipse.e4.ui.workbench.UIEvents
The Eclipse platform uses events for its complete user interface communication.
![Page 21: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/21.jpg)
Model add-ons are a way to react to events in the IDE
![Page 22: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/22.jpg)
Part of the application model below application without user
interface
![Page 23: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/23.jpg)
Typically register for events and act upon them
![Page 24: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/24.jpg)
Core IDE functionality controlled by model add-ons
![Page 25: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/25.jpg)
27
Several classes are stored in the IEclipseContext which you can override
Window
Perspective
Part
Part
Application
![Page 26: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/26.jpg)
3/20/15
Demo and exercises.... (different save dialog)
![Page 27: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/27.jpg)
Using e4 API in 3.X components
![Page 28: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/28.jpg)
3.x part accessing 4.x API// get the context of a partIEclipseContext parentContext = (IEclipseContext) site.getService(IEclipseContext.class);// or access directly a value in the context based on its keyEModelService service = (EModelService) site.getService(EModelService.class);
![Page 29: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/29.jpg)
3.x handler accessing 4.x API// get the context of a partIEclipseContext parentContext = (IEclipseContext) site.getService(IEclipseContext.class);// or access directly a value in the context based on its keyEModelService service = (EModelService) site.getService(EModelService.class);
![Page 30: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/30.jpg)
Additional model data
![Page 31: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/31.jpg)
Additional model data
TagsPersisted StateContext PropertiesTransistent data
![Page 32: EclipseCon 2015Lars Vogel Eclipse Platform UI Co-Lead e4 Committer Java Champion Founder of vogella GmbH which offers Eclipse and Android consulting and training support](https://reader030.vdocuments.net/reader030/viewer/2022040515/5e7406ebdd00dc67084ff410/html5/thumbnails/32.jpg)
Usage Renderer can use the information to drive different behavior
Events are send out if this data changes, e.g. if a tag is set on a model element
Model data can be accessed via API, e.g., to configure the parts
Tags can be used as CSS classes.