JFXtras/jfxtras-labs — pull request #96 by CarrKnight (2014-04-26 22:10:50+00:00)
Title: HeterogeneousBidirectionalBinder

This is something of a prototype. It works and is tested. I found it useful in my fx project. Hopefully you'll think it's useful for yours.

BidirectionalBinding only works between two properties of the same type. I'd like Property and Property to be bound bidirectionally even if A and B are different.
I created a simple "binder" that listens to the changes in one property and updates the other. This way the two properties are bound.

The main weakness is that, while it works as the others BidirectionalBinding object, it doesn't extend the original class. The original class has private constructors. Moreover the original class works mostly by static methods in a, IMHO, very ugly fashion.
I think this BindER works more intuitively without static methods.

An example of when I needed to use this for my project is the following.
I have an ENUM describing the "mouse mode" over a certain node. Whether SELECT/DELETE/EDIT. Then I have a toggle button group where the user can change the mouse-mode. So obviously the mouse mode needs to be bound to the toggle group. But the mouse-mode can be changed also by key short-cuts, and I'd like the toggle group to notice that as well. So a Property and a Property needed to be bound bidirectionally.
The binder solved this for me.