use of io.github.vocabhunter.gui.status.GuiTask in project VocabHunter by VocabHunter.
the class GuiFileHandler method processSave.
private void processSave() {
Path file = model.getSessionFile();
statusManager.performAction(file);
LOG.info("Saving file '{}'", file);
SessionState sessionState = sessionStateHandler.getSessionState();
GuiTask<Boolean> task = new GuiTask<>(guiTaskHandler, statusManager, () -> saveFile(file, sessionState), b -> model.setChangesSaved(true), e -> FileErrorTool.save(file, e));
guiTaskHandler.executeInBackground(task);
}
use of io.github.vocabhunter.gui.status.GuiTask in project VocabHunter by VocabHunter.
the class GuiFileHandler method processNewSession.
private void processNewSession() {
Path file = checkUnsavedChangesAndChooseFile(FileDialogueType.NEW_SESSION);
if (file == null) {
statusManager.completeAction();
} else {
statusManager.performAction(file);
LOG.info("New session from '{}'", file);
GuiTask<EnrichedSessionState> task = new GuiTask<>(guiTaskHandler, statusManager, () -> sessionFileService.createNewSession(file), this::finishOpen, e -> FileErrorTool.open(file, e));
guiTaskHandler.executeInBackground(task);
}
}
use of io.github.vocabhunter.gui.status.GuiTask in project VocabHunter by VocabHunter.
the class GuiFileHandler method processExport.
private void processExport() {
Path file = chooseFile(FileDialogueType.EXPORT_SELECTION);
if (file == null) {
statusManager.completeAction();
} else {
statusManager.performAction(file);
Path fileWithSuffix = FileNameTool.ensureExportFileHasSuffix(file);
SessionState sessionState = sessionStateHandler.getSessionState();
GuiTask<Boolean> task = new GuiTask<>(guiTaskHandler, statusManager, () -> processExport(fileWithSuffix, sessionState), e -> FileErrorTool.export(fileWithSuffix, e));
guiTaskHandler.executeInBackground(task);
}
}
use of io.github.vocabhunter.gui.status.GuiTask in project VocabHunter by VocabHunter.
the class GuiFileHandler method processOpenSession.
private void processOpenSession() {
Path file = checkUnsavedChangesAndChooseFile(FileDialogueType.OPEN_SESSION);
if (file == null) {
statusManager.completeAction();
} else {
statusManager.performAction(file);
LOG.info("Opening session file '{}'", file);
GuiTask<EnrichedSessionState> task = new GuiTask<>(guiTaskHandler, statusManager, () -> sessionFileService.read(file), this::finishOpen, e -> FileErrorTool.open(file, e));
guiTaskHandler.executeInBackground(task);
}
}
Aggregations