<commit_before>package sample;

import com.jfoenix.controls.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ListCell;
import javafx.scene.input.MouseEvent;
import javafx.util.StringConverter;

import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ResourceBundle;

public class Controller implements Initializable {

    @FXML
    private JFXListView reservations;

    @FXML
    private JFXTextField userName;

    @FXML
    private JFXComboBox<Room> rooms;

    @FXML
    private JFXDatePicker startDate;

    @FXML
    private JFXTimePicker startTime;

    @FXML
    private JFXDatePicker endDate;

    @FXML
    private JFXTimePicker endTime;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        startTime.setIs24HourView(true);
        endTime.setIs24HourView(true);

        ObservableList<Room> items = loadRooms();
        rooms.setItems(items);

        rooms.setCellFactory((JFXComboBox) -> {
            return new ListCell<Room>() {
                @Override
                protected void updateItem(Room item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty) {
                        setText(null);
                    } else {
                        setText(item.getRoom_number());
                    }
                }
            };
        });

        rooms.setConverter(new StringConverter<Room>() {
            @Override
            public String toString(Room object) {
                if (object == null) {
                    return null;
                } else  {
                    return object.getRoom_number();
                }
            }

            @Override
            public Room fromString(String string) {
                return null;
            }
        });

//        reservations.setOnMouseClicked((event) -> {
//            loadReservation((int)reservations.getSelectionModel().getSelectedItem());
//        });

    }

    private ObservableList<Room> loadRooms() {
        ObservableList<Room> items = FXCollections.observableArrayList();
        Statement statement = MySqlConnector.getInstance().getNewStatement();
        ResultSet resultSet = null;
        try {
            resultSet = statement.executeQuery("SELECT * FROM `rr_rooms` ORDER BY `room_number` ASC");
            while (resultSet.next()) {
                items.add(new Room(
                        resultSet.getInt("id"),
                        resultSet.getString("room_number"),
                        resultSet.getInt("room_seats"),
                        resultSet.getInt("type")));
            }
        } catch (SQLException e) {<commit_msg>file updated: new nameChecker method, buttons added<commit_after>package sample;

import com.jfoenix.controls.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ListCell;
import javafx.util.StringConverter;

import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ResourceBundle;

import static sample.Utils.nameChecker;

public class Controller implements Initializable {

    @FXML
    private JFXListView reservations;

    @FXML
    private JFXTextField userName;

    @FXML
    private JFXComboBox<Room> rooms;

    @FXML
    private JFXDatePicker startDate;

    @FXML
    private JFXTimePicker startTime;

    @FXML
    private JFXDatePicker endDate;

    @FXML
    private JFXTimePicker endTime;

    @FXML
    private JFXButton saveReservation;

    @FXML
    private JFXButton deleteReservation;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        startTime.setIs24HourView(true);
        endTime.setIs24HourView(true);

        ObservableList<Room> items = loadRooms();
        rooms.setItems(items);

        rooms.setCellFactory((JFXComboBox) -> {
            return new ListCell<Room>() {
                @Override
                protected void updateItem(Room item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty) {
                        setText(null);
                    } else {
                        setText(item.getRoom_number());
                    }
                }
            };
        });

        rooms.setConverter(new StringConverter<Room>() {
            @Override
            public String toString(Room object) {
                if (object == null) {
                    return null;
                } else  {
                    return object.getRoom_number();
                }
            }

            @Override
            public Room fromString(String string) {
                return null;
            }
        });

//        reservations.setOnMouseClicked((event) -> {
//            loadReservation((int)reservations.getSelectionModel().getSelectedItem());
//        });

//        saveReservation.setDisable(false);

        userName.setOnKeyReleased(event -> {
            nameChecker(userName);
        });

    }

    private ObservableList<Room> loadRooms() {
        ObservableList<Room> items = FXCollections.observableArrayList();
        Statement statement = MySqlConnector.getInstance().getNewStatement();
        ResultSet resultSet = null;
        try {
            resultSet = statement.executeQuery("SELECT * FROM `rr_rooms` ORDER BY `room_number` ASC");
            while (resultSet.next()) {
                items.add(new Room(
                        resultSet.getInt("id"),
                        resultSet.getString("room_number"),
                        resultSet.getInt("room_seats"),
                        resultSet.getInt("type")));
            }
        } catch (SQLException e) {
{'fraction_non_alphanumeric': 0.09362680683311432, 'fraction_numerical': 0.001314060446780552, 'mean_word_length': 1.9231877100336054, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4197383', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1549, 'n_words': 322}