Save the current workspace to a file.
()
| 522 | * Save the current workspace to a file. |
| 523 | */ |
| 524 | private void saveWorkspace() { |
| 525 | if (controller.getWorkspace() == null) { |
| 526 | return; |
| 527 | } |
| 528 | fcSaveWorkspace.setInitialDirectory(config().getRecentSaveWorkspaceDir()); |
| 529 | File file = fcSaveWorkspace.showSaveDialog(null); |
| 530 | if (file != null) { |
| 531 | String json = WorkspaceIO.toJson(controller.getWorkspace()); |
| 532 | try { |
| 533 | FileUtils.write(file, json, UTF_8); |
| 534 | config().recentSaveWorkspace = file.getAbsolutePath(); |
| 535 | } catch(IOException ex) { |
| 536 | error(ex, "Failed to save workspace to file: {}", file.getName()); |
| 537 | ExceptionAlert.show(ex, "Failed to save workspace to file: " + file.getName()); |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | /** |
| 543 | * Update the recent files menu. |
nothing calls this directly
no test coverage detected