Skip to content

Commit

Permalink
PropertySheet editors now subscribe to the item's ObservableValue eve…
Browse files Browse the repository at this point in the history
…n if the editor is read-only
  • Loading branch information
Frederik Kammel committed Jul 26, 2023
1 parent d141298 commit 7ab8798
Showing 1 changed file with 11 additions and 11 deletions.
Expand Up @@ -79,6 +79,17 @@ public AbstractPropertyEditor(Item property, C control) {
public AbstractPropertyEditor(Item property, C control, boolean readonly) {
this.control = control;
this.property = property;

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;
}
});
}

if (! readonly) {
getObservableValue().addListener((ObservableValue<? extends Object> o, Object oldValue, Object newValue) -> {
if (! suspendUpdate) {
Expand All @@ -87,17 +98,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

0 comments on commit 7ab8798

Please sign in to comment.