Search in sources :

Example 1 with SessionState

use of io.github.vocabhunter.analysis.session.SessionState in project VocabHunter by VocabHunter.

the class AnalysisSystemTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    Analyser analyser = new SimpleAnalyser();
    FileStreamer target = new FileStreamer(analyser);
    URL resource = FileStreamerTest.class.getResource("/" + INPUT_DOCUMENT);
    Path file = Paths.get(resource.toURI());
    EnrichedSessionState enrichedSession = target.createNewSession(file);
    SessionState sessionState = enrichedSession.getState();
    words = sessionState.getOrderedUses();
}
Also used : Path(java.nio.file.Path) SessionState(io.github.vocabhunter.analysis.session.SessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState) SimpleAnalyser(io.github.vocabhunter.analysis.simple.SimpleAnalyser) Analyser(io.github.vocabhunter.analysis.model.Analyser) SimpleAnalyser(io.github.vocabhunter.analysis.simple.SimpleAnalyser) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 2 with SessionState

use of io.github.vocabhunter.analysis.session.SessionState in project VocabHunter by VocabHunter.

the class SelectionExportToolTest method testSelection.

@Test
public void testSelection() throws Exception {
    SessionState state = state(word("Out1", WordState.KNOWN), word("In1", WordState.UNKNOWN), word("Out2", WordState.UNSEEN), word("In2", WordState.UNKNOWN));
    validate(state, "In1", "In2");
}
Also used : SessionState(io.github.vocabhunter.analysis.session.SessionState) Test(org.junit.Test)

Example 3 with SessionState

use of io.github.vocabhunter.analysis.session.SessionState 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 4 with SessionState

use of io.github.vocabhunter.analysis.session.SessionState 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 5 with SessionState

use of io.github.vocabhunter.analysis.session.SessionState in project VocabHunter by VocabHunter.

the class SelectionExportToolTest method state.

private SessionState state(final SessionWord... words) {
    SessionState bean = new SessionState();
    bean.setOrderedUses(listOf(words));
    return bean;
}
Also used : SessionState(io.github.vocabhunter.analysis.session.SessionState)

Aggregations

SessionState (io.github.vocabhunter.analysis.session.SessionState)7 EnrichedSessionState (io.github.vocabhunter.analysis.session.EnrichedSessionState)4 Path (java.nio.file.Path)3 GuiTask (io.github.vocabhunter.gui.status.GuiTask)2 Test (org.junit.Test)2 Analyser (io.github.vocabhunter.analysis.model.Analyser)1 SimpleAnalyser (io.github.vocabhunter.analysis.simple.SimpleAnalyser)1 SessionModel (io.github.vocabhunter.gui.model.SessionModel)1 URL (java.net.URL)1 BeforeClass (org.junit.BeforeClass)1