X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix_swing%2Fgui%2FMainFrame.java;h=d580c61c788d380b69f1af000d1e25f11c893fc9;hb=30c4d6ed834b52aa4ce4b252295c41b63375ecba;hp=0f94fa575ee1377307f814cffcf35d0baa9d2f95;hpb=3cdf3fd8a60d22a592e1cd0634cb108faa1f5f9f;p=fanfix.git diff --git a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java index 0f94fa5..d580c61 100644 --- a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java +++ b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java @@ -1,10 +1,8 @@ package be.nikiroo.fanfix_swing.gui; -import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; -import java.io.IOException; import javax.swing.JComponent; import javax.swing.JFrame; @@ -12,15 +10,15 @@ import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; -import javax.swing.JPanel; import javax.swing.JSplitPane; -import javax.swing.SwingWorker; +import be.nikiroo.fanfix_swing.Actions; import be.nikiroo.utils.Version; public class MainFrame extends JFrame { private BooksPanel books; private DetailsPanel details; + private BrowserPanel browser; public MainFrame(boolean sidePanel, boolean detailsPanel) { super("Fanfix " + Version.getCurrentVersion()); @@ -30,7 +28,8 @@ public class MainFrame extends JFrame { sidePanel = true; detailsPanel = true; - final BrowserPanel browser = new BrowserPanel(); + browser = new BrowserPanel(); + books = new BooksPanel(true); JComponent other = null; boolean orientationH = true; @@ -49,24 +48,35 @@ public class MainFrame extends JFrame { other = split(goBack, details, false, 0.5, 1); } - books = new BooksPanel(true); browser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - books.load(browser.getSelectedSources(), browser.getSelectedAuthors(), browser.getSelectedTags()); + books.load(browser.getSelectedSources(), + browser.getSelectedAuthors(), + browser.getSelectedTags()); details.setBook(browser.getHighlight()); } }); + books.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (BooksPanel.INVALIDATE_CACHE.equals(e.getActionCommand())) { + browser.reloadData(); + } + } + }); JSplitPane split = split(other, books, orientationH, 0.5, 0); this.add(split); } - private JSplitPane split(JComponent leftTop, JComponent rightBottom, boolean horizontal, double ratio, - double weight) { - JSplitPane split = new JSplitPane(horizontal ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT, leftTop, - rightBottom); + private JSplitPane split(JComponent leftTop, JComponent rightBottom, + boolean horizontal, double ratio, double weight) { + JSplitPane split = new JSplitPane( + horizontal ? JSplitPane.HORIZONTAL_SPLIT + : JSplitPane.VERTICAL_SPLIT, + leftTop, rightBottom); split.setOneTouchExpandable(true); split.setResizeWeight(weight); split.setContinuousLayout(true); @@ -81,15 +91,42 @@ public class MainFrame extends JFrame { JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); - JMenuItem item1 = new JMenuItem("Uuu", KeyEvent.VK_U); + JMenuItem item1 = new JMenuItem("Download", KeyEvent.VK_D); item1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - System.out.println("Uuu: ACTION"); + Actions.imprt(MainFrame.this, true, new Runnable() { + @Override + public void run() { + browser.reloadData(); + books.load(browser.getSelectedSources(), + browser.getSelectedAuthors(), + browser.getSelectedTags()); + details.setBook(browser.getHighlight()); + } + }); + } + }); + + JMenuItem item2 = new JMenuItem("Import file", KeyEvent.VK_I); + item2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Actions.imprt(MainFrame.this, false, new Runnable() { + @Override + public void run() { + browser.reloadData(); + books.load(browser.getSelectedSources(), + browser.getSelectedAuthors(), + browser.getSelectedTags()); + details.setBook(browser.getHighlight()); + } + }); } }); file.add(item1); + file.add(item2); JMenu edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E);