SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
MODERNIZE YOUR REAL-
WORLD APPLICATION WITH
E4 AND JAVAFX
COLE MARKHAM	

 	

 	

 	

SENIOR SOFTWARE ENGINEER	

THE WELLAND COMPANY	

!
!
CMARKHAM@WELLAND.COM
WELLAND BACKGROUND
• Welland Company celebrating 24 years	

• Flagship products	

• EXPORT	

• FORMS	

• IBM / Rocket Business Partner	

• Perform support for UniVerse / UniData sites
EXPORT PRODUCT OVERVIEW
• Transfers U2 data into an SQL compliant database	

• Access data for reporting, warehousing, and web
services	

• Empowers users to build reports and queries with
industry-standard tools.
EXPORT ARCHITECTURE
U2	

Database
EXPORT	

Server
SQL
Database
EXPORT
Client
MAKE IT LOOK LIKE IT WASN’T
BUILT IN 1995!
BUT IT’S BETTERTHANTHIS…
NEW SWING L&F?
DESIGNER’SVISION
BACKTOTHE DRAWING BOARD
• UI Frameworks	

• Swing	

• SWT	

• JavaFX	

• HTML5	

• .NET
• Application Frameworks	

• RCP 3.x	

• E4	

• Scout	

• Riena	

• .NET
Why JavaFX?
• FXML using SceneBuilder	

• CSS Styling	

• Chart library	

• e(fx)clipse tooling and E4 Renderers	

• Deployment via packaged application with JRE
CSS STYLING
• 500 Lines of CSS for our custom theme	

• E4 Renders add CSS classes
SCENE BUILDER
CHART LIBRARY
HTML5 SUPPORT
Why Eclipse 4?
• Modern architecture	

• Modularity	

• Application model	

• Custom Renderers	

• Dependency Injection	

• OSGi
RAPID PROTOTYPING
OSGI Bundle
EXPORT ARCHITECTURE
EXPORT	

Server
Old EXPORT Client
Equinox Framework
E4 Platform
e(fx)clipse
New Export Client
FXML LOADING
• Custom factory class used for most parts	

• Handles loading FXML resource defined in model	

• Controller class specified in FXML file	

• Inject @FXML variables into controller	

• Full Eclipse dependency injection support
FXML LOADING
public class FxmlLoadedPart{	
	 // Loaded from the fxml	
	 private Node mainControl;	
	 @PostConstruct	
	 public void postConstruct(	
	 	 	 @org.eclipse.fx.ui.di.FXMLLoader	
	 	 	 FXMLLoaderFactory factory,	
	 	 	 BorderPane parent,	
	 	 	 MPart part){	
	 	 try{	
	 	 	 String partFXML = part.getProperties().get("welland.part.fxml");	
	 	 	 if (partFXML == null){	
	 	 	 getLogger(this).warning("welland.part.fxml was null for part: " + part.getLabel() );	
	 	 	 return;	
	 	 	 }	
	 	 	 FXMLBuilder<Node> builder = factory.loadBundleRelative(partFXML);	
	 	 	 mainControl = builder.load();	
	 	 	 parent.setCenter(mainControl);	
	 	 }catch(IOException e){	
	 	 	 LoggerFactory.getFactory().getLogger(this).log(Level.WARNING,	
	 	 	 	 	 "Error loading fxml", e);	
	 	 }	
	 }	
	 @Focus	
	 public void onFocus(){	
	 	 mainControl.requestFocus();	
	 }	
}
• Custom factory class used for most parts
IMPLEMENTING A LOGIN DIALOG
IMPLEMENTING A LOGIN DIALOG
Defined as a Window in the application model	

Window contains a single Part	

Custom Window 

Renderer to set

modality
CUSTOM PERSPECTIVE SWITCHER
CUSTOM PERSPECTIVE SWITCHER
• Prototyped in SceneBuilder, defined in FXML	

• Radio Buttons with custom CSS	

• Implemented as aToolControl, in WindowTrimBar	

• Simpler implementation than MPerspectiveStack renderer	

• Listens to model for perspective changes	

• Updates model when buttons are pressed
CUSTOM PERSPECTIVE SWITCHER
Simple yet powerful CSS
CUSTOMTITLE BAR AND MENUS
CUSTOMTITLE BAR AND MENUS
• e(fx)clipse support for custom window decoration	

• Set efx.window.decoration.fxml in model	

• Custom Window renderer to populate icon, title
and menus	

• Application Addon to bind menus to perspectives
CUSTOMTITLE BAR AND MENUS
• Set tag on Menu in application model
CUSTOMTITLE BAR AND MENUS
public class PerspectiveMenuProcessingAddon {	
	 	
