Search in sources :

Example 1 with GuiTask

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);
}
Also used : Path(java.nio.file.Path) GuiTask(io.github.vocabhunter.gui.status.GuiTask) SessionState(io.github.vocabhunter.analysis.session.SessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Example 2 with GuiTask

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);
    }
}
Also used : Path(java.nio.file.Path) GuiTask(io.github.vocabhunter.gui.status.GuiTask) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Example 3 with GuiTask

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);
    }
}
Also used : Path(java.nio.file.Path) GuiTask(io.github.vocabhunter.gui.status.GuiTask) SessionState(io.github.vocabhunter.analysis.session.SessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Example 4 with GuiTask

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);
    }
}
Also used : Path(java.nio.file.Path) GuiTask(io.github.vocabhunter.gui.status.GuiTask) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Aggregations

EnrichedSessionState (io.github.vocabhunter.analysis.session.EnrichedSessionState)4 GuiTask (io.github.vocabhunter.gui.status.GuiTask)4 Path (java.nio.file.Path)4 SessionState (io.github.vocabhunter.analysis.session.SessionState)2