1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.awt
.EventQueue
;
5 import java
.io
.IOException
;
7 import be
.nikiroo
.fanfix
.Instance
;
8 import be
.nikiroo
.fanfix
.Library
;
9 import be
.nikiroo
.fanfix
.bundles
.UiConfig
;
10 import be
.nikiroo
.fanfix
.data
.Story
;
11 import be
.nikiroo
.fanfix
.output
.BasicOutput
.OutputType
;
13 class LocalReader
extends BasicReader
{
16 public LocalReader() throws IOException
{
17 File dir
= Instance
.getReaderDir();
20 throw new IOException(
21 "Cannote create cache directory for local reader: " + dir
);
24 // TODO: can throw an exception, manage that (convert to IOEx ?)
25 OutputType text
= OutputType
.valueOfNullOkUC(Instance
.getUiConfig()
26 .getString(UiConfig
.LOCAL_READER_NON_IMAGES_DOCUMENT_TYPE
));
28 text
= OutputType
.HTML
;
31 OutputType images
= OutputType
.valueOfNullOkUC(Instance
.getUiConfig()
32 .getString(UiConfig
.LOCAL_READER_IMAGES_DOCUMENT_TYPE
));
34 images
= OutputType
.CBZ
;
38 lib
= new Library(dir
, text
, images
);
42 public void read() throws IOException
{
46 public void read(int chapter
) {
50 public void imprt(String luid
) throws IOException
{
52 Story story
= Instance
.getLibrary().getStory(luid
);
54 story
= lib
.save(story
, luid
);
56 throw new IOException("Cannot find story in Library: " + luid
);
58 } catch (IOException e
) {
59 throw new IOException(
60 "Cannot import story from library to LocalReader library: "
65 public File
getTarget(String luid
) throws IOException
{
66 File file
= lib
.getFile(luid
);
69 file
= lib
.getFile(luid
);
76 public void start(String type
) {
77 final String typeFinal
= type
;
78 EventQueue
.invokeLater(new Runnable() {
80 new LocalReaderFrame(LocalReader
.this, typeFinal
)