Skip to content

Commit 86a83b0

Browse files
committed
New todolist can be saved now
1 parent ceae47e commit 86a83b0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/org/ainm/controllers/MainController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,17 @@ void new_todo_list(ActionEvent event) throws IOException {
287287
// Create the file
288288
String directoryPath = createFileDialogController.getDirectory();
289289
String fileName = createFileDialogController.getFilename();
290-
File file = new File(
291-
((directoryPath.endsWith("/")) ? directoryPath : directoryPath + "/") + fileName + ".todo");
290+
String fullPath = ((directoryPath.endsWith("/")) ? directoryPath : directoryPath + "/") + fileName + ".todo";
291+
File file = new File(fullPath);
292292
if (!file.exists()) {
293293
file.createNewFile();
294294
}
295295
// Load the todolist view in current tab
296-
Node todolistView = FXMLLoader.load(getClass().getResource("/fxml/views/todo/todo_view.fxml"));
296+
FXMLLoader loader = new FXMLLoader();
297+
loader.setLocation("/fxml/views/todo/todo_view.fxml");
298+
Node todolistView = loader.load();
299+
TodolistController controller = loader.getController();
300+
controller.openedFile = Paths.get(fullPath);
297301
addViewToCurrentTab(todolistView);
298302
}
299303
}
@@ -351,4 +355,4 @@ public static Object getController(Node node) {
351355
} while (controller == null && node != null);
352356
return controller;
353357
}
354-
}
358+
}

0 commit comments

Comments
 (0)