+ All Categories
Home > Documents > SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application...

SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application...

Date post: 01-Sep-2019
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
19
AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights. EclipseCon Europe 2015 Automotive Service Solutions 1 SWT to JavaFX Migration Dirk Fauth
Transcript
Page 1: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

EclipseCon Europe 2015

Automotive Service Solutions

1

SWT to JavaFX Migration

Dirk Fauth

Page 2: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Speaker

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

2

Dirk Fauth

Robert Bosch GmbH

Franz-Oechsle-Straße 4

73207 Plochingen

[email protected]

www.bosch.com

blog.vogella.com/author/fipro/

blog.codecentric.de/en/author/dirk-fauth/

Twitter: fipro78

Page 3: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Structure

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

3

SWT to JavaFX Migration Terminology

SWT vs. JavaFX

SWT Downsides

JavaFX Advantages

Migration Basics

Migration UI

Controls

Layout

Interactions & Event Handling

CSS Styling

Page 4: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

4

Terminology

Page 5: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Terminology

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

5

SWT Standard Widget Toolkit

JavaFX Oracle Standard Java UI Toolkit

SWTonJavaFX SWT Implementierung mit JavaFX

Page 6: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Terminology

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

6

Eclipse RCP Rich Client Platform

e(fx)clipse Tooling (IDE)

Runtime (JRE, OSGi, RCP, EMF)

Page 7: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

SWT vs. JavaFX

7

Page 8: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

SWT vs. JavaFX

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

8

SWT Downsides

Few people

Platform dependent

Usage of native widgets

CSS incomplete

Resource Management

Page 9: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

SWT vs. JavaFX

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

9

JavaFX Advantages

Part of Java

Multimedia-Platform

Usage of the Graphics Engine

Support of Transitions

Complete CSS Support

Graph instead of “Canvas”

Declarative UI

Page 10: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

Migration Basics

10

Page 11: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

public class Main extends Application {

@Override

public void start(Stage primaryStage) {

// build UI

}

public static void main(String[] args) {

launch(args);

}

}

Migration Basics

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

11

Plain SWT -> Plain JavaFXpublic class Main {

public static void main(String[] args) {

// build UI

while (!shell.isDisposed()) {

if (!display.readAndDispatch()) {

display.sleep();

}

}

// shutdown

}

}

Page 12: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Migration Basics

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

12

Eclipse RCP

Target Platform

Product

Feature Dependencies

Product / Application

Classloader-Delegation

Application Model

SWT Addons

Plug-in Dependencies

Page 13: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

13

Migration UI

Page 14: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Migration UI

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

14

Controls Replace SWT Controls with JavaFX

Controls

org.eclipse.swt.widgets.Label

org.eclipse.swt.widgets.Text

org.eclipse.swt.widgets.Button

javafx.scene.control.Label

javafx.scene.control.TextField

javafx.scene.control.Button

Label label =

new Label("My Label");

parent.getChildren().add(label);

Label label =

new Label(parent, SWT.NONE);

label.setText("My Label");

Mind the constructor parameter

Page 15: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Migration UI

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

15

Layout@PostConstruct

public void postConstruct(Composite parent) {

parent.setLayout(new GridLayout(3, true));

...

GridDataFactory.fillDefaults().applyTo(label);

@PostConstruct

public void postConstruct(GridPane parent) {

...

GridPane.setConstraints(label, 0, 0);

GridPane.setMargin(label, new Insets(5.0));

Page 16: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Migration UI

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

16

Interactions & Event Handling

button.addSelectionListener(new SelectionAdapter() {

@Override

public void widgetSelected(SelectionEvent e) {

...

}

});

button.setOnAction(event -> ...);

Page 17: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Migration UI

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

17

CSS Styling No simple CSS Styling

(applicationCSS)

Only theme-styling via CSS

Themes as OSGi declarative

services

Text {

color: green;

}

.text-field {

-fx-text-fill: green;

}

Page 18: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Further Information

AA-AS/EIS2-EU | 10/19/2015 | © Robert Bosch GmbH 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing,

distribution, as well as in the event of applications for industrial property rights.

SWT to JavaFX Migration

Automotive Service Solutions

18

SWT to JavaFX migration Dirk Fauth https://blog.codecentric.de/en/2015/02/

swt-javafx-migration-eclipse-rcp-

cookbook/

Migrate E4 RCP from SWT to

JavaFX using SWTonJavaFXChristoph Keimel http://www.kware.net/?p=64

Page 19: SWT to JavaFX Migration Dirk Fauth - EclipseCon France2018 · public class Main extends Application {@Override public void start(Stage primaryStage) {// build UI} public static void

Recommended