Author: Bashan Zuo
Last modified: Dec 18 2019



-------------------------------------------------Introduction-----------------------------------------------------------
Those controllers act as an interface between Model and View. It handle user input, submit the request to
corresponding model routine to process, get back some results and render the certain information/UI based on the return
result.



----------------------------------------What's inside a controller------------------------------------------------------
The controller name is registered with its corresponding fxml file, denoted as fx:controller="controller
.CompileController", such registration could be done with JavaFX Scene Builder. In Egtapi project, each controller has
one corresponding fxml file:
    e.g: CompileController  =>  CompileView.fxml
         TurninController   =>  TurninView.fxml

@FXML annotated fields are UI component that associated specific UI component itself, you need to make sure that the
field name is the same as the fx:id name you set in JavaFx Scene Builder. You don't need to declare @FXML annotated
field and give fx:id for a component unless you need to control the component through the controller.

@FXML annotated functions are action that associated specific UI component's "On Action", "On Action" is set by JavaFx
Scene Builder, essentially it is just a event handler. You give the name of the function to the event handler so when
user trigger the UI, it knows where to execute the code.

The @FXML annotated initialize() function is to initialize the dynamic/static contents because those contents cannot be
initialized with FXML, for example: the dropdown menu needs to be filled during the initialization. Some of the time
consuming jobs are get submitted to other routine during the initialize() call. Some event listener needs to be
registered during the initialization. The initialize() method will be only called once, at the beginning of the
controller's loading process.

Some of the controllers have a public close() function. The close() function should guarantee that the window quit
gracefully. The close() function can be called from inside of a controller or it can be registered with
setOnCloseRequest() to handle windows default close action.



--------------------------------------------Controller's lifecycle------------------------------------------------------
When FXML loader load certain fxml file, it check the syntax error of the FXML file, then the controller's constructor
method get called first, then any @FXML annotated fields are populated, then initialize() is called. The initialize()
method will be only called once, after the content of its associated document(fxml) have been completely loaded.
Note: Controller's constructor function will be called before initialize(). In Egtapi project, I didn't use constructor
in any controller.



----------------------------------------------Thread in controller------------------------------------------------------
Controllers are running on the JavaFX main GUI thread, any tasks that could take longer time should be called in a
separate worker thread. Worker thread was supported by the abstract class Task. The time consuming jobs should be
placed in Task's call() method. Task class has two functions setOnSucceeded and setOnFailed, these two methods are used
to check whether there is Exception being thrown out from worker thread's call() method. When worker thread finished
and came back to the main GUI thread, the GUI thread knows how to handle it differently.