javafx @ eclipse · ‣l10n-dsl: if you java8, e4 and want dynamic language flipping ‣rrobot-dsl:...

97
JavaFX @ eclipse.org Tom Schindl <[email protected]> Twitter: @tomsontom Blog: http://tomsondev.bestsolution.at Website: http://www.bestsolution.at

Upload: others

Post on 22-Jun-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

JavaFX @ eclipse.org

Tom Schindl <[email protected]>

Twitter: @tomsontomBlog: http://tomsondev.bestsolution.atWebsite: http://www.bestsolution.at

Page 2: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

About Me‣ CTO BestSolution.at Systemhaus GmbH

‣ Eclipse Committer

‣ e4

‣ Platform

‣ EMF

‣ Project lead

‣ e(fx)clipse

‣ Twitter: @tomsontom

‣ Blog: tomsondev.bestsolution.at

‣ Cooperate: http://bestsolution.at

Page 3: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Page 4: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Tooling

Page 5: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Tooling News 1.0 - 1.2‣ CSS-Editor - Add gradient editor

Page 6: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Tooling News 1.0 - 1.2‣ CSS-Editor - Add gradient editor

Page 7: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ CSS-Editor - Support for custom controls

Tooling News 1.0 - 1.2

Page 8: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ Java-Editor - Wizard to generate JavaFX Getter/setters

Tooling News 1.0 - 1.2

Page 9: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ Java-Editor - Wizard to generate JavaFX Getter/setters

Tooling News 1.0 - 1.2

Page 10: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ FXML-Editor - Generating controller stub

Tooling News 1.0 - 1.2

Page 11: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Reuseable Tooling

Page 12: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Components for reuse

Page 13: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Components for reuse‣ l10n-DSL: if you Java8, e4 and want dynamic language flipping

Page 14: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Components for reuse‣ l10n-DSL: if you Java8, e4 and want dynamic language flipping

‣ RRobot-DSL: allows you to describe eclipse-project setups

Page 15: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Components for reuse‣ l10n-DSL: if you Java8, e4 and want dynamic language flipping

‣ RRobot-DSL: allows you to describe eclipse-project setups

‣ LivePreview: Reuse the live preview to present your textual content in a visual way

Page 16: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Components for reuse‣ l10n-DSL: if you Java8, e4 and want dynamic language flipping

‣ RRobot-DSL: allows you to describe eclipse-project setups

‣ LivePreview: Reuse the live preview to present your textual content in a visual way

‣ CSSExt-DSL: allows you to define your custom CSS-Properties

Page 17: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

l10n

Page 18: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

l10n-DSL

Page 19: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DSL to define translations

l10n-DSL

Page 20: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DSL to define translations

‣ Uses Xtext

l10n-DSL

Page 21: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DSL to define translations

‣ Uses Xtext

‣ Generates code and text files

l10n-DSL

Page 22: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DSL to define translations

‣ Uses Xtext

‣ Generates code and text files

‣ Requires Java8

‣ Makes use of Java8 functional interfaces and method references

l10n-DSL

Page 23: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

l10n-DSL‣ DSL to store language definitions

package sample.l10n.app.themes {bundle BasicMessages default en {

HelloWorld {en : '''Hello World''',de : '''Hallo Welt'''

}}bundle SamplePartMessages default en {

Button_title [ BasicMessages.HelloWorld ]Current_Date(DATE now) {

en : '''«now "MM/dd/yyyy"»''',de : '''«now "dd.MM.yyyy"»'''

}}

}

Page 24: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

l10n-DSL‣ Generated artifacts

‣ ${bundle}.java: e4 message class

‣ ${bundle}.properties: Default transalations

‣ ${bundle}_${lang}.properties: Translations for the lang

‣ ${bundle}Registry.java: Registry to use for binding

Page 25: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ Use in code (Sample JavaFX)

l10n-DSL

package sample.l10n.app.themes;

public class SamplePart {@InjectSamplePartMessagesRegistry messagesReg;

@PostConstructvoid init(BorderPane pane) {

Button b = new Button();messagesReg.register(b::setText, messagesReg::Button_title);pane.setCenter(b);

Label l = new Label();messagesReg.register(b::setText,

messagesReg.Current_Date_supplier(new Date()));pane.setTop(l);

}}

Page 26: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ Use in code (Sample SWT)

l10n-DSL

package sample.l10n.app.themes;

public class SamplePart {@InjectSamplePartMessagesRegistry messagesReg;

@PostConstructvoid init(Composite pane) {

Button b = new Button(pane,SWT.PUSH);messagesReg.register(b::setText, messagesReg::Button_title);

Label l = new Label(pane,SWT.NONE);messagesReg.register(b::setText,

messagesReg.Current_Date_supplier(new Date()));}

}

Page 27: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Demo (Elementary)

Page 28: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

