use of javafx.beans.property.ReadOnlyBooleanProperty in project VocabHunter by VocabHunter.
the class SettingsController method initialiseField.
private void initialiseField(final TextField field, final Supplier<Object> settingGetter) {
StringProperty textProperty = field.textProperty();
ReadOnlyBooleanProperty focusedProperty = field.focusedProperty();
field.setText(settingGetter.get().toString());
textProperty.addListener((o, oldValue, newValue) -> cleanNonNegativeInteger(field::setText, newValue, oldValue));
focusedProperty.addListener((o, old, isFocused) -> applyDefaultIfEmpty(field::setText, field::getText, settingGetter));
}
use of javafx.beans.property.ReadOnlyBooleanProperty in project bitsquare by bitsquare.
the class TraderDisputeView method getStateColumn.
private TableColumn<Dispute, Dispute> getStateColumn() {
TableColumn<Dispute, Dispute> column = new TableColumn<Dispute, Dispute>("State") {
{
setMinWidth(50);
}
};
column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
@Override
public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
return new TableCell<Dispute, Dispute>() {
public ReadOnlyBooleanProperty closedProperty;
public ChangeListener<Boolean> listener;
@Override
public void updateItem(final Dispute item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
listener = (observable, oldValue, newValue) -> {
setText(newValue ? "Closed" : "Open");
getTableRow().setOpacity(newValue ? 0.4 : 1);
};
closedProperty = item.isClosedProperty();
closedProperty.addListener(listener);
boolean isClosed = item.isClosed();
setText(isClosed ? "Closed" : "Open");
getTableRow().setOpacity(isClosed ? 0.4 : 1);
} else {
if (closedProperty != null) {
closedProperty.removeListener(listener);
closedProperty = null;
}
setText("");
}
}
};
}
});
return column;
}
use of javafx.beans.property.ReadOnlyBooleanProperty in project bisq-desktop by bisq-network.
the class TraderDisputeView method getStateColumn.
private TableColumn<Dispute, Dispute> getStateColumn() {
TableColumn<Dispute, Dispute> column = new AutoTooltipTableColumn<Dispute, Dispute>(Res.get("support.state")) {
{
setMinWidth(50);
}
};
column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
@Override
public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
return new TableCell<Dispute, Dispute>() {
public ReadOnlyBooleanProperty closedProperty;
public ChangeListener<Boolean> listener;
@Override
public void updateItem(final Dispute item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
listener = (observable, oldValue, newValue) -> {
setText(newValue ? Res.get("support.closed") : Res.get("support.open"));
getTableRow().setOpacity(newValue ? 0.4 : 1);
};
closedProperty = item.isClosedProperty();
closedProperty.addListener(listener);
boolean isClosed = item.isClosed();
setText(isClosed ? Res.get("support.closed") : Res.get("support.open"));
getTableRow().setOpacity(isClosed ? 0.4 : 1);
} else {
if (closedProperty != null) {
closedProperty.removeListener(listener);
closedProperty = null;
}
setText("");
}
}
};
}
});
return column;
}
Aggregations