	 @Inject @Optional	
	 public void perspectiveChanged(	
	 	 	 @UIEventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event) {	
	 	 Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);	
	 	 if(changedObj instanceof MPerspectiveStack){	
	 	 	 MPerspectiveStack perspectiveStack = (MPerspectiveStack)changedObj;	
	 	 	 MPerspective perspective = perspectiveStack.getSelectedElement();	
	 	 	 if (perspective != null && perspective.getContext() != null) {	
	 	 	 MWindow window = perspective.getContext().getActive(MWindow.class);	
	 	 	 MMenu mainMenu = window.getMainMenu();	
	 	 	 for (MMenuElement element: mainMenu.getChildren()) {	
	 	 	 List<String> tags = element.getTags();	
	 	 	 if (tags.contains("limitPerspectives")) {	
	 	 	 element.setVisible(tags.contains(perspective.getElementId()));	
	 	 	 }	
	 	 	 }	
	 	 	 }	
	 	 }	
	 }	
}
• Application Addon to bind menus to perspectives
DEPENDENCY INJECTIONTIPS
• Avoid generics	

• Use @Optional when appropriate	

• Use method injection with @Optional or dynamic objects	

• Active selection 

@Named(IServiceConstants.ACTIVE_SELECTION)	

• Use @UIEventTopic to receive notifications on the UI
thread
DEPENDENCY INJECTIONTIPS
• Avoid generics
public class ExampleTableHandler {	
	 @Execute	
public void execute(	
@Named(IServiceConstants.ACTIVE_SELECTION) 	
final List<Table> selectedTables) {	
	 // this will break if the active selection becomes List<Foo>	
	 	 for (Table table: selectedTables) {	
	 // do something with the table	
	 }	
	 }	
	 	 	
}
public class ExampleTableHandler {	
	 @Execute	
public void execute(	
@Named(IServiceConstants.ACTIVE_SELECTION) final Table[] selectedTables) {	
	 // do something with the tables	
	 }	
	 	 	
}
DEPENDENCY INJECTIONTIPS
• Use @Optional when injected object may not be available at
construction	

• Use methods with @Optional
@Inject	
@Optional	
public void populate(ExportOperations newOperations){	
	 // Save for later	
	 this.operations = newOperations;	
	 // Do something useful with the operations	
}
DEPENDENCY INJECTIONTIPS
• Active selection 

@Named(IServiceConstants.ACTIVE_SELECTION)	

• Different semantics than RCP 3.x	

• Useful for popup menus and master/detail views	

• Consider custom @Named variables	

• Only one part’s selection can be active	

• @Inject method not called when active part changes
DEPENDENCY INJECTIONTIPS
• Use @UIEventTopic to receive notifications on the UI thread	

• Post notifications using IEventBroker	

• Pub-Sub pattern enables decoupled code	

• Platform handles calling subscribers on the UIThread
@Inject	
@Optional	
public void insert(@UIEventTopic(EventConstants.TOPIC_NEW) Table table) {	
	 // New data added, add to our TableView data to refresh UI	
	 data.add(table);	
}
@Inject	
IEventBroker eventBroker;	 	
!
protected IStatus runInJobThread(IProgressMonitor monitor) {	
	 operations.add(table);	
	 eventBroker.post(EventConstants.TOPIC_NEW, table);	
	 return Status.OK_STATUS;	
}
Publish Subscribe
RESOURCES/ACKNOWLEDGMENTS
• http://eclipse.org/efxclipse	

• http://wiki.eclipse.org/Efxclipse/Tutorials
QUESTIONS?
EVALUATETHIS SESSION
Sign-in: www.eclipsecon.org
Select session from schedule
Evaluate:
1
2
3

Más contenido relacionado

La actualidad más candente

What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
Alfonso Fernández
 
e computer notes - Creating views
e computer notes - Creating viewse computer notes - Creating views
e computer notes - Creating views
ecomputernotes
 

La actualidad más candente (20)

JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
Ajax Applications with JSF 2 and New RichFaces 4 - JAX/JSF Summit
Ajax Applications with JSF 2 and New RichFaces 4 - JAX/JSF SummitAjax Applications with JSF 2 and New RichFaces 4 - JAX/JSF Summit
Ajax Applications with JSF 2 and New RichFaces 4 - JAX/JSF Summit
 
What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
 
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Ajax Applications with JSF 2 and New RichFaces 4 - CONFESS 2011
Ajax Applications with JSF 2 and New RichFaces 4 - CONFESS 2011Ajax Applications with JSF 2 and New RichFaces 4 - CONFESS 2011
Ajax Applications with JSF 2 and New RichFaces 4 - CONFESS 2011
 
