package task.timer.view;



import java.util.Calendar;

import javax.swing.Timer;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import task.timer.model.Record;

public class RecordsController {
	@FXML private TableView<Record> recordTable;
	@FXML private TableColumn<Record, Integer> userIdColumn;
	@FXML private TableColumn<Record, String> projectNameColumn;
	@FXML private TableColumn<Record, String> workNameColumn;
	@FXML private TableColumn<Record, Long> startTimeColumn;
	@FXML private TableColumn<Record, Long> stopTimeColumn;
	
	@FXML private Button startStopTime;
	@FXML private Label measuredTime;
	@FXML private ChoiceBox projectChoice;
	
	private int licznikCzasu;
	private Timer t;
	
	
	@FXML private void timing(){
		if (startStopTime.getText().equals("START")){
			startStopTime.setText("STOP");	
			projectChoice.setDisable(true);
			licznikCzasu=0;
			measuredTime.setText("0:0:0");
		
			t = new Timer(1000, e -> {				
				licznikCzasu++;
				int timeHour = licznikCzasu/3600;
				int reszta = licznikCzasu%3600;										
				int timeMinutes = reszta/60;
				int timeSeconds = reszta%60;
				
				Platform.runLater(() -> measuredTime.setText(timeHour + ":" + timeMinutes + ":" + timeSeconds));
			});
			
			t.start();
		}
				
		else {
			startStopTime.setText("START");
			t.stop();
			projectChoice.setDisable(false);
		}
	}

@FXML private void initialize(){

	measuredTime.setText("0:0:0");
	
	//recordTable.setTableMenuButtonVisible(true);
	
	/*	userIdColumn.setCellValueFactory(cellData -> 
			cellData.getValue().recordIdProperty().asObject());
	
	projectNameColumn.setCellValueFactory(cellData ->
			cellData.getValue().projectNameProperty());*/
}

}
@@ -866,41 +866,485 @@
 int 
-licznikCzasu;%0A%09private Timer t
+timeCounter;%0A%09private Timer time;%0A%09%0A%09%0A%09private void startTimeMeaserement(Label measuredTimeLabel)%7B%0A%09%09time = new Timer(1000, e -%3E %7B%09%09%09%09%0A%09%09%09timeCounter++;%0A%09%09%09int timeHour = timeCounter/3600;%0A%09%09%09int rest = timeCounter%253600;%09%09%09%09%09%09%09%09%09%09%0A%09%09%09int timeMinutes = rest/60;%0A%09%09%09int timeSeconds = rest%2560;%09%09%09%0A%09%09%09Platform.runLater(() -%3E measuredTime.setText(timeHour + %22:%22 + timeMinutes + %22:%22 + timeSeconds));%0A%09%09%7D);%09%09%0A%09%09time.start();%0A%09%7D%0A%09%0A%09private void stopTimeMeaserement()%7B%0A%09%09time.stop()
 ;%0A%09
+%7D
 %0A%09%0A%09
@@ -1493,28 +1493,27 @@
 ue);%0A%09%09%09
-licznikCzasu
+timeCounter
 =0;%0A%09%09%09m
@@ -1548,348 +1548,54 @@
 ;%0A%09%09
-%0A%09%09%09t = new Timer(1000, e -%3E %7B%09%09%09%09%0A%09%09%09%09licznikCzasu++;%0A%09%09%09%09int timeHour = licznikCzasu/3600;%0A%09%09%09%09int reszta = licznikCzasu%253600;%09%09%09%09%09%09%09%09%09%09%0A%09%09%09%09int timeMinutes = reszta/60;%0A%09%09%09%09int timeSeconds = reszta%2560;%0A%09%09%09%09%0A%09%09%09%09Platform.runLater(() -%3E measuredTime.setText(timeHour + %22:%22 + timeMinutes + %22:%22 + timeSeconds));%0A%09%09%09%7D);%0A%09%09%09%0A%09%09%09t.start();
+%09%0A%09%09%09startTimeMeaserement(measuredTime);%09%09
 %0A%09%09%7D
-%0A
 %09%09%09%09
@@ -1646,14 +1646,27 @@
 %0A%09%09%09
-t.
 stop
+TimeMeaserement
 ();%0A

extract new methods: startTimeMeaserement and stopTimeMEasurement