2020import de .doubleslash .keeptime .model .Settings ;
2121import de .doubleslash .keeptime .model .Work ;
2222import de .doubleslash .keeptime .view .ViewController ;
23- import de .doubleslash .keeptime .viewPopup .GlobalScreenListener ;
24- import de .doubleslash .keeptime .viewPopup .ViewControllerPopup ;
23+ import de .doubleslash .keeptime .viewpopup .GlobalScreenListener ;
24+ import de .doubleslash .keeptime .viewpopup .ViewControllerPopup ;
2525import javafx .application .Application ;
2626import javafx .fxml .FXMLLoader ;
2727import javafx .scene .Parent ;
3434@ SpringBootApplication
3535public class Main extends Application {
3636
37- private final Logger LOG = LoggerFactory .getLogger (this .getClass ());
37+ private final Logger log = LoggerFactory .getLogger (this .getClass ());
3838
3939 public static final String VERSION = "v0.0.2" ;
4040
@@ -47,7 +47,7 @@ public class Main extends Application {
4747
4848 @ Override
4949 public void init () throws Exception {
50- LOG .info ("Starting KeepTime {}" , VERSION );
50+ log .info ("Starting KeepTime {}" , VERSION );
5151 final DefaultExceptionHandler defaultExceptionHandler = new DefaultExceptionHandler ();
5252 defaultExceptionHandler .register ();
5353
@@ -60,14 +60,14 @@ public void init() throws Exception {
6060 @ Override
6161 public void start (final Stage primaryStage ) throws Exception {
6262
63- LOG .debug ("Reading configuration" );
63+ log .debug ("Reading configuration" );
6464
6565 // TODO there should just be one instance of settings in the repo
66- final List <Settings > settingsList = model .settingsRepository .findAll ();
66+ final List <Settings > settingsList = model .getSettingsRepository () .findAll ();
6767 final Settings settings ;
6868 if (settingsList .isEmpty ()) {
6969 settings = new Settings ();
70- settings .setTaskBarColor (model . taskBarColor .get ());
70+ settings .setTaskBarColor (Model . TASK_BAR_COLOR .get ());
7171
7272 settings .setDefaultBackgroundColor (model .defaultBackgroundColor .get ());
7373 settings .setDefaultFontColor (model .defaultFontColor .get ());
@@ -76,7 +76,7 @@ public void start(final Stage primaryStage) throws Exception {
7676 settings .setHoverFontColor (model .hoverFontColor .get ());
7777 settings .setUseHotkey (false );
7878 settings .setDisplayProjectsRight (true );
79- model .settingsRepository .save (settings );
79+ model .getSettingsRepository () .save (settings );
8080 } else {
8181 settings = settingsList .get (0 );
8282 }
@@ -85,21 +85,21 @@ public void start(final Stage primaryStage) throws Exception {
8585 model .defaultFontColor .set (settings .getDefaultFontColor ());
8686 model .hoverBackgroundColor .set (settings .getHoverBackgroundColor ());
8787 model .hoverFontColor .set (settings .getHoverFontColor ());
88- model . taskBarColor .set (settings .getTaskBarColor ());
89- model . useHotkey .set (settings .isUseHotkey ());
88+ Model . TASK_BAR_COLOR .set (settings .getTaskBarColor ());
89+ Model . USE_HOTKEY .set (settings .isUseHotkey ());
9090 model .displayProjectsRight .set (settings .isDisplayProjectsRight ());
9191
92- final List <Work > todaysWorkItems = model .workRepository .findByCreationDate (LocalDate .now ());
93- LOG .info ("Found {} past work items" , todaysWorkItems .size ());
94- model .pastWorkItems .addAll (todaysWorkItems );
92+ final List <Work > todaysWorkItems = model .getWorkRepository () .findByCreationDate (LocalDate .now ());
93+ log .info ("Found {} past work items" , todaysWorkItems .size ());
94+ model .getPastWorkItems () .addAll (todaysWorkItems );
9595
96- final List <Project > projects = model .projectRepository .findAll ();
96+ final List <Project > projects = model .getProjectRepository () .findAll ();
9797
98- LOG .debug ("Found '{}' projects" , projects .size ());
98+ log .debug ("Found '{}' projects" , projects .size ());
9999 if (projects .isEmpty ()) {
100- LOG .info ("Adding default project" );
101- projects .add (model .DEFAULT_PROJECT );
102- model .projectRepository .save (model .DEFAULT_PROJECT );
100+ log .info ("Adding default project" );
101+ projects .add (Model .DEFAULT_PROJECT );
102+ model .getProjectRepository () .save (Model .DEFAULT_PROJECT );
103103 }
104104
105105 model .allProjects .addAll (projects );
@@ -109,25 +109,25 @@ public void start(final Stage primaryStage) throws Exception {
109109 // set default project
110110 final Optional <Project > findAny = projects .stream ().filter (p -> p .isDefault ()).findAny ();
111111 if (findAny .isPresent ()) {
112- model .idleProject = findAny .get ();
113- LOG .debug ("Using project '{}' as default project." , model .idleProject );
112+ Model .idleProject = findAny .get ();
113+ log .debug ("Using project '{}' as default project." , Model .idleProject );
114114 }
115115
116- primaryStage .setOnHiding (( we ) -> {
116+ primaryStage .setOnHiding (we -> {
117117 popupViewStage .close ();
118118 globalScreenListener .register (false ); // deregister, as this will keep app running
119119 });
120120
121121 try {
122122 initialiseUI (primaryStage );
123123 } catch (final Exception e ) {
124- LOG .error (e .getMessage ());
124+ log .error (e .getMessage ());
125125 }
126126
127127 try {
128128 initialisePopupUI (primaryStage );
129129 } catch (final Exception e ) {
130- LOG .error (e .getMessage ());
130+ log .error (e .getMessage ());
131131 }
132132 }
133133
@@ -137,10 +137,8 @@ private void initialisePopupUI(final Stage primaryStage) throws IOException {
137137 // TODO register only if it is enabled
138138 globalScreenListener = new GlobalScreenListener ();
139139 // TODO stop and close stage when main stage is shutdown
140- model .useHotkey .addListener ((a , b , newValue ) -> {
141- globalScreenListener .register (newValue );
142- });
143- globalScreenListener .register (model .useHotkey .get ());
140+ Model .USE_HOTKEY .addListener ((a , b , newValue ) -> globalScreenListener .register (newValue ));
141+ globalScreenListener .register (Model .USE_HOTKEY .get ());
144142
145143 // Platform.setImplicitExit(false); // TODO maybe not needed as other view will be available
146144 popupViewStage = new Stage ();
@@ -158,7 +156,7 @@ private void initialisePopupUI(final Stage primaryStage) throws IOException {
158156 // Give the controller access to the main app.
159157 popupViewStage .setAlwaysOnTop (true );
160158 final ViewControllerPopup viewControllerPopupController = loader .getController ();
161- viewControllerPopupController .setStage (popupViewStage , popupScene );
159+ viewControllerPopupController .setStage (popupViewStage );
162160 viewControllerPopupController .setController (controller , model );
163161 globalScreenListener .setViewController (viewControllerPopupController );
164162
@@ -184,7 +182,7 @@ private void initialiseUI(final Stage primaryStage) {
184182 primaryStage .setAlwaysOnTop (true );
185183 primaryStage .setResizable (false );
186184
187- primaryStage .setOnCloseRequest (actionEvent -> LOG .info ("On close request" ));
185+ primaryStage .setOnCloseRequest (actionEvent -> log .info ("On close request" ));
188186
189187 viewController = loader .getController ();
190188 // Give the controller access to the main app.
@@ -197,7 +195,7 @@ private void initialiseUI(final Stage primaryStage) {
197195 } catch (
198196
199197 final Exception e ) {
200- LOG .error ("Error: " + e .toString (), e );
198+ log .error ("Error: " + e .toString (), e );
201199 }
202200 }
203201
0 commit comments