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 Nov 7, 2023
1 parent bf04d27 commit 29d40fa
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 29d40fa

Please sign in to comment.