2222import java .nio .charset .Charset ;
2323import java .nio .file .Paths ;
2424import java .sql .SQLException ;
25+ import java .time .LocalDate ;
26+ import java .util .List ;
27+ import java .util .stream .Collectors ;
2528
29+ import de .doubleslash .keeptime .Main ;
30+ import de .doubleslash .keeptime .model .Project ;
31+ import de .doubleslash .keeptime .model .Work ;
2632import javafx .application .Platform ;
2733import javafx .scene .control .*;
2834import org .h2 .tools .RunScript ;
@@ -270,6 +276,10 @@ private void initImportButton(){
270276 final String url = applicationProperties .getSpringDataSourceUrl ();
271277 final String username = applicationProperties .getSpringDataSourceUserName ();
272278 final String password = applicationProperties .getSpringDataSourcePassword ();
279+
280+ model .getAllProjects ().clear ();
281+ model .getAvailableProjects ().clear ();
282+
273283 RunScript .execute (url , username , password , file .toString (), Charset .defaultCharset (), true );
274284
275285 Alert informationDialog = new Alert (AlertType .INFORMATION );
@@ -278,7 +288,12 @@ private void initImportButton(){
278288 informationDialog .setContentText ("KeepTime will now be CLOSED! You have to RESTART it again to see the changes" );
279289 informationDialog .showAndWait ();
280290
281- Platform .exit ();
291+ final List <Project > projects = model .getProjectRepository ().findAll ();
292+ LOG .debug ("Found '{}' projects" , projects .size ());
293+ model .getAllProjects ().addAll (projects );
294+ model .getAvailableProjects ()
295+ .addAll (model .getAllProjects ().stream ().filter (Project ::isEnabled ).collect (Collectors .toList ()));
296+
282297 } catch (SQLException e ) {
283298 LOG .error ("Could not import script file to db." , e );
284299
0 commit comments