RRobot-DSL

Page 29: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

RRobot-DSL‣ DSL to describe Eclipse project setups

Page 30: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

RRobot-DSL‣ DSL to describe Eclipse project setups

‣ Uses Xtext

Page 31: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

RRobot-DSL‣ DSL to describe Eclipse project setups

‣ Uses Xtext

‣ Allows to setup

‣ JDT Projects

‣ PDE-Projects Bundles & Features

Page 32: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

RRobot-DSLRobotTask {

// Variables to be used later onvariables = {

## Name of the bundleSTRING "BundleName" default "econsample"

}projects = {

BundleProject "${BundleName}" {manifest = ManifestFile "${BundleName}" "1.0.0" "JavaSE-1.8" {

bundlename = "${BundleName}"vendor = "BestSolution.at"

}build = BuildProperties {

}resources = {

Folder "src"}rootfragments = {

fragment "default-src" "src"}

}}

}

Page 33: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Demo (Run Task)

Page 34: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

LivePreview

Page 35: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

LivePreview‣ LivePreview was developed for FXML/FXGraph immediate feedback

Page 36: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

LivePreview‣ LivePreview was developed for FXML/FXGraph immediate feedback

‣ Expects FXML passed

Page 37: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

LivePreview‣ LivePreview was developed for FXML/FXGraph immediate feedback

‣ Expects FXML passed

‣ LivePreview requests FXML from editors who adapt to IFXMLProviderAdapter

Page 38: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Demo (Elemenatry & Lego-DSL & FXML-

Viewer)

Page 39: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

