FXMisc / UndoFX

Undo manager for JavaFX
BSD 2-Clause "Simplified" License
98 stars 17 forks source link

Change return ObservableBooleanValue to BooleanExpression or BooleanBinding #4

Closed ruckc closed 9 years ago

ruckc commented 9 years ago

Can you change the return results for undoAvailableProperty and redoAvailableProperty to BooleanExpression or BooleanBinding? This would simplify binding Button.disableProperty().bind(UndoManager.undoAvailableProperty().not()) in RichTextFX

TomasMikula commented 9 years ago

It cannot be BooleanBinding, since that would expose methods like dispose() or invalidate().

I could change it to BooleanExpression for the convenience, but I feel the type BooleanExpression became obsolete with the advent of default methods in Java 8: all its methods could be moved up to ObservableBooleanValue interface as default methods. I would expect this to happen in some future JavaFX version.

TomasMikula commented 9 years ago

Also, I think this is not too bad:

import static javafx.beans.binding.Bindings.not;

button.disableProperty().bind(not(undoManager.undoAvailableProperty()));

Btw, Bindings.not() is exactly how BooleanExpression.not() is implemented in JavaFX.

ruckc commented 9 years ago

That is an elegant way, i was just trying to avoid the cast, and that does it.

On Mon Dec 15 2014 at 10:39:12 AM TomasMikula notifications@github.com wrote:

Also, I think this is not too bad:

import static javafx.beans.binding.Bindings.not;

button.disableProperty().bind(not(undoManager.undoAvailableProperty()));

Btw, Bindings.not() is exactly how BooleanExpression.not() is implemented in JavaFX.

— Reply to this email directly or view it on GitHub https://github.com/TomasMikula/UndoFX/issues/4#issuecomment-67012251.