Allow to import/export crosswords
Related to #39 (closed), which enables to save then re-open crossword created by croiseur – implies a repository with its own, a priori independent, persistence format.
Here the focus is on the capability on importing (respectively exporting) crosswords created externally (resp. so that can be used externally). Work is on puzzle formats and generic codec interface definition.
Why?
- Import: Because existing grid templates may be created externally.
- Export: Because one may want to export the grid in a playable format (e.g. pdf) or for post-processing in a different software.
What?
CLI
- New commands:
-
puzzle list-codecs
: List the supported formats. May be split intolist-encoders
andlist-decoders
. -
puzzle import <file.ext>
: Import puzzle - i.e. decode given file and save it to puzzle repository. Decoder should be picked based on file extension. -
puzzle export <id> <file.ext>
: Export saved puzzle with given id to a file of given name. Encoders should be picked based on file extension.
-
GUI
- For import:
- New button to import puzzle from welcome screen, alongside the "New puzzle" button.
- Clicking on it opens a
FileChooser
(kind: open dialog) allowing to select the puzzle to import. - File extension selected in the
FileChooser
allows to choose the decoder.
- For export:
- Add a button somewhere in the editor view's puzzle pane.
- Clicking on it opens a
FileChooser
(kind: save dialog) allowing to select the location of the puzzle to export. - File extension selected in the
FileChooser
allows to choose the encoder.
How?
New services for core to provide:
listDecoders()
listEncoders()
importPuzzle(InputStream in, String format)
exportPuzzle(OutputStream out, String format)
I'm hesitating between two solutions:
- Put everything under
PuzzleService
. It fits more or less but class is getting big and the new methods are slightly distinct from the rest. - Put everything under a distinct
PuzzleImportExportService
?
On the other hand, we do have listProviders
on DictionaryService
and listSolvers
on SolverService
. It's just that the providers related to these service are read-only, they do not have an API to add new dictionaries/solvers, so they are smaller.
Edited by Antoine Belvire