Search in sources :

Example 1 with FilterFileMode

use of io.github.vocabhunter.gui.model.FilterFileMode in project VocabHunter by VocabHunter.

the class FilterGridController method buildFilterModel.

@Override
protected FilterGridModel buildFilterModel(final FilterFileModel model) {
    Path file = model.getFile();
    FilterFileMode mode = model.getMode();
    TextGrid grid = readGrid(file, mode);
    return new FilterGridModel(file, grid, mode, model.getColumns());
}
Also used : Path(java.nio.file.Path) TextGrid(io.github.vocabhunter.analysis.grid.TextGrid) FilterGridModel(io.github.vocabhunter.gui.model.FilterGridModel) FilterFileMode(io.github.vocabhunter.gui.model.FilterFileMode)

Example 2 with FilterFileMode

use of io.github.vocabhunter.gui.model.FilterFileMode in project VocabHunter by VocabHunter.

the class FilterGridController method changeFile.

@Override
protected void changeFile(final Stage stage, final FileDialogueFactory factory, final FilterGridModel filterModel) {
    FileDialogue dialogue = factory.create(FileDialogueType.OPEN_WORD_LIST, stage);
    dialogue.showChooser();
    if (dialogue.isFileSelected()) {
        Path file = dialogue.getSelectedFile();
        FileFormatType format = dialogue.getFileFormatType();
        FilterFileMode mode = FileFormatTypeTool.getMode(format);
        TextGrid grid = readGrid(file, mode);
        unbindCheckboxes(filterModel);
        filterModel.replaceContent(file, grid, mode, FilterGridModel.DEFAULT_COLUMNS);
        setupColumnsAndCheckBoxes(filterModel);
    }
}
Also used : Path(java.nio.file.Path) TextGrid(io.github.vocabhunter.analysis.grid.TextGrid) FileDialogue(io.github.vocabhunter.gui.dialogues.FileDialogue) FileFormatType(io.github.vocabhunter.gui.dialogues.FileFormatType) FilterFileMode(io.github.vocabhunter.gui.model.FilterFileMode)

Example 3 with FilterFileMode

use of io.github.vocabhunter.gui.model.FilterFileMode in project VocabHunter by VocabHunter.

the class FilterSessionController method exit.

@Override
protected void exit(final Stage stage, final FilterSessionModel filterModel, final Runnable onSave, final FilterFileModel parentModel, final boolean isSaveRequested) {
    if (isSaveRequested) {
        FilterFileMode mode = filterModel.isIncludeUnknown() ? FilterFileMode.SESSION_SEEN : FilterFileMode.SESSION_KNOWN;
        parentModel.setMode(mode);
        parentModel.setFile(filterModel.getFile());
        onSave.run();
    }
    stage.close();
}
Also used : FilterFileMode(io.github.vocabhunter.gui.model.FilterFileMode)

Example 4 with FilterFileMode

use of io.github.vocabhunter.gui.model.FilterFileMode in project VocabHunter by VocabHunter.

the class FilterFileModelTranslatorImpl method translateSession.

private static FilterFileModel translateSession(final BaseListedFile baseListedFile) {
    SessionListedFile file = (SessionListedFile) baseListedFile;
    FilterFileMode mode;
    if (file.isIncludeUnknown()) {
        mode = FilterFileMode.SESSION_SEEN;
    } else {
        mode = FilterFileMode.SESSION_KNOWN;
    }
    return new FilterFileModel(file.getFile(), mode, Collections.emptySet());
}
Also used : FilterFileModel(io.github.vocabhunter.gui.model.FilterFileModel) SessionListedFile(io.github.vocabhunter.analysis.settings.SessionListedFile) FilterFileMode(io.github.vocabhunter.gui.model.FilterFileMode)

Example 5 with FilterFileMode

use of io.github.vocabhunter.gui.model.FilterFileMode in project VocabHunter by VocabHunter.

the class FileFormatTypeToolTest method validate.

private void validate(final FileFormatType type, final FilterFileMode mode) {
    FilterFileMode actual = FileFormatTypeTool.getMode(type);
    assertEquals(mode, actual);
}
Also used : FilterFileMode(io.github.vocabhunter.gui.model.FilterFileMode)

Aggregations

FilterFileMode (io.github.vocabhunter.gui.model.FilterFileMode)6 Path (java.nio.file.Path)3 TextGrid (io.github.vocabhunter.analysis.grid.TextGrid)2 SessionListedFile (io.github.vocabhunter.analysis.settings.SessionListedFile)2 VocabHunterException (io.github.vocabhunter.analysis.core.VocabHunterException)1 DocumentListedFile (io.github.vocabhunter.analysis.settings.DocumentListedFile)1 ExcelListedFile (io.github.vocabhunter.analysis.settings.ExcelListedFile)1 FileDialogue (io.github.vocabhunter.gui.dialogues.FileDialogue)1 FileFormatType (io.github.vocabhunter.gui.dialogues.FileFormatType)1 FilterFileModel (io.github.vocabhunter.gui.model.FilterFileModel)1 FilterGridModel (io.github.vocabhunter.gui.model.FilterGridModel)1