package scheduler.view;

import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import scheduler.Main;

public class ViewCalendarController extends ViewScheduleController {
   @FXML
   private TableView<TimeRange> calendarTable;
   @FXML
   private TableColumn<TimeRange, String> range;
   @FXML
   private TableColumn<TimeRange, String> sunday;
   @FXML
   private TableColumn<TimeRange, String> monday;
   @FXML
   private TableColumn<TimeRange, String> tuesday;
   @FXML
   private TableColumn<TimeRange, String> wednesday;
   @FXML
   private TableColumn<TimeRange, String> thursday;
   @FXML
   private TableColumn<TimeRange, String> friday;
   @FXML
   private TableColumn<TimeRange, String> saturday;
   
   /**
    * The constructor. The constructor is called before the initialize() method.
    */
   public ViewCalendarController() {
   }
   
   /**
    * Initializes the controller class. This method is automatically called
    * after the fxml file has been loaded.
    */
   @FXML
   private void initialize() {
      // Initialize the person table with the two columns.
      range.setCellValueFactory(cellData -> cellData.getValue().rangeProperty());
      sunday.setCellValueFactory(cellData -> cellData.getValue().sundayProperty());
      monday.setCellValueFactory(cellData -> cellData.getValue().mondayProperty());
      tuesday.setCellValueFactory(cellData -> cellData.getValue().tuesdayProperty());
      wednesday.setCellValueFactory(cellData -> cellData.getValue().wednesdayProperty());
      thursday.setCellValueFactory(cellData -> cellData.getValue().thursdayProperty());
      friday.setCellValueFactory(cellData -> cellData.getValue().fridayProperty());
      saturday.setCellValueFactory(cellData -> cellData.getValue().saturdayProperty());
   }
   
   @FXML
   private void handleOpenAction() {
      System.out.println("Open clicked\n");
   }
   
   @FXML
   private void handleSaveAction() {
      System.out.println("Save clicked\n");
   }
   
   @FXML
   private void handleRatingAction() {
      System.out.println("Rating clicked");
   }
   
   /**
    * Is called by the main application to give a reference back to itself.
    * 
    * @param mainApp
    */
   public void setMainApp(Main mainApp) {
      super.setMainApp(mainApp);
      
      // Add observable list data to the table
      calendarTable.setItems(mainApp.getCalendarData());
   }
}