package ch.zhaw.gartenverwaltung;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class TextFieldFormularController {

    @FXML
    private Label description_label;

    @FXML
    private TextField text_area;


    public void setDescription_label(String string) {
        description_label.setText(string);
    }

    public void setValueTextArea(String string) {
        text_area.setText(string);
    }

    public String getValue() {
        return text_area.getText();
    }

    public void initSaveButton(Button button) {
        text_area.textProperty().addListener((observable, oldValue, newValue) -> {
            if (newValue.matches("\\d*\\.?\\d*")) {
                text_area.setText(newValue);
            } else {
                text_area.setText(oldValue);
            }
        });

        button.disableProperty().bind(text_area.textProperty().isEmpty());
    }

}
