77import de .doubleslash .keeptime .controller .HeimatController ;
88import de .doubleslash .keeptime .model .Project ;
99import de .doubleslash .keeptime .model .Work ;
10+ import javafx .animation .Animation ;
1011import javafx .animation .PauseTransition ;
1112import javafx .animation .RotateTransition ;
1213import javafx .application .Platform ;
@@ -143,7 +144,7 @@ private void initialize() {
143144 TableColumn <TableRow , TableRow > shouldSyncColumn = new TableColumn <>("Sync" );
144145 shouldSyncColumn .setCellValueFactory (data -> new SimpleObjectProperty <>(data .getValue ()));
145146 // Custom Cell Factory to disable CheckBoxes
146- shouldSyncColumn .setCellFactory (col -> new TableCell <TableRow , TableRow >() {
147+ shouldSyncColumn .setCellFactory (col -> new TableCell <>() {
147148 private final CheckBox checkBox = new CheckBox ();
148149 private ChangeListener <Boolean > boolChangeListener ;
149150
@@ -158,9 +159,7 @@ protected void updateItem(TableRow item, boolean empty) {
158159 } else {
159160 checkBox .setDisable (!item .mapping .canBeSynced ());
160161 checkBox .setSelected (item .shouldSyncCheckBox .get ());
161- boolChangeListener = (obs , oldText , newBoolean ) -> {
162- item .shouldSyncCheckBox .set (newBoolean );
163- };
162+ boolChangeListener = (obs , oldText , newBoolean ) -> item .shouldSyncCheckBox .set (newBoolean );
164163 checkBox .selectedProperty ().addListener (boolChangeListener );
165164
166165 setGraphic (checkBox );
@@ -171,7 +170,7 @@ protected void updateItem(TableRow item, boolean empty) {
171170 shouldSyncColumn .setEditable (true );
172171
173172 TableColumn <TableRow , List <Project >> projectColumn = new TableColumn <>("Project" );
174- projectColumn .setCellValueFactory (data -> new SimpleObjectProperty (data .getValue ().mapping .projects ()));
173+ projectColumn .setCellValueFactory (data -> new SimpleObjectProperty <> (data .getValue ().mapping .projects ()));
175174 projectColumn .setCellFactory (column -> new TableCell <>() {
176175 @ Override
177176 protected void updateItem (List <Project > item , boolean empty ) {
@@ -181,9 +180,7 @@ protected void updateItem(List<Project> item, boolean empty) {
181180 setText (null );
182181 } else {
183182 VBox vbox = new VBox (5 );
184- item .forEach (project -> {
185- vbox .getChildren ().add (createRow (project .getColor (), project .getName ()));
186- });
183+ item .forEach (project -> vbox .getChildren ().add (createRow (project .getColor (), project .getName ())));
187184 setGraphic (vbox );
188185 }
189186 }
@@ -230,7 +227,7 @@ protected void updateItem(TableRow item, boolean empty) {
230227 } else {
231228 keeptimeLabel .setText ("KeepTime: " + localTimeStringConverter .toString (
232229 LocalTime .ofSecondOfDay (item .keeptimeTimeSeconds .get ())));
233- heimatLabel .setText ("Heimat : " + localTimeStringConverter .toString (
230+ heimatLabel .setText ("HEIMAT : " + localTimeStringConverter .toString (
234231 LocalTime .ofSecondOfDay (item .heimatTimeSeconds .get ())));
235232 timeSpinner .setDisable (!item .mapping .canBeSynced ());
236233 timeSpinner .getValueFactory ().setValue (LocalTime .ofSecondOfDay (0 ));
@@ -289,7 +286,7 @@ protected void updateItem(TableRow item, boolean empty) {
289286 copyHeimatNotes .setOnAction (me -> copyToClipboard (heimatNotesLabel .getText ()));
290287
291288 hbox .getChildren ().addAll (copyKeepTimeNotes , new Label ("KeepTime:" ), keepTimeNotesLabel );
292- hbox2 .getChildren ().addAll (copyHeimatNotes , new Label ("Heimat :" ), heimatNotesLabel );
289+ hbox2 .getChildren ().addAll (copyHeimatNotes , new Label ("HEIMAT :" ), heimatNotesLabel );
293290 container .getChildren ().addAll (textArea , hbox , hbox2 );
294291 }
295292
@@ -325,23 +322,21 @@ protected void updateItem(TableRow item, boolean empty) {
325322 shouldSyncColumn .setPrefWidth (50 );
326323 projectColumn .setPrefWidth (100 );
327324 timeColumn .setPrefWidth (125 );
328- notesColumn .prefWidthProperty ().bind (mappingTableView .widthProperty ().subtract (525 + 17 ));
325+ notesColumn .prefWidthProperty ().bind (mappingTableView .widthProperty ().subtract (525 + 17 ));
329326 syncColumn .setPrefWidth (250 );
330327
331328 mappingTableView .getColumns ().addAll (shouldSyncColumn , projectColumn , timeColumn , notesColumn , syncColumn );
332329 mappingTableView .setSelectionModel (null );
333330 mappingTableView .getColumns ().forEach (column -> column .setSortable (false ));
334331
335-
336- saveButton .setOnAction ((ae ) -> {
337- LOG .debug ("New mappings to be synced '{}'." , "TODO" );
332+ saveButton .setOnAction (ae -> {
338333 showLoadingScreen (true );
339334
340335 Task <List <HeimatController .HeimatErrors >> task = new Task <>() {
341336 @ Override
342337 protected List <HeimatController .HeimatErrors > call () {
343338 return heimatController .saveDay (items .stream ()
344- .map (item -> new HeimatController .Asdf (item .mapping ,
339+ .map (item -> new HeimatController .UserMapping (item .mapping ,
345340 item .shouldSyncCheckBox .get (), item .userNotes .get (),
346341 (int ) (item .userTimeSeconds .get () / 60 )))
347342 .toList (), currentReportDate );
@@ -353,11 +348,12 @@ protected List<HeimatController.HeimatErrors> call() {
353348 final List <HeimatController .HeimatErrors > errors = task .getValue ();
354349 if (!errors .isEmpty ()) {
355350 loadingScreenShowSyncing ("Something did not work :(" , loadingFailure );
356- List <String > a = errors .stream ().map (error -> {
357- return error .mapping ().getMapping ().heimatTaskId () + ": " + error .errorMessage ()
358- + ". Wanted to store '" + error .mapping ().getUserMinutes () + "' minutes with notes '"
359- + error .mapping ().getUserNotes () + "'" ;
360- }).toList ();
351+ List <String > a = errors .stream ()
352+ .map (error -> error .mapping ().mapping ().heimatTaskId () + ": "
353+ + error .errorMessage () + ". Wanted to store '" + error .mapping ()
354+ .userMinutes ()
355+ + "' minutes with notes '" + error .mapping ().userNotes () + "'" )
356+ .toList ();
361357
362358 showErrorDialog (a );
363359 } else {
@@ -385,9 +381,7 @@ protected List<HeimatController.HeimatErrors> call() {
385381 Platform .runLater (() -> new Thread (task ).start ());
386382 });
387383
388- cancelButton .setOnAction (ae -> {
389- thisStage .close ();
390- });
384+ cancelButton .setOnAction (ae -> thisStage .close ());
391385
392386 // TODO offer some way to book time to an additional project?
393387 }
@@ -408,7 +402,7 @@ private void initializeLoadingScreen() {
408402
409403 RotateTransition rotateTransition = new RotateTransition (Duration .seconds (1 ), loadingSpinner );
410404 rotateTransition .setByAngle (360 );
411- rotateTransition .setCycleCount (RotateTransition .INDEFINITE );
405+ rotateTransition .setCycleCount (Animation .INDEFINITE );
412406 rotateTransition .play ();
413407 }
414408
@@ -452,7 +446,7 @@ private void showErrorDialog(List<String> errorMessages) {
452446 }
453447
454448 private void setUpTimeSpinner (final Spinner <LocalTime > spinner ) {
455- spinner .focusedProperty ().addListener (( e ) -> {
449+ spinner .focusedProperty ().addListener (e -> {
456450 final LocalTimeStringConverter stringConverter = new LocalTimeStringConverter (FormatStyle .MEDIUM );
457451 final StringProperty text = spinner .getEditor ().textProperty ();
458452 try {
@@ -464,7 +458,7 @@ private void setUpTimeSpinner(final Spinner<LocalTime> spinner) {
464458 }
465459 });
466460
467- spinner .setValueFactory (new SpinnerValueFactory <LocalTime >() {
461+ spinner .setValueFactory (new SpinnerValueFactory <>() {
468462
469463 @ Override
470464 public void decrement (final int steps ) {
0 commit comments