Commit | Line | Data |
---|---|---|
a6395bef NR |
1 | package be.nikiroo.fanfix.reader; |
2 | ||
3 | import java.awt.Desktop; | |
4 | import java.awt.FlowLayout; | |
5 | import java.awt.event.ActionEvent; | |
6 | import java.awt.event.ActionListener; | |
7 | import java.io.IOException; | |
8 | import java.util.List; | |
9 | ||
10 | import javax.swing.JButton; | |
11 | import javax.swing.JFrame; | |
12 | ||
13 | import be.nikiroo.fanfix.Instance; | |
14 | import be.nikiroo.fanfix.data.MetaData; | |
15 | import be.nikiroo.fanfix.supported.BasicSupport.SupportType; | |
16 | ||
17 | class LocalReaderFrame extends JFrame { | |
18 | private static final long serialVersionUID = 1L; | |
19 | private LocalReader reader; | |
20 | ||
21 | public LocalReaderFrame(LocalReader reader, SupportType type) { | |
22 | super("HTML reader"); | |
23 | ||
24 | this.reader = reader; | |
25 | ||
26 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
27 | setSize(800, 600); | |
28 | setLayout(new FlowLayout()); | |
29 | ||
30 | // TODO: list all stories, list all TMP stories (and format?) | |
31 | ||
32 | List<MetaData> stories = Instance.getLibrary().getList(type); | |
33 | for (MetaData story : stories) { | |
34 | JButton button = new JButton(story.getTitle()); | |
35 | final String luid = story.getLuid(); | |
36 | button.addActionListener(new ActionListener() { | |
37 | public void actionPerformed(ActionEvent e) { | |
38 | try { | |
39 | // TODO: config option (image, non image): TXT, | |
40 | // custom-HTML, CBZ, EPUB | |
41 | Desktop.getDesktop().browse( | |
42 | LocalReaderFrame.this.reader.getTarget(luid) | |
43 | .toURI()); | |
44 | } catch (IOException e1) { | |
45 | e1.printStackTrace(); | |
46 | } | |
47 | } | |
48 | }); | |
49 | ||
50 | add(button); | |
51 | } | |
52 | ||
53 | setVisible(true); | |
54 | } | |
55 | } |