import javax.swing.JMenuItem;
import javax.swing.JSplitPane;
+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());
sidePanel = true;
detailsPanel = true;
- final BrowserPanel browser = new BrowserPanel();
+ browser = new BrowserPanel();
+ books = new BooksPanel(true);
JComponent other = null;
boolean orientationH = true;
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());
}
});
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);
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);