JavaFX – 10 things I love about you
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about you
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Angular Mini Hackathon Code Talks 2019
Angular Mini Hackathon Code Talks 2019Angular Mini Hackathon Code Talks 2019
Angular Mini Hackathon Code Talks 2019
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
 
RichFaces 4 webinar #1: Everything You Need To Know
RichFaces 4 webinar #1: Everything You Need To KnowRichFaces 4 webinar #1: Everything You Need To Know
RichFaces 4 webinar #1: Everything You Need To Know
 
Angular Workshop FrOSCon 2018
Angular Workshop  FrOSCon 2018Angular Workshop  FrOSCon 2018
Angular Workshop FrOSCon 2018
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
 
JavaFX Advanced
JavaFX AdvancedJavaFX Advanced
JavaFX Advanced
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
Gephi Toolkit Tutorial
Gephi Toolkit TutorialGephi Toolkit Tutorial
Gephi Toolkit Tutorial
 
e computer notes - Creating views
e computer notes - Creating viewse computer notes - Creating views
e computer notes - Creating views
 
Spring framework part 2
Spring framework  part 2Spring framework  part 2
Spring framework part 2
 

Similar a Modernize Your Real-World Application with Eclipse 4 and JavaFX

SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
Jon Galloway
 

Similar a Modernize Your Real-World Application with Eclipse 4 and JavaFX (20)

Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010
 
WPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA AustriaWPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA Austria
 
Learn about Eclipse e4 from Lars Vogel at SF-JUG
Learn about Eclipse e4 from Lars Vogel at SF-JUGLearn about Eclipse e4 from Lars Vogel at SF-JUG
Learn about Eclipse e4 from Lars Vogel at SF-JUG
 
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UICustomizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
 
Eclipse e4
Eclipse e4Eclipse e4
Eclipse e4
 
Java development with the dynamo framework
Java development with the dynamo frameworkJava development with the dynamo framework
Java development with the dynamo framework
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
 
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-FunctionsIntegration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
 
SOLID & IoC Principles
SOLID & IoC PrinciplesSOLID & IoC Principles
SOLID & IoC Principles
 
Tips and tricks of the 2021.4 release
Tips and tricks of the 2021.4 releaseTips and tricks of the 2021.4 release
Tips and tricks of the 2021.4 release
 
Siebel Open UI Presentation
Siebel Open UI PresentationSiebel Open UI Presentation
Siebel Open UI Presentation
 
Applet in java
Applet in javaApplet in java
Applet in java
 
JavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io PresentationJavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io Presentation
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
 
S313937 cdi dochez
S313937 cdi dochezS313937 cdi dochez
S313937 cdi dochez
 
Fluttering
FlutteringFluttering
Fluttering
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

