1 package be
.nikiroo
.fanfix
.reader
.ui
;
3 import java
.awt
.BorderLayout
;
4 import java
.awt
.Component
;
5 import java
.awt
.event
.ActionEvent
;
6 import java
.awt
.event
.ActionListener
;
7 import java
.io
.IOException
;
10 import javax
.swing
.JButton
;
11 import javax
.swing
.JFrame
;
12 import javax
.swing
.JPanel
;
14 import be
.nikiroo
.fanfix
.Instance
;
15 import be
.nikiroo
.fanfix
.library
.BasicLibrary
;
16 import be
.nikiroo
.utils
.Progress
;
17 import be
.nikiroo
.utils
.ui
.ProgressBar
;
19 public class GuiReaderSearchAction
extends JFrame
{
20 private static final long serialVersionUID
= 1L;
22 private GuiReaderBookInfo info
;
23 private ProgressBar pgBar
;
25 public GuiReaderSearchAction(BasicLibrary lib
, GuiReaderBookInfo info
) {
26 super(info
.getMainInfo());
27 this.setSize(800, 600);
30 setLayout(new BorderLayout());
32 JPanel main
= new JPanel(new BorderLayout());
33 JPanel props
= new GuiReaderPropertiesPane(lib
, info
.getMeta());
35 main
.add(props
, BorderLayout
.NORTH
);
36 main
.add(new GuiReaderViewerPanel(info
.getMeta(), info
.getMeta()
37 .isImageDocument()), BorderLayout
.CENTER
);
38 main
.add(createImportButton(lib
), BorderLayout
.SOUTH
);
40 add(main
, BorderLayout
.CENTER
);
42 pgBar
= new ProgressBar();
43 pgBar
.setVisible(false);
44 add(pgBar
, BorderLayout
.SOUTH
);
46 pgBar
.addActionListener(new ActionListener() {
48 public void actionPerformed(ActionEvent e
) {
50 pgBar
.setProgress(null);
56 pgBar
.addUpdateListener(new ActionListener() {
58 public void actionPerformed(ActionEvent e
) {
66 private Component
createImportButton(final BasicLibrary lib
) {
67 JButton imprt
= new JButton("Import into library");
68 imprt
.addActionListener(new ActionListener() {
70 public void actionPerformed(ActionEvent ae
) {
71 final Progress pg
= new Progress();
72 pgBar
.setProgress(pg
);
74 new Thread(new Runnable() {
78 lib
.imprt(new URL(info
.getMeta().getUrl()), null);
79 } catch (IOException e
) {
80 Instance
.getTraceHandler().error(e
);