@@ -20,7 +20,7 @@ public Controller(UI ui) {
20
20
public void cleanup () {
21
21
this .m_storage .delete_storage ();
22
22
}
23
-
23
+
24
24
public void uiUsernamePasswordCallback (Credentials credentials ) {
25
25
// save username and password for github
26
26
this .m_storage .set_username (credentials .getUsername ());
@@ -29,46 +29,55 @@ public void uiUsernamePasswordCallback(Credentials credentials) {
29
29
// pull files from github
30
30
this .m_storage .get_files ();
31
31
}
32
-
33
- public void storage_get_files_complete (boolean success , String message ){
32
+
33
+ public void storage_get_files_complete (boolean success , String message ) {
34
34
// let the ui know of success or failure
35
35
Platform .runLater (() -> this .m_ui .githubPullResult (success , message ));
36
-
36
+ // check version
37
+ Platform .runLater (() -> {
38
+ this .m_ui .checkVersion (
39
+ this .m_parser .parseCurrentVersion (this .m_storage .get_shift_overflow_version_filename ()));
40
+ });
37
41
// go ahead and give them the schedule immediately for use
38
- try {
39
- Schedule schedule = this .m_parser .parseSchedule (this .m_storage .get_schedule_json_filename (), this .m_storage .get_path_to_onyen_csv_directory (), this .m_storage .get_schedule_leads_filename ());
42
+ try {
43
+ Schedule schedule = this .m_parser .parseSchedule (this .m_storage .get_schedule_json_filename (),
44
+ this .m_storage .get_path_to_onyen_csv_directory (), this .m_storage .get_schedule_leads_filename ());
40
45
this .m_ui .setSchedule (schedule );
41
- } catch (Exception e ){
46
+ } catch (Exception e ) {
42
47
// tell the ui things suck
43
48
this .m_ui .setSchedule (null );
44
- Platform .runLater (() -> this .m_ui .displayMessage ("Controller::storage_get_files_complete(): " + e .toString ()));
49
+ Platform .runLater (
50
+ () -> this .m_ui .displayMessage ("Controller::storage_get_files_complete(): " + e .toString ()));
45
51
}
46
- }
47
-
48
- public void storage_save_files_complete (boolean success , String message ){
52
+ }
53
+
54
+ public void storage_save_files_complete (boolean success , String message ) {
49
55
// let the ui know
50
- Platform .runLater (() -> this .m_ui .githubPushResult (success , message ));
51
- }
56
+ Platform .runLater (() -> this .m_ui .githubPushResult (success , message ));
57
+ }
52
58
53
59
public void uiRequestSchedule () {
54
- // tell the ui to show the schedule...this can/will be null if there was an exception
60
+ // tell the ui to show the schedule...this can/will be null if there was
61
+ // an exception
55
62
// ui needs to be ready to handle null schedule
56
- try {
57
- Schedule schedule = this .m_parser .parseSchedule (this .m_storage .get_schedule_json_filename (), this .m_storage .get_path_to_onyen_csv_directory (), this .m_storage .get_schedule_leads_filename ());
63
+ try {
64
+ Schedule schedule = this .m_parser .parseSchedule (this .m_storage .get_schedule_json_filename (),
65
+ this .m_storage .get_path_to_onyen_csv_directory (), this .m_storage .get_schedule_leads_filename ());
58
66
this .m_ui .setSchedule (schedule );
59
67
Platform .runLater (() -> this .m_ui .displaySchedule (schedule ));
60
- } catch (Exception e ){
68
+ } catch (Exception e ) {
61
69
Platform .runLater (() -> this .m_ui .displayMessage ("Controller::uiRequestSchedule(): " + e .toString ()));
62
70
}
63
71
}
64
72
65
73
public void uiRequestEmployeeAvailability (String onyen ) {
66
74
// parse the employee
67
- try {
68
- Employee employee = this .m_parser .parseEmployee (this .m_storage .get_availability_csv_filename_from_onyen (onyen ));
69
- //display available object on ui
70
- Platform .runLater (() -> this .m_ui .displayAvailable (employee ));
71
- } catch (Exception e ){
75
+ try {
76
+ Employee employee = this .m_parser
77
+ .parseEmployee (this .m_storage .get_availability_csv_filename_from_onyen (onyen ));
78
+ // display available object on ui
79
+ Platform .runLater (() -> this .m_ui .displayAvailable (employee ));
80
+ } catch (Exception e ) {
72
81
this .m_ui .createNewEmployeeCSV (onyen );
73
82
}
74
83
}
@@ -78,33 +87,34 @@ public void uiRequestSwaps() {
78
87
}
79
88
80
89
public void uiRequestSaveAvailability (Employee employee , String commit_message ) {
81
- // need to tell parser to save this employee object and what filename to save it as
82
- if (employee == null ){
90
+ // need to tell parser to save this employee object and what filename to
91
+ // save it as
92
+ if (employee == null ) {
83
93
// unable to save
84
94
this .m_ui .displayMessage ("Controller::uiRequestSaveAvailability(): Employee is null" );
85
95
return ;
86
96
}
87
-
97
+
88
98
String filename = this .m_storage .get_availability_csv_filename_from_onyen (employee .getOnyen ());
89
- try {
99
+ try {
90
100
// have the parser write out the file
91
101
this .m_parser .writeFile (employee , filename );
92
102
// have storage push to the repo
93
103
this .m_storage .save_files (commit_message );
94
- } catch (Exception e ){
104
+ } catch (Exception e ) {
95
105
this .m_ui .displayMessage ("Controller::uiRequestSaveAvailability(): " + e .toString ());
96
106
}
97
107
}
98
-
99
- public void uiRequestChangeSchedule (Schedule schedule , String commit_message ){
100
- try {
101
- this .m_parser .writeScheduleToJson (schedule , this .m_storage .get_schedule_json_filename ());
102
- this .m_storage .save_files (commit_message );
103
- } catch (Exception e ){
108
+
109
+ public void uiRequestChangeSchedule (Schedule schedule , String commit_message ) {
110
+ try {
111
+ this .m_parser .writeScheduleToJson (schedule , this .m_storage .get_schedule_json_filename ());
112
+ this .m_storage .save_files (commit_message );
113
+ } catch (Exception e ) {
104
114
this .m_ui .displayMessage ("Controller::uiRequestChangeSchedule(): " + e .toString ());
105
115
}
106
116
}
107
-
117
+
108
118
public void displayMessage (String message ) {
109
119
this .m_ui .displayMessage (message );
110
120
}
0 commit comments