LivePreviewpublic class FXMLProviderAdapter implements IFXMLProviderAdapter {

private XtextEditor editor;

public FXMLProviderAdapter(XtextEditor editor) {this.editor = editor;

}

@Overridepublic IEditorPart getEditorPart() {

return editor;}

@Overridepublic String getPreviewFXML() {

return editor.getDocument().readOnly(new IUnitOfWork<String, XtextResource>() {

@Overridepublic String exec(XtextResource resource) throws Exception {

Injector injector = LegoActivator.getInstance().getInjector("at.bestsolution.lego.Lego");PreviewGenerator generator = injector.getInstance(PreviewGenerator.class);return generator.generatePreview((Model) resource.getContents().get(0)).toString();

}

});}

Page 40: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

CSSExt-DSL

Page 41: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

CSSExt-DSL‣ CSS-Editor has NO hard coded properties

Page 42: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

CSSExt-DSL‣ CSS-Editor has NO hard coded properties

‣ Properties available are defined in an extra file ending with .cssext

Page 43: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

CSSExt-DSL‣ CSS-Editor has NO hard coded properties

‣ Properties available are defined in an extra file ending with .cssext

‣ CSS-Editor looks up .cssext-Files from projects classpath

Page 44: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

package svg {prop_alignment-baseline = [ auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | inherit ];

/** * */tspan {

/** * Documentation */alignment-baseline <prop_alignment-baseline> default: auto;

}}

CSSExt-DSL

Page 45: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Demo (SVG-CSS-Properties)

Page 46: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Page 47: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Runtime

Page 48: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Components for reuse

Page 49: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DI-Extensions: @Log, @ContextValue, @Service

Components for reuse

Page 50: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DI-Extensions: @Log, @ContextValue, @Service

‣ Filesystem-Service

Components for reuse

Page 51: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ DI-Extensions: @Log, @ContextValue, @Service

‣ Filesystem-Service

‣ Controls

‣ Filesystem controls

‣ StyledText & JFace-Text-Port

Components for reuse

Page 52: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API

Page 53: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API‣ Simple slf4j like API

‣ Used internally by e(fx)clipse runtime

‣ Implementation provided as an OSGi-Service/ServiceLoader

Page 54: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API‣ Simple slf4j like API

‣ Used internally by e(fx)clipse runtime

‣ Implementation provided as an OSGi-Service/ServiceLoader

‣ Multiple ways to consume

‣ Through OSGi-Service-Registry

‣ Through a factory

‣ Through DI with @Log

Page 55: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API

Page 56: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API

@Componentpublic class OSGiComponent {

private Logger logger;

@Referencepublic synchronized void setLoggerFactory(LoggerFactory factory) {

this.logger = factory.createLogger(OSGiComponent.class.getName());}

}

OSGi-Component

Page 57: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API

public class DIComponent {@Inject@Logprivate Logger logger;

}

Eclipse-DI

@Componentpublic class OSGiComponent {

private Logger logger;

@Referencepublic synchronized void setLoggerFactory(LoggerFactory factory) {

this.logger = factory.createLogger(OSGiComponent.class.getName());}

}

OSGi-Component

Page 58: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Log & Logger-API

public class DIComponent {@Inject@Logprivate Logger logger;

}

Eclipse-DI

public class PlainJava {private static Logger logger = LoggerCreator.createLogger(PlainJava.class);

}

Plain Java

@Componentpublic class OSGiComponent {

private Logger logger;

@Referencepublic synchronized void setLoggerFactory(LoggerFactory factory) {

this.logger = factory.createLogger(OSGiComponent.class.getName());}

}

OSGi-Component

Page 59: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ Current shipped backends

‣ java.util.logging (default)

‣ log4j

‣ slf4j

@Log & Logger-API

Page 60: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@ContextValue‣ Allows you to abstract away IEclipseContext#modify

Page 61: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@ContextValue‣ Allows you to abstract away IEclipseContext#modify

public class ValuePublisherComponent {

@Injectprivate IEclipseContext context;

public void publishContext() {ListView<String> values = new ListView<>();values.getSelectionModel().selectedItemProperty().addListener( (o,newVal,oldVal) -> value.modify("contextValue",newVal));

}}

Page 62: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@ContextValue‣ Allows you to abstract away IEclipseContext#modify

public class ValuePublisherComponent {

@Injectprivate IEclipseContext context;

public void publishContext() {ListView<String> values = new ListView<>();values.getSelectionModel().selectedItemProperty().addListener( (o,newVal,oldVal) -> value.modify("contextValue",newVal));

}}

public class ValuePublisherComponent {@Inject@ContextValue("contextValue")private ContextBoundValue<String> value;

public void publishContext() {ListView<String> values = new ListView<>();values.getSelectionModel().selectedItemProperty().addListener( (o,newVal,oldVal) -> value.publish(newVal));

}}

Page 63: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@ContextValue‣ Allows you to abstract away IEclipseContext#modify

public class ValuePublisherComponent {

@Injectprivate IEclipseContext context;

public void publishContext() {ListView<String> values = new ListView<>();values.getSelectionModel().selectedItemProperty().addListener( (o,newVal,oldVal) -> value.modify("contextValue",newVal));

}}

public class ValuePublisherComponent {@Inject@ContextValue("contextValue")private ContextBoundValue<String> value;

public void publishContext() {ListView<String> values = new ListView<>();values.getSelectionModel().selectedItemProperty().addListener( (o,newVal,oldVal) -> value.publish(newVal));

}}

public class ValuePublisherComponent {@Inject@ContextValue("contextValue")private Property<String> value;

public void publishContext() {ListView<String> values = new ListView<>();fxProperty.bind(values.getSelectionModel().selectedItemProperty());

}}

Page 64: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Service

Page 65: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

@Service‣ Eclipse DI by default does NOT conform to OSGi-Service semantics

‣ Services can come and go

‣ Requestor of services is important if a ServiceFactory is used

Page 66: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

public class DIServiceConsumer {@Injectpublic void setServices(@Service List<LoggerFactory> serviceList) {

}

@Injectpublic void setServices(@Service LoggerFactory serviceList) {

}}

@Service

Page 67: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Fileystem Service‣ Service on top of NIO2 low level API

Page 68: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Fileystem Service‣ Service on top of NIO2 low level API

public class FilesystemSample extends Application {

@Overridepublic void start(Stage primaryStage) throws Exception {

FilesystemService fs = Util.lookupService(FilesystemSample.class, FilesystemService.class);Subscription observePath = fs.observePath(Paths.get(URI.create("file:/Users/tomschindl")), (k,p) -> {

System.err.print("filesystem item '"+p+"' has been ");switch (k) {case CREATE:

System.err.println("created.");break;

case DELETE:System.err.println("deleted.");break;

default:System.err.println("modified.");break;

}});

// .....observePath.dispose();

}

}

Page 69: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Filesystem controls

Page 70: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Filesystem controlsFo

lder

Vie

wer

Page 71: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Filesystem controlsFo

lder

Vie

wer

Folder Content Viewer

Page 72: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Filesystem controlsFo

lder

Vie

wer

Folder Content Viewer

File

Con

tent

Vie

wer

Page 73: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

StyledText APIs‣ Non Editable Text: StyledLabel & StyledString

Page 74: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

StyledText APIs‣ Non Editable Text: StyledLabel & StyledString

StyledString s = new StyledString();s.appendSegment("Hello", "h1");s.appendSegment("World!", "h1","colorful");

StyledLabel label = new StyledLabel(s);

Page 75: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

StyledText APIs‣ Non Editable Text: StyledLabel & StyledString

StyledString s = new StyledString();s.appendSegment("Hello", "h1");s.appendSegment("World!", "h1","colorful");

StyledLabel label = new StyledLabel(s);.h1 {

-fx-font-size: 20pt;}

.colorful {-fx-font-weight: bold;-fx-fill: linear-gradient( from 0.0% 0.0% to 100.0% 100.0%, rgb(128,179,128)

0.0, rgb(255,179,102) 100.0);}

Page 76: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ StyledText in List/Table/TreeView

StyledText APIs

Page 77: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ StyledText in List/Table/TreeView

StyledText APIs

public interface OutlineItem {public CharSequence getLabel();public Node getGraphic();public OutlineItem getParent();public ObservableList<OutlineItem> getChildren();

}

Page 78: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

‣ StyledText in List/Table/TreeView

StyledText APIs

public interface OutlineItem {public CharSequence getLabel();public Node getGraphic();public OutlineItem getParent();public ObservableList<OutlineItem> getChildren();

}private TreeView<OutlineItem> createView() {TreeView<OutlineItem> outlineView = new TreeView<>();outlineView.setShowRoot(false);outlineView.setCellFactory(this::createCell);return outlineView;

}

TreeCell<OutlineItem> createCell(TreeView<OutlineItem> param) {return new SimpleTreeCell<OutlineItem>(i -> i.getLabel(), i -> i.getGraphic(), i -> Collections.emptyList());

}

Page 79: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

StyledText APIs‣ Editable StyledText

Page 80: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

StyledText APIs‣ Editable StyledText

StyledTextArea t = new StyledTextArea();t.getContent().setText("package test;\n\n…");t.setStyleRanges(new StyleRange("keyword",0,6,null,null),/* */);

Page 81: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

StyledText APIs‣ Editable StyledText

StyledTextArea t = new StyledTextArea();t.getContent().setText("package test;\n\n…");t.setStyleRanges(new StyleRange("keyword",0,6,null,null),/* */);

.keyword {-styled-text-color: rgb(127, 0, 85);-fx-font-weight: bold;

}

Page 82: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator

Page 83: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator

Page 84: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator‣ Mission 0: Must look slick!

Page 85: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator‣ Mission 0: Must look slick!

‣ Mission 1: Create a simple source editor like Notepad++ who:

‣ Is process light-weight

‣ Makes it easy to add new language highlightings

Page 86: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator‣ Mission 0: Must look slick!

‣ Mission 1: Create a simple source editor like Notepad++ who:

‣ Is process light-weight

‣ Makes it easy to add new language highlightings

‣ Mission 2: Allow the simple source editor to expand to a (simple) IDE:

‣ where Source-Editor, VCS (git), Ticketsystem (eg. github), CI (eg. travis) are core components fully integrated with each other

‣ Easy to integrate: Does not depend on core.resources

Page 87: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator

Page 88: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator

Page 89: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Demo (Basic-Editor + Python

install)

Page 90: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator - HSL+CSS

Page 91: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Python { partition __dftl_partition_content_type partition __python_multiline_comment partition __python_singleline_comment partition __python_string rule_damager rule_damager __dftl_partition_content_type { default token python_default token python_string token python_operator token python_bracket token python_keyword_return token python_keyword keywords python_keyword_return [ "return" ] keywords python_keyword [ "and", "as", „assert", /* … */] } rule_damager __python_singleline_comment { default token python_single_line_comment } /* … */ rule_partitioner { single_line __python_string '"' => '"' single_line __python_singleline_comment "#" multi_line __python_multiline_comment "'''" => "'''" single_line __python_string "'" => "'" }} for "text/python"

Compensator - HSL+CSS

Page 92: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Python { partition __dftl_partition_content_type partition __python_multiline_comment partition __python_singleline_comment partition __python_string rule_damager rule_damager __dftl_partition_content_type { default token python_default token python_string token python_operator token python_bracket token python_keyword_return token python_keyword keywords python_keyword_return [ "return" ] keywords python_keyword [ "and", "as", „assert", /* … */] } rule_damager __python_singleline_comment { default token python_single_line_comment } /* … */ rule_partitioner { single_line __python_string '"' => '"' single_line __python_singleline_comment "#" multi_line __python_multiline_comment "'''" => "'''" single_line __python_string "'" => "'" }} for "text/python"

Compensator - HSL+CSS

/* */.Python.styled-text-area .python_doc_default {

-styled-text-color: rgb(63, 95, 191);}

.Python.styled-text-area .python_single_line_comment {-styled-text-color: rgb(63, 127, 95);

}/* */

Page 93: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Demo

Page 94: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Page 95: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Page 96: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator

Page 97: JavaFX @ eclipse · ‣l10n-DSL: if you Java8, e4 and want dynamic language flipping ‣RRobot-DSL: allows you to describe eclipse-project setups ‣LivePreview: Reuse the live preview

(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0

Compensator - Roadmap‣ Tighter integration with git workflow

‣ Improve Java autocomplete & Error Annotations

‣ Support for JavaScript auto-complete & error reporting

‣ Support for Xtext-Languages (their upcoming IntelliJ support should help us)

‣ Connect it to Flux to get a Flux Compensator