Modernize Your Real-World Application with Eclipse 4 and JavaFX

  • 1. MODERNIZE YOUR REAL- WORLD APPLICATION WITH E4 AND JAVAFX COLE MARKHAM SENIOR SOFTWARE ENGINEER THE WELLAND COMPANY ! ! CMARKHAM@WELLAND.COM
  • 2. WELLAND BACKGROUND • Welland Company celebrating 24 years • Flagship products • EXPORT • FORMS • IBM / Rocket Business Partner • Perform support for UniVerse / UniData sites
  • 3. EXPORT PRODUCT OVERVIEW • Transfers U2 data into an SQL compliant database • Access data for reporting, warehousing, and web services • Empowers users to build reports and queries with industry-standard tools.
  • 5. MAKE IT LOOK LIKE IT WASN’T BUILT IN 1995!
  • 9. BACKTOTHE DRAWING BOARD • UI Frameworks • Swing • SWT • JavaFX • HTML5 • .NET • Application Frameworks • RCP 3.x • E4 • Scout • Riena • .NET
  • 10. Why JavaFX? • FXML using SceneBuilder • CSS Styling • Chart library • e(fx)clipse tooling and E4 Renderers • Deployment via packaged application with JRE
  • 11. CSS STYLING • 500 Lines of CSS for our custom theme • E4 Renders add CSS classes
  • 15. Why Eclipse 4? • Modern architecture • Modularity • Application model • Custom Renderers • Dependency Injection • OSGi
  • 17. OSGI Bundle EXPORT ARCHITECTURE EXPORT Server Old EXPORT Client Equinox Framework E4 Platform e(fx)clipse New Export Client
  • 18. FXML LOADING • Custom factory class used for most parts • Handles loading FXML resource defined in model • Controller class specified in FXML file • Inject @FXML variables into controller • Full Eclipse dependency injection support
  • 19. FXML LOADING public class FxmlLoadedPart{ // Loaded from the fxml private Node mainControl; @PostConstruct public void postConstruct( @org.eclipse.fx.ui.di.FXMLLoader FXMLLoaderFactory factory, BorderPane parent, MPart part){ try{ String partFXML = part.getProperties().get("welland.part.fxml"); if (partFXML == null){ getLogger(this).warning("welland.part.fxml was null for part: " + part.getLabel() ); return; } FXMLBuilder<Node> builder = factory.loadBundleRelative(partFXML); mainControl = builder.load(); parent.setCenter(mainControl); }catch(IOException e){ LoggerFactory.getFactory().getLogger(this).log(Level.WARNING, "Error loading fxml", e); } } @Focus public void onFocus(){ mainControl.requestFocus(); } } • Custom factory class used for most parts
  • 21. IMPLEMENTING A LOGIN DIALOG Defined as a Window in the application model Window contains a single Part Custom Window 
 Renderer to set
 modality
  • 23. CUSTOM PERSPECTIVE SWITCHER • Prototyped in SceneBuilder, defined in FXML • Radio Buttons with custom CSS • Implemented as aToolControl, in WindowTrimBar • Simpler implementation than MPerspectiveStack renderer • Listens to model for perspective changes • Updates model when buttons are pressed
  • 26. CUSTOMTITLE BAR AND MENUS • e(fx)clipse support for custom window decoration • Set efx.window.decoration.fxml in model • Custom Window renderer to populate icon, title and menus • Application Addon to bind menus to perspectives
  • 27. CUSTOMTITLE BAR AND MENUS • Set tag on Menu in application model
  • 28. CUSTOMTITLE BAR AND MENUS public class PerspectiveMenuProcessingAddon { @Inject @Optional public void perspectiveChanged( @UIEventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event) { Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT); if(changedObj instanceof MPerspectiveStack){ MPerspectiveStack perspectiveStack = (MPerspectiveStack)changedObj; MPerspective perspective = perspectiveStack.getSelectedElement(); if (perspective != null && perspective.getContext() != null) { MWindow window = perspective.getContext().getActive(MWindow.class); MMenu mainMenu = window.getMainMenu(); for (MMenuElement element: mainMenu.getChildren()) { List<String> tags = element.getTags(); if (tags.contains("limitPerspectives")) { element.setVisible(tags.contains(perspective.getElementId())); } } } } } } • Application Addon to bind menus to perspectives
  • 29. DEPENDENCY INJECTIONTIPS • Avoid generics • Use @Optional when appropriate • Use method injection with @Optional or dynamic objects • Active selection 
 @Named(IServiceConstants.ACTIVE_SELECTION) • Use @UIEventTopic to receive notifications on the UI thread
  • 30. DEPENDENCY INJECTIONTIPS • Avoid generics public class ExampleTableHandler { @Execute public void execute( @Named(IServiceConstants.ACTIVE_SELECTION) final List<Table> selectedTables) { // this will break if the active selection becomes List<Foo> for (Table table: selectedTables) { // do something with the table } } } public class ExampleTableHandler { @Execute public void execute( @Named(IServiceConstants.ACTIVE_SELECTION) final Table[] selectedTables) { // do something with the tables } }
  • 31. DEPENDENCY INJECTIONTIPS • Use @Optional when injected object may not be available at construction • Use methods with @Optional @Inject @Optional public void populate(ExportOperations newOperations){ // Save for later this.operations = newOperations; // Do something useful with the operations }
  • 32. DEPENDENCY INJECTIONTIPS • Active selection 
 @Named(IServiceConstants.ACTIVE_SELECTION) • Different semantics than RCP 3.x • Useful for popup menus and master/detail views • Consider custom @Named variables • Only one part’s selection can be active • @Inject method not called when active part changes
  • 33. DEPENDENCY INJECTIONTIPS • Use @UIEventTopic to receive notifications on the UI thread • Post notifications using IEventBroker • Pub-Sub pattern enables decoupled code • Platform handles calling subscribers on the UIThread @Inject @Optional public void insert(@UIEventTopic(EventConstants.TOPIC_NEW) Table table) { // New data added, add to our TableView data to refresh UI data.add(table); } @Inject IEventBroker eventBroker; ! protected IStatus runInJobThread(IProgressMonitor monitor) { operations.add(table); eventBroker.post(EventConstants.TOPIC_NEW, table); return Status.OK_STATUS; } Publish Subscribe
  • 36. EVALUATETHIS SESSION Sign-in: www.eclipsecon.org Select session from schedule Evaluate: 1 2 3