SlideShare una empresa de Scribd logo
1 de 75
Eclipse e4 Tutorial © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. Tom Schindl – BestSolution.at Lars Vogel – http://www.vogella.de Kai Tödter – Siemens AG
Outline Theory The e4 Programming Model – Tom Schindl The Workbench Model – Lars Vogel Styling in e4 – Kai Tödter Labs Programming Model (looking a bit behind e4 Dependency Injection) Create an RCP-Application from scratch Work with CSS to retheme the Contacts Demo © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 2
Installation USB-Sticks with Eclipse-SDK Only copy the version you need for your OS located at SDK-Folder Slides as PDFs located in slides-Folder Examples code located in samples-Folder Solutions code located in solutions-Folder © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 3
E4 and Example Installation Copy the e4 zip file on your laptop and unzip it. Start e4 with eclipse.exe Use File -> Import -> „Existing Projects into Workspace“ to import the projects from directory „samples“. „Select archive file“ -> *.zip 4 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
e4 The Programming Model Tom Schindl BestSolution.at © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
Outline POJO as the Programming Model Dependency Injection JSR 330 Annotations e4 specific Annotations The IEclipseContext Handlers Lab Tasks © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 6
POJO as the ProgrammingModel All building blocks of e4 are POJO  © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 7
2 Main Object-Types Part UI Component representing an Editor, Table, Tree, … Most likely has a constructor which accepts a Composite Handler Reacts on Commands execute by the user through Button press, KeyBinding, … Has to have a method named execute() with a variable number of Parameters © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 8
Dependency Injection What is DI Inversion of control: Your application doesn’t reach out stuff but gets it provided/injected from the outside framework e4 provides an JSR 330 compatible injection implementation @Inject – Field, Constructor and Method injection @Named – Specify a custom qualifier to context object (default is fully qualified classname of the injected type) © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 9
Dependency Injection Example of an e4-Part publicclassMyPart { @Inject privateECommandServicecmdService; @Inject public SampleView(Composite parent) {   } @Inject private voidsetSelection(@Optional @Named( IServiceConstants.SELECTION) Contactcontact) { // Handle changedselection   } private voidexecCommand() { // Execute command   } } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 10
Dependency Injection e4 specific Annotations @Optional: Marking the parameter as optional @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) © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 11
Dependency Injection Example Usage of e4 PostConstruct /PreDestroy Annotations publicclassMyPart { @Inject privateITimerServicetimerService; @PostConstruct private voidinit() { if(timerService!= null) { // Do something     }   }   @PreDestroy private voiduninit() { if(timerService != null) { // Do something     }   } } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 12
Dependency Injection IEclipseContext Stores information of possible Injection Values Hierarchical Datastructure Rootcontext backed up by OSGi-Service Registry (every registered as an OSGi-Service can get injected) Dynamic context information: Possibility to contribute an IContextFunction through DS to construct Objects on the fly © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 13
Using Eclipse DI Eclipse DI can consumed standalone in OSGi-Applications publicObjectstart() { // GetBundle Information Bundlebundle = FrameworkUtil.getBundle(getClass()); BundleContextbundleContext = bundle.getBundleContext(); IEclipseContexteclipseCtx =    EclipseContextFactory.getServiceContext(bundleContext); // FillContextwithinformationusingset(String,Object)   // … // Create instanceofclass ContextInjectionFactory.make(MyPart.class, eclipseCtx); } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 14
Writing Handlers Implement an Execute-Method Can have any number of arguments Use IServiceConstantsforgeneralcontextinformations publicclassAboutHandler {   public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){ MessageDialog.openInformation(       shell, "About", "e4 Application example.");   } } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 15
LabTask 1 – Part 1 Create a Headless RCP-Application Add asdependency org.eclipse.e4.core.services javax.inject org.eclipse.swt org.eclipse.jface Create a classMyPartwith a TableViewer Constructoraccepts an SWT-Composite 16 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
LabTask 2 Import org.eclipse.tutorial.pgm.service Injectorg.eclipse.tutorial.pgm.service.ITimeService Register Listener in postconstructionphaseand update viewerwithInformations UnregisterListener in predestroy 17 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
LabTask 3 UseMethod-Injection Add methodset-methodwhichinjects an Objectof type String knownunderthe FQN „org.eclipsecon.myObject“ (hintusethe@Named and @Optional ) Start a threadbeforelaunchingtheeventloopandset a newvalue in theIEclipseContextfor „org.eclipsecon.myObject“  18 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
Eclipse e4:Eclipse, the modeled Workbench and 20 other things Lars Vogel
Mini-Agenda  The existing Eclipse 3.x UI model e4 workbench model Model to UI -> Renderer „The 20 things“ aka as Services
Excersise: e4 wizard Create a new applicaton via File -> New -> Other -> e4 -> e4 Application Project Choose a name, e.g. „org.eclipsecon.e4.first“ Leave all default and go to the last tab and press finish. On the „org.eclipsecon.e4.first.product“ select the overview tab. Press „Launch an Eclipse application“ -> your application should start In case you have problem, please use „de.vogella.e4.rcp.wizard“ from your important workspace as a reference. 21 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Motivation  Why a new approach?
Eclipse 3.x the workbench model UI Contributions via plugin.xml Stored in separate registries (ViewRegistry, EditorRegistry) Several advisers, e.g Actions created by ActionBarAdvicers UI model is pre-defined © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Eclipse 3.x the workbench model Not easy to test No single place to look for the workbench model © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Editor vrs. View - ViewParts are not equal Editor
The Singleton Problem PlatformUI.getWorkbench() Platform.getExtensionRegistry() ResourcePlugin.getWorkspace() Dependencies make UI difficult to test and hard to re-use  © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
If I only had a consistent view of the Eclipse workbench 27
The e4 Workbench Model e4 Workbench Model EMF inside © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
5 reasons why using EMF is fantastic: Proven domain model technology Runtime small (1.5 MB) and highly optimized Tooling available Easy to build visual tools on top 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 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
The e4 Workbench Model Model „ UIElements.ecore“ is contained in plugin „org.eclipse.e4.ui.model.workbench“
Example Elements Application Part (aka View / Editor)
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 Parts Handlers Key Bindings Commands © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Model is Flexible Perspectives are options Stack / Slash Forms are optional Extend it to get your own functionality (more on renderes later) © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Defining the model  User changes Base Model provided by xmi file (Application.e4xmi) Model Components are contribution of extension point „ org.eclipse.e4.workbench.model” Model can be dynamically changed by Code User model changes are stored as (intelligent) deltas and applied during startup. Model Components Application.e4xmi Application.e4xmi © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Limits of the e4 application model Only models the Application (frame) Modeled Workbench Content of the view not part of the e4 model
Model URI’s The Part in the Model The Part’s URI © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Parts publicclassListView {    @Inject    privateIEclipseContextcontext;    @Inject    publicListView(Composite parent) { // ... ,[object Object]
Services are injected via the the framework
Defined Lifecycle via annotioans (@PostConstruct, @Predestroy) Re-usable  Easier to test © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Hierarchy of ViewParts in 3.x vrs. Parts  Eclipse 3.x Eclipse e4 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
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  © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
How is this model translated into UI components? © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
UI Renderer The Workbench model is independent of a specific UI toolkit Each UI elements gets are renderer  Renderer manage Lifecycle of the UI-Element Creation Model to widget binding Rendering Disposal © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Renderers © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
How to determine a Renderer During startup, the app context is asks for an IPresentationEngine service The default is an SWT based presentation engine The presentation engine asks the RenderFactory for the Renderers of the individual UI components org.eclipse.e4.workbench.ui.renderers.swt.WorkbenchRendererFactory returns org.eclipse.e4.workbench.ui.renderers.swt.SWTPartRenderer for the model components e.g. org.eclipse.e4.workbench.ui.renderers.swt.SashRenderer © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
RendererFactory Example publicclassWorkbenchRendererFactoryimplementsIRendererFactory { publicAbstractPartRenderergetRenderer(MUIElementuiElement,                                                                      Object parent) {      if (uiElementinstanceofMPart) {            if (contributedPartRenderer == null) { contributedPartRenderer = newContributedPartRenderer(); initRenderer(contributedPartRenderer);            }            returncontributedPartRenderer;      } //... © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Services © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Eclipse Application Services (“Twenty Things”) ,[object Object]
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© Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Examples ,[object Object]
Logger
IShellProvider
OSGi services is also available via dependency injection
Workbench Services follow usually with E*Service pattern, e.g.
EPartService
ESelectionService
EModelService© Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
Excersise: Using the Model Editor Load the project „de.vogella.e4.rcp.first“. Start the application via the .product file and validate that the application is working.  Select the Application.e4xmi file, right click and select Open-with „E4 WorkbenchModel Editor“. Rename the menu entry „Hello“ Rename the title of the „View1“ Change the order of the Views in the stack. 48 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)

Más contenido relacionado

La actualidad más candente

I pad uicatalog_lesson02
I pad uicatalog_lesson02I pad uicatalog_lesson02
I pad uicatalog_lesson02Rich Helton
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and DebuggingRich Helton
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1Rich Helton
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad ProgrammingRich Helton
 
Visual Studio Automation Object Model. EnvDTE interfaces
Visual Studio Automation Object Model. EnvDTE interfacesVisual Studio Automation Object Model. EnvDTE interfaces
Visual Studio Automation Object Model. EnvDTE interfacesPVS-Studio
 
Python harness fundamental
Python harness fundamentalPython harness fundamental
Python harness fundamentalRobin0590
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101Rich Helton
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksTsimafei Avilin
 
Plug-in Architectures
Plug-in ArchitecturesPlug-in Architectures
Plug-in Architectureselliando dias
 
Selenium Interview Questions & Answers
Selenium Interview Questions & AnswersSelenium Interview Questions & Answers
Selenium Interview Questions & AnswersTechcanvass
 
San Diego ASP.NET Meeting Oct 21st
San  Diego  ASP.NET Meeting Oct 21stSan  Diego  ASP.NET Meeting Oct 21st
San Diego ASP.NET Meeting Oct 21stWoody Pewitt
 
Entity frameworks101
Entity frameworks101Entity frameworks101
Entity frameworks101Rich Helton
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionAmr E. Mohamed
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsTrinity Dwarka
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management toolRenato Primavera
 

La actualidad más candente (20)

I pad uicatalog_lesson02
I pad uicatalog_lesson02I pad uicatalog_lesson02
I pad uicatalog_lesson02
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
 
Azure rev002
Azure rev002Azure rev002
Azure rev002
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad Programming
 
Visual Studio Automation Object Model. EnvDTE interfaces
Visual Studio Automation Object Model. EnvDTE interfacesVisual Studio Automation Object Model. EnvDTE interfaces
Visual Studio Automation Object Model. EnvDTE interfaces
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
Python harness fundamental
Python harness fundamentalPython harness fundamental
Python harness fundamental
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricks
 
Plug-in Architectures
Plug-in ArchitecturesPlug-in Architectures
Plug-in Architectures
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Selenium Interview Questions & Answers
Selenium Interview Questions & AnswersSelenium Interview Questions & Answers
Selenium Interview Questions & Answers
 
San Diego ASP.NET Meeting Oct 21st
San  Diego  ASP.NET Meeting Oct 21stSan  Diego  ASP.NET Meeting Oct 21st
San Diego ASP.NET Meeting Oct 21st
 
Entity frameworks101
Entity frameworks101Entity frameworks101
Entity frameworks101
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 

Destacado

Eclipse Plug-in Develompent Tips And Tricks
Eclipse Plug-in Develompent Tips And TricksEclipse Plug-in Develompent Tips And Tricks
Eclipse Plug-in Develompent Tips And TricksChris Aniszczyk
 
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBMOSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBMmfrancis
 
Eclipse Extensions Vs OSGI Services Tikal@ EclipseDemoCamps Tel Aviv
Eclipse Extensions Vs OSGI Services   Tikal@ EclipseDemoCamps Tel AvivEclipse Extensions Vs OSGI Services   Tikal@ EclipseDemoCamps Tel Aviv
Eclipse Extensions Vs OSGI Services Tikal@ EclipseDemoCamps Tel Avivguestb69b980e
 
OSGi, Eclipse and API Tooling
OSGi, Eclipse and API ToolingOSGi, Eclipse and API Tooling
OSGi, Eclipse and API ToolingChris Aniszczyk
 
Intro to OSGi and Eclipse Virgo
Intro to OSGi and Eclipse VirgoIntro to OSGi and Eclipse Virgo
Intro to OSGi and Eclipse VirgoGordon Dickens
 
Eclipse plug in development
Eclipse plug in developmentEclipse plug in development
Eclipse plug in developmentMartin Toshev
 
Atmosphere Powerpoint
Atmosphere PowerpointAtmosphere Powerpoint
Atmosphere PowerpointMrs. Henley
 
K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)LiGhT ArOhL
 
K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)LiGhT ArOhL
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 

Destacado (11)

RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Eclipse Plug-in Develompent Tips And Tricks
Eclipse Plug-in Develompent Tips And TricksEclipse Plug-in Develompent Tips And Tricks
Eclipse Plug-in Develompent Tips And Tricks
 
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBMOSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
 
Eclipse Extensions Vs OSGI Services Tikal@ EclipseDemoCamps Tel Aviv
Eclipse Extensions Vs OSGI Services   Tikal@ EclipseDemoCamps Tel AvivEclipse Extensions Vs OSGI Services   Tikal@ EclipseDemoCamps Tel Aviv
Eclipse Extensions Vs OSGI Services Tikal@ EclipseDemoCamps Tel Aviv
 
OSGi, Eclipse and API Tooling
OSGi, Eclipse and API ToolingOSGi, Eclipse and API Tooling
OSGi, Eclipse and API Tooling
 
Intro to OSGi and Eclipse Virgo
Intro to OSGi and Eclipse VirgoIntro to OSGi and Eclipse Virgo
Intro to OSGi and Eclipse Virgo
 
Eclipse plug in development
Eclipse plug in developmentEclipse plug in development
Eclipse plug in development
 
Atmosphere Powerpoint
Atmosphere PowerpointAtmosphere Powerpoint
Atmosphere Powerpoint
 
K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN HEALTH (Q3-Q4)
 
K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)
K TO 12 GRADE 7 LEARNING MODULE IN SCIENCE (Q3-Q4)
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 

Similar a Eclipse e4 Tutorial - EclipseCon 2010

Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010Lars Vogel
 
CSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.xCSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.xKai Tödter
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformTonny Madsen
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit TestingJames Phillips
 
Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012
Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012
Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012jsievers
 
Developing Rich Clients with the Eclipse 4 Application Platform
Developing Rich Clients with the Eclipse 4 Application PlatformDeveloping Rich Clients with the Eclipse 4 Application Platform
Developing Rich Clients with the Eclipse 4 Application PlatformKai Tödter
 
Application of code composer studio in digital signal processing
Application of code composer studio in digital signal processingApplication of code composer studio in digital signal processing
Application of code composer studio in digital signal processingIAEME Publication
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview Lars Vogel
 
Eclipse Banking Day in Copenhagen - Eclipse RCP as an Application Platform
Eclipse Banking Day in Copenhagen - Eclipse RCP as an Application PlatformEclipse Banking Day in Copenhagen - Eclipse RCP as an Application Platform
Eclipse Banking Day in Copenhagen - Eclipse RCP as an Application PlatformTonny Madsen
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureTonny Madsen
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Mikkel Flindt Heisterberg
 
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019Codemotion
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
 
LoCloud - D3.1: Operational SaaS Test lab
LoCloud -  D3.1: Operational SaaS Test labLoCloud -  D3.1: Operational SaaS Test lab
LoCloud - D3.1: Operational SaaS Test lablocloud
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...bhargavi804095
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesDurgesh Singh
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...bhargavi804095
 

Similar a Eclipse e4 Tutorial - EclipseCon 2010 (20)

Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010Eclipse 40 Labs- Eclipse Summit Europe 2010
Eclipse 40 Labs- Eclipse Summit Europe 2010
 
CSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.xCSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.x
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platform
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit Testing
 
Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012
Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012
Building Eclipse Plugins and RCP Applications with Tycho - ECE 2012
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Pcom xpcom
Pcom xpcomPcom xpcom
Pcom xpcom
 
Developing Rich Clients with the Eclipse 4 Application Platform
Developing Rich Clients with the Eclipse 4 Application PlatformDeveloping Rich Clients with the Eclipse 4 Application Platform
Developing Rich Clients with the Eclipse 4 Application Platform
 
Application of code composer studio in digital signal processing
Application of code composer studio in digital signal processingApplication of code composer studio in digital signal processing
Application of code composer studio in digital signal processing
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
 
Eclipse Banking Day in Copenhagen - Eclipse RCP as an Application Platform
Eclipse Banking Day in Copenhagen - Eclipse RCP as an Application PlatformEclipse Banking Day in Copenhagen - Eclipse RCP as an Application Platform
Eclipse Banking Day in Copenhagen - Eclipse RCP as an Application Platform
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
LoCloud - D3.1: Operational SaaS Test lab
LoCloud -  D3.1: Operational SaaS Test labLoCloud -  D3.1: Operational SaaS Test lab
LoCloud - D3.1: Operational SaaS Test lab
 
T2
T2T2
T2
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...
 

Más de Lars Vogel

Eclipse IDE and Platform news on Fosdem 2020
Eclipse IDE and Platform news on Fosdem 2020Eclipse IDE and Platform news on Fosdem 2020
Eclipse IDE and Platform news on Fosdem 2020Lars Vogel
 
Eclipse platform news and how to contribute to the Eclipse Open Source project
Eclipse platform news and how to contribute to the Eclipse Open Source projectEclipse platform news and how to contribute to the Eclipse Open Source project
Eclipse platform news and how to contribute to the Eclipse Open Source projectLars Vogel
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views Lars Vogel
 
How to become an Eclipse committer in 20 minutes and fork the IDE
How to become an Eclipse committer in 20 minutes and fork the IDEHow to become an Eclipse committer in 20 minutes and fork the IDE
How to become an Eclipse committer in 20 minutes and fork the IDELars Vogel
 
Building beautiful User Interface in Android
Building beautiful User Interface in AndroidBuilding beautiful User Interface in Android
Building beautiful User Interface in AndroidLars Vogel
 
What is so cool about Android 4.0
What is so cool about Android 4.0What is so cool about Android 4.0
What is so cool about Android 4.0Lars Vogel
 
What is so cool about Android 4.0?
What is so cool about Android 4.0?What is so cool about Android 4.0?
What is so cool about Android 4.0?Lars Vogel
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
Eclipse e4 - Google Eclipse Day
Eclipse e4 - Google Eclipse DayEclipse e4 - Google Eclipse Day
Eclipse e4 - Google Eclipse DayLars Vogel
 
Android C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen ConferenceAndroid C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen ConferenceLars Vogel
 
Android Overview (Karlsruhe VKSI)
Android Overview (Karlsruhe VKSI)Android Overview (Karlsruhe VKSI)
Android Overview (Karlsruhe VKSI)Lars Vogel
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Lars Vogel
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsLars Vogel
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Android Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App EngineAndroid Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App EngineLars Vogel
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Eclipse 4.0 - Dynamic Models
Eclipse 4.0 - Dynamic Models Eclipse 4.0 - Dynamic Models
Eclipse 4.0 - Dynamic Models Lars Vogel
 
Android Programming made easy
Android Programming made easyAndroid Programming made easy
Android Programming made easyLars Vogel
 
Eclipse RCP Overview @ Rheinjug
Eclipse RCP Overview @ RheinjugEclipse RCP Overview @ Rheinjug
Eclipse RCP Overview @ RheinjugLars Vogel
 
Google App Engine for Java (GAE/J)
Google App Engine for Java (GAE/J) Google App Engine for Java (GAE/J)
Google App Engine for Java (GAE/J) Lars Vogel
 

Más de Lars Vogel (20)

Eclipse IDE and Platform news on Fosdem 2020
Eclipse IDE and Platform news on Fosdem 2020Eclipse IDE and Platform news on Fosdem 2020
Eclipse IDE and Platform news on Fosdem 2020
 
Eclipse platform news and how to contribute to the Eclipse Open Source project
Eclipse platform news and how to contribute to the Eclipse Open Source projectEclipse platform news and how to contribute to the Eclipse Open Source project
Eclipse platform news and how to contribute to the Eclipse Open Source project
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
 
How to become an Eclipse committer in 20 minutes and fork the IDE
How to become an Eclipse committer in 20 minutes and fork the IDEHow to become an Eclipse committer in 20 minutes and fork the IDE
How to become an Eclipse committer in 20 minutes and fork the IDE
 
Building beautiful User Interface in Android
Building beautiful User Interface in AndroidBuilding beautiful User Interface in Android
Building beautiful User Interface in Android
 
What is so cool about Android 4.0
What is so cool about Android 4.0What is so cool about Android 4.0
What is so cool about Android 4.0
 
What is so cool about Android 4.0?
What is so cool about Android 4.0?What is so cool about Android 4.0?
What is so cool about Android 4.0?
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Eclipse e4 - Google Eclipse Day
Eclipse e4 - Google Eclipse DayEclipse e4 - Google Eclipse Day
Eclipse e4 - Google Eclipse Day
 
Android C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen ConferenceAndroid C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen Conference
 
Android Overview (Karlsruhe VKSI)
Android Overview (Karlsruhe VKSI)Android Overview (Karlsruhe VKSI)
Android Overview (Karlsruhe VKSI)
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot Topics
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Android Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App EngineAndroid Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App Engine
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Eclipse 4.0 - Dynamic Models
Eclipse 4.0 - Dynamic Models Eclipse 4.0 - Dynamic Models
Eclipse 4.0 - Dynamic Models
 
Android Programming made easy
Android Programming made easyAndroid Programming made easy
Android Programming made easy
 
Eclipse RCP Overview @ Rheinjug
Eclipse RCP Overview @ RheinjugEclipse RCP Overview @ Rheinjug
Eclipse RCP Overview @ Rheinjug
 
Google App Engine for Java (GAE/J)
Google App Engine for Java (GAE/J) Google App Engine for Java (GAE/J)
Google App Engine for Java (GAE/J)
 

Eclipse e4 Tutorial - EclipseCon 2010

  • 1. Eclipse e4 Tutorial © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. Tom Schindl – BestSolution.at Lars Vogel – http://www.vogella.de Kai Tödter – Siemens AG
  • 2. Outline Theory The e4 Programming Model – Tom Schindl The Workbench Model – Lars Vogel Styling in e4 – Kai Tödter Labs Programming Model (looking a bit behind e4 Dependency Injection) Create an RCP-Application from scratch Work with CSS to retheme the Contacts Demo © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 2
  • 3. Installation USB-Sticks with Eclipse-SDK Only copy the version you need for your OS located at SDK-Folder Slides as PDFs located in slides-Folder Examples code located in samples-Folder Solutions code located in solutions-Folder © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 3
  • 4. E4 and Example Installation Copy the e4 zip file on your laptop and unzip it. Start e4 with eclipse.exe Use File -> Import -> „Existing Projects into Workspace“ to import the projects from directory „samples“. „Select archive file“ -> *.zip 4 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 5. e4 The Programming Model Tom Schindl BestSolution.at © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 6. Outline POJO as the Programming Model Dependency Injection JSR 330 Annotations e4 specific Annotations The IEclipseContext Handlers Lab Tasks © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 6
  • 7. POJO as the ProgrammingModel All building blocks of e4 are POJO © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 7
  • 8. 2 Main Object-Types Part UI Component representing an Editor, Table, Tree, … Most likely has a constructor which accepts a Composite Handler Reacts on Commands execute by the user through Button press, KeyBinding, … Has to have a method named execute() with a variable number of Parameters © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 8
  • 9. Dependency Injection What is DI Inversion of control: Your application doesn’t reach out stuff but gets it provided/injected from the outside framework e4 provides an JSR 330 compatible injection implementation @Inject – Field, Constructor and Method injection @Named – Specify a custom qualifier to context object (default is fully qualified classname of the injected type) © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 9
  • 10. Dependency Injection Example of an e4-Part publicclassMyPart { @Inject privateECommandServicecmdService; @Inject public SampleView(Composite parent) { } @Inject private voidsetSelection(@Optional @Named( IServiceConstants.SELECTION) Contactcontact) { // Handle changedselection } private voidexecCommand() { // Execute command } } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 10
  • 11. Dependency Injection e4 specific Annotations @Optional: Marking the parameter as optional @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) © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 11
  • 12. Dependency Injection Example Usage of e4 PostConstruct /PreDestroy Annotations publicclassMyPart { @Inject privateITimerServicetimerService; @PostConstruct private voidinit() { if(timerService!= null) { // Do something } } @PreDestroy private voiduninit() { if(timerService != null) { // Do something } } } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 12
  • 13. Dependency Injection IEclipseContext Stores information of possible Injection Values Hierarchical Datastructure Rootcontext backed up by OSGi-Service Registry (every registered as an OSGi-Service can get injected) Dynamic context information: Possibility to contribute an IContextFunction through DS to construct Objects on the fly © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 13
  • 14. Using Eclipse DI Eclipse DI can consumed standalone in OSGi-Applications publicObjectstart() { // GetBundle Information Bundlebundle = FrameworkUtil.getBundle(getClass()); BundleContextbundleContext = bundle.getBundleContext(); IEclipseContexteclipseCtx = EclipseContextFactory.getServiceContext(bundleContext); // FillContextwithinformationusingset(String,Object) // … // Create instanceofclass ContextInjectionFactory.make(MyPart.class, eclipseCtx); } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 14
  • 15. Writing Handlers Implement an Execute-Method Can have any number of arguments Use IServiceConstantsforgeneralcontextinformations publicclassAboutHandler { public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){ MessageDialog.openInformation( shell, "About", "e4 Application example."); } } © Tom Schindl and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 15
  • 16. LabTask 1 – Part 1 Create a Headless RCP-Application Add asdependency org.eclipse.e4.core.services javax.inject org.eclipse.swt org.eclipse.jface Create a classMyPartwith a TableViewer Constructoraccepts an SWT-Composite 16 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 17. LabTask 2 Import org.eclipse.tutorial.pgm.service Injectorg.eclipse.tutorial.pgm.service.ITimeService Register Listener in postconstructionphaseand update viewerwithInformations UnregisterListener in predestroy 17 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 18. LabTask 3 UseMethod-Injection Add methodset-methodwhichinjects an Objectof type String knownunderthe FQN „org.eclipsecon.myObject“ (hintusethe@Named and @Optional ) Start a threadbeforelaunchingtheeventloopandset a newvalue in theIEclipseContextfor „org.eclipsecon.myObject“ 18 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 19. Eclipse e4:Eclipse, the modeled Workbench and 20 other things Lars Vogel
  • 20. Mini-Agenda The existing Eclipse 3.x UI model e4 workbench model Model to UI -> Renderer „The 20 things“ aka as Services
  • 21. Excersise: e4 wizard Create a new applicaton via File -> New -> Other -> e4 -> e4 Application Project Choose a name, e.g. „org.eclipsecon.e4.first“ Leave all default and go to the last tab and press finish. On the „org.eclipsecon.e4.first.product“ select the overview tab. Press „Launch an Eclipse application“ -> your application should start In case you have problem, please use „de.vogella.e4.rcp.wizard“ from your important workspace as a reference. 21 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 22. Motivation Why a new approach?
  • 23. Eclipse 3.x the workbench model UI Contributions via plugin.xml Stored in separate registries (ViewRegistry, EditorRegistry) Several advisers, e.g Actions created by ActionBarAdvicers UI model is pre-defined © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 24. Eclipse 3.x the workbench model Not easy to test No single place to look for the workbench model © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 25. Editor vrs. View - ViewParts are not equal Editor
  • 26. The Singleton Problem PlatformUI.getWorkbench() Platform.getExtensionRegistry() ResourcePlugin.getWorkspace() Dependencies make UI difficult to test and hard to re-use © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 27. If I only had a consistent view of the Eclipse workbench 27
  • 28. The e4 Workbench Model e4 Workbench Model EMF inside © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 29. 5 reasons why using EMF is fantastic: Proven domain model technology Runtime small (1.5 MB) and highly optimized Tooling available Easy to build visual tools on top 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 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 30. The e4 Workbench Model Model „ UIElements.ecore“ is contained in plugin „org.eclipse.e4.ui.model.workbench“
  • 31. Example Elements Application Part (aka View / Editor)
  • 32. 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 Parts Handlers Key Bindings Commands © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 33. Model is Flexible Perspectives are options Stack / Slash Forms are optional Extend it to get your own functionality (more on renderes later) © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 34. Defining the model User changes Base Model provided by xmi file (Application.e4xmi) Model Components are contribution of extension point „ org.eclipse.e4.workbench.model” Model can be dynamically changed by Code User model changes are stored as (intelligent) deltas and applied during startup. Model Components Application.e4xmi Application.e4xmi © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 35. Limits of the e4 application model Only models the Application (frame) Modeled Workbench Content of the view not part of the e4 model
  • 36. Model URI’s The Part in the Model The Part’s URI © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 37.
  • 38. Services are injected via the the framework
  • 39. Defined Lifecycle via annotioans (@PostConstruct, @Predestroy) Re-usable  Easier to test © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 40. Hierarchy of ViewParts in 3.x vrs. Parts Eclipse 3.x Eclipse e4 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 41. 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 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 42. How is this model translated into UI components? © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 43. UI Renderer The Workbench model is independent of a specific UI toolkit Each UI elements gets are renderer Renderer manage Lifecycle of the UI-Element Creation Model to widget binding Rendering Disposal © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 44. Renderers © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 45. How to determine a Renderer During startup, the app context is asks for an IPresentationEngine service The default is an SWT based presentation engine The presentation engine asks the RenderFactory for the Renderers of the individual UI components org.eclipse.e4.workbench.ui.renderers.swt.WorkbenchRendererFactory returns org.eclipse.e4.workbench.ui.renderers.swt.SWTPartRenderer for the model components e.g. org.eclipse.e4.workbench.ui.renderers.swt.SashRenderer © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 46. RendererFactory Example publicclassWorkbenchRendererFactoryimplementsIRendererFactory { publicAbstractPartRenderergetRenderer(MUIElementuiElement, Object parent) { if (uiElementinstanceofMPart) { if (contributedPartRenderer == null) { contributedPartRenderer = newContributedPartRenderer(); initRenderer(contributedPartRenderer); } returncontributedPartRenderer; } //... © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 47. Services © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 48.
  • 66. Authorization© Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 67.
  • 70. OSGi services is also available via dependency injection
  • 71. Workbench Services follow usually with E*Service pattern, e.g.
  • 74. EModelService© Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 75. Excersise: Using the Model Editor Load the project „de.vogella.e4.rcp.first“. Start the application via the .product file and validate that the application is working. Select the Application.e4xmi file, right click and select Open-with „E4 WorkbenchModel Editor“. Rename the menu entry „Hello“ Rename the title of the „View1“ Change the order of the Views in the stack. 48 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 76. Excersise: Model Componets Load the project „de.vogella.e4.rcp.modelcontributions“. Open plugin.xml and check the extension point „ org.eclipse.e4.workbench.model” Review the files „components.e4xmi“ and „components2.e4xmi“ Create a new class „ org.eclipse.e4.modelcomponets.parts.Part4“ as a copy of an existing part and add it via model contribution to your UI. Remember that all ID‘s must be unique!! Remember to use the correct ID for the parent!! 49 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 77. Excersise: Services Load the project „ de.vogella.e4.rcp.first“. Open class „ org.eclipse.e4.modelcomponets.parts.View1“ Add private member @Inject Logger logger Write some log messages in the method init(), for example logger.info("UI will start to build"); 50 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de)
  • 78. e4 CSS Styling Kai Tödter Siemens Corporate Technology © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 79. Outline CSS Styling Demo Lab Task Discussion © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 52
  • 80. Styling the User Interface In Eclipse 3.x, UI styling can be done using The Presentation API Custom Widgets These mechanisms are very limited It is not possible to implement a specific UI design, created by a designer e4 provides a CSS based UI styling that addresses all the above issues 53 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 81. Contacts Demo without CSS Styling 54 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 82. Dark CSS Styling with Gradients 55 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 83. Bright CSS Styling with Gradients 56 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 84. Bright CSS Styling with new look 57 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 85. How does the CSS look like? 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; } 58 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 86. Some Things you cannot style (yet) Menu bar background Table headers Partly implemented: Gradients Planned: Having similar capabilities compared with WebKit’s gradients 59 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 87. How to enable CSS Styling Create a contribution to the 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> 60 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 88. How to use custom attributes? Java Label label = new Label(parent, SWT.NONE); label.setData("org.eclipse.e4.ui.css.id", "SeparatorLabel"); CSS #SeparatorLabel { color: #f08d00; } 61 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 89. e4 CSS Editors CSS has a well known syntax But which UI elements can be styled? Which CSS attributes does a specific element support? The first approach for the above questions might be an Xtext-based editor, with content assist for both elements and attributes A project is already set up, stay tuned… 62 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 90. Gradient Examples 63 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 91. Dynamic Theme Switching It is possible to change the CSS based styling at runtime Good for accessibility Good for user preferences 64 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 92. CSS Styling Engine Getting the styling engine: Display display = shell.getDisplay(); finalCSSEngine engine = (CSSEngine) display.getData("org.eclipse.e4.ui.css.core.engine"); This is a current workaround The engine should be a service accessible through the EclipseContext 65 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 93. Theme Switching Code URL url = FileLocator.resolve(new URL( "platform:/plugin/org.eclipse.e4.demo.contacts/css/new.css")); InputStreamReaderstreamReader = newInputStreamReader( url.openStream();); engine.reset(); engine.parseStyleSheet(streamReader); streamReader.close(); try { shell.setRedraw(false); shell.reskin(SWT.ALL); } finally { shell.setRedraw(true); } 66 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 94. Contacs Demo on RAP 67 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 95. How will the e4 IDE look like? Designers are working on a new e4 workbench look Watch bug 293481 for mockups Windows XP Windows 7 Mac Cocoa https://bugs.eclipse.org/bugs/show_bug.cgi?id=293481 68 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 96. e4 IDE Mockup (February 2010) 69 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 97. Demo 70 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 98. Lab Task Install the Contacts Demo sources form the USB stick Start the demo Edit both css/dark-gradient.css and css/bright-gradient.css Play around switching the css styles at runtime and watch the differences you made Optional: Create a new colorful psychedelic look for the Contacts Demo. Send screen shots to kai@toedter.com  71 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.
  • 99. e4: Where to go from here: 72 © Lars Vogel and others, Licensed under Creative Commons by-nc-nd-3.0 (de) Eclipse e4 Wiki http://wiki.eclipse.org/E4 Eclipse e4 Tutorial http://www.vogella.de/articles/EclipseE4/article.html Eclipse e4 Whitepaper http://www.eclipse.org/e4/resources/e4-whitepaper.php Lars Vogel‘s Blog http://www.vogella.de/blog Tom Schindl‘s Blog http://tomsondev.bestsolution.at/ Kai Toeder http://www.toedter.com/blog/
  • 100. Photo credits Target http://www.sxc.hu/photo/1078182 Rusty stuff http://www.sxc.hu/photo/450663 Binder: http://www.sxc.hu/photo/443042 Something is different http://www.sxc.hu/photo/944284 Praying Girl http://www.sxc.hu/photo/646227 Pin http://www.sxc.hu/photo/771409 Box: http://www.sxc.hu/photo/502457 Screws http://www.sxc.hu/photo/1148064 House with compartments http://www.sxc.hu/photo/494103 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
  • 101. Discussion © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 74
  • 102. 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 75