fix: при ручном измененнии значений Spinner не обновлял данные
This commit is contained in:
@@ -8,6 +8,7 @@ import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ru.dmitriymx.corrector1s.Corrector1S;
|
||||
|
||||
@@ -105,10 +106,32 @@ public class MainController {
|
||||
return alert;
|
||||
}
|
||||
|
||||
private <T> void commitEditorText(Spinner<T> spinner) {
|
||||
if (!spinner.isEditable()) return;
|
||||
String text = spinner.getEditor().getText();
|
||||
SpinnerValueFactory<T> valueFactory = spinner.getValueFactory();
|
||||
if (valueFactory != null) {
|
||||
StringConverter<T> converter = valueFactory.getConverter();
|
||||
if (converter != null) {
|
||||
T value = converter.fromString(text);
|
||||
valueFactory.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
honorarium.setValueFactory(honorariumValueFactory);
|
||||
honorarium.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue) return; // what?
|
||||
commitEditorText(honorarium);
|
||||
});
|
||||
|
||||
fss.setValueFactory(fssValueFactory);
|
||||
fss.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue) return; // what?
|
||||
commitEditorText(fss);
|
||||
});
|
||||
|
||||
saveAsCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
saveAsFilePath.setDisable(!newValue);
|
||||
|
||||
Reference in New Issue
Block a user