b7f83085a636f79660443e1d1395b835025b43b2
1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
7 import jexer
.TApplication
;
8 import jexer
.TMessageBox
;
10 import be
.nikiroo
.fanfix
.data
.MetaData
;
11 import be
.nikiroo
.fanfix
.data
.Story
;
12 import be
.nikiroo
.fanfix
.library
.BasicLibrary
;
13 import be
.nikiroo
.fanfix
.library
.LocalLibrary
;
14 import be
.nikiroo
.utils
.Progress
;
17 * Manages the TUI reader, links and manages the {@link TWindow}s, starts the
18 * correct output mode.
22 class TuiReaderApplication
extends TApplication
implements Reader
{
23 private Reader reader
;
25 public TuiReaderApplication(MetaData meta
, int chapter
, Reader reader
,
26 BackendType backend
) throws Exception
{
27 this(reader
, backend
);
29 new TuiReaderMainWindow(this, meta
, chapter
);
32 public TuiReaderApplication(List
<MetaData
> stories
, Reader reader
,
33 TApplication
.BackendType backend
) throws Exception
{
34 this(reader
, backend
);
36 new TuiReaderMainWindow(this, stories
);
39 private TuiReaderApplication(Reader reader
, TApplication
.BackendType backend
)
51 getBackend().setTitle("Fanfix");
54 public void read() throws IOException
{
58 public void read(int chapter
) throws IOException
{
62 public void open(MetaData meta
) {
66 public void open(MetaData meta
, int chapter
) {
67 // TODO: open in editor + external option
68 if (!meta
.isImageDocument()) {
69 new TuiReaderStoryWindow(this, getLibrary(), meta
, chapter
);
72 BasicReader
.openExternal(getLibrary(), meta
.getLuid());
73 } catch (IOException e
) {
74 messageBox("Error when trying to open the story",
75 e
.getMessage(), TMessageBox
.Type
.OK
);
80 public Story
getStory() {
81 return reader
.getStory();
84 public BasicLibrary
getLibrary() {
85 return reader
.getLibrary();
88 public void setLibrary(LocalLibrary lib
) {
89 reader
.setLibrary(lib
);
92 public void setStory(String luid
, Progress pg
) throws IOException
{
93 reader
.setStory(luid
, pg
);
96 public void setStory(URL source
, Progress pg
) throws IOException
{
97 reader
.setStory(source
, pg
);
100 public void browse(String source
) {
101 reader
.browse(source
);