Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyEditors now subscribe to the item's ObservableValue even if the editor is read-only #1512

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2013, ControlsFX
* Copyright (c) 2023, ControlsFX
abhinayagarwal marked this conversation as resolved.
Show resolved Hide resolved
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -79,6 +79,15 @@ public AbstractPropertyEditor(Item property, C control) {
public AbstractPropertyEditor(Item property, C control, boolean readonly) {
this.control = control;
this.property = property;

property.getObservableValue().ifPresent(obs -> obs.addListener((ObservableValue<?> o, Object oldValue, Object newValue) -> {
if (!suspendUpdate) {
suspendUpdate = true;
AbstractPropertyEditor.this.setValue((T) property.getValue());
suspendUpdate = false;
}
}));

if (! readonly) {
getObservableValue().addListener((ObservableValue<? extends Object> o, Object oldValue, Object newValue) -> {
if (! suspendUpdate) {
Expand All @@ -87,17 +96,6 @@ public AbstractPropertyEditor(Item property, C control, boolean readonly) {
suspendUpdate = false;
}
});

if (property.getObservableValue().isPresent()) {
property.getObservableValue().get().addListener((ObservableValue<? extends Object> o, Object oldValue, Object newValue) -> {
if (! suspendUpdate) {
suspendUpdate = true;
AbstractPropertyEditor.this.setValue((T) property.getValue());
suspendUpdate = false;
}
});
}

}
}

Expand Down