Xtend, JavaFX-Properties and operator overloading

JavaFX has properties you can bind to each other to keep them insync. Watch this video for a very minimal example which scales a text by dragging a slider.

Now let’s look at the Xtend code used to write this small sample

The important lines are:

// Bidirectional binding between sliders
sl_1.valueProperty .. sl_2.valueProperty;

// Unidirectional binding from slider to scaleX/Y
l.scaleXProperty -> sl_2.valueProperty;
l.scaleYProperty -> sl_2.valueProperty;

The trick here to make this code not as verbose as it’s java counterpart is that Xtend allows to overload operators (+, -, ->, .., …).

What I don’t fully understand is why I can’t define my operator overloading like this:

def static <T> operator_mappedTo(Property<T> x, ObservableValue<? extends T> y) {
  x.bind(y);
}

which should work when looking at the inheritance hierarchy of DoubleProperty, maybe some Xtend guru can explain it to me ;-)

Talks and Democamps (Eclipse 4, e(fx)clipse and JavaFX)

I’m back from a very nice trip to Cluj, Romania where I took part at the DemoCamp on Friday.

For those who are interested here are the slides of my talks:

The Eclipse 4 talk is a similar to the one I did at “EclipseDay Florence” where the organizers recorded a video of my talk and others as well.

For those JavaFX interested folks reading my blog – if you fast forward to minute 21 you see an e4 application running on JavaFX sycned live with a SWT/JavaFX mashup e4 application using CDO.

In the next 2 demo camps this I’ll show e(fx)clipse in action:

I hope you to see you at one of those events – afterwards it’s time for holiday.

Almost totally crazy?

So there’s a comment on my JDT and JavaFX blog asking if it is possible to have an SWT-Port which uses JavaFX. So its time to present an even crazier thing than using JavaFX to build an IDE!

You are right I did already explored what the comment requests. I’ve started a proof-of-concept implementation of SWT ontop of JavaFX. Like all SWT-Ports everything starts with the control example.

I’ve only hacked for 1 or 2 days and this is what I have already.

This slideshow requires JavaScript.

Now where to go from here? Frankly, I’m not sure yet. I’ve always pushed hard that e4 is not depending on SWT so for new applications it is not really needed. JavaFX misses some controls (most prominent StyledText) and support things like OwnerDraw in table/trees is extremly hard to implement (read maybe impossible). I think a feasable target is to implement the same level of API, RAP has implemented today.

Anyways such a port needs funding to get implemented so if there are companies out there who want to see such a thing happening:

  • Start with my proof-of-concept and put your engineers on it
  • Hire us (BestSolution.at) to do it for you and the rest of the world

Sources are as always released under EPL.

You can take a look at them in my github repo at https://github.com/tomsontom/e-fx-clipse/tree/master/at.bestsolution.efxclipse.runtime.swt

About mixing and matching JDT and JavaFX

What is the result of mixing JDT and JavaFX into one project? Right you get an Java-IDE :-) You don’t believe me? Then watch this short video.

Freaking cool but how did I managed to get this work. First all of the whole thing is not a fake. I used different OpenSource technologies to make this work.

  1. JDT-Core: Correct JDT-Core is the same you use everyday in your eclipse, it provides you the incremental compiler, launch and debug support, …
  2. JavaFX: Right i used FX as the UI technology – it’s an experiment
  3. e4-core: For DI I used e4 stuff
  4. Equinox: Correct the whole thing is mixed together using OSGi
  5. e(fx)clipse-runtime: To make JavaFX run in OSGi, I used stuff from my e(fx)clipse project

Finally the big mystery where the hell is this nice editor coming from? First of JavaFX has no such nice control as SWTs StyledText but what it has is a Webkit-Browser and Java/JavaScript integration. So guess what the the editor you are seeing there is the one developed by the Orion project at Eclipse.org – no joke!

Packaging up the whole thing into a product without JavaFX the size is ~25MB – if packaging JavaFX so that you get a “crossplatform-no-prerequist” product the size would be ~92MB.