X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReaderFrame.java;h=bb77655b7734c48c05ecf6eb4458662bbcdeb1fd;hp=a7935138d6ff2157cf11a5e356d8eb366862d112;hb=5ce869b82f28c4d288b266d7dee03aa4898fff21;hpb=d5a7153c54d09502f58acbacb047041c1917bbd7 diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index a793513..bb77655 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -34,6 +34,7 @@ import javax.swing.filechooser.FileNameExtensionFilter; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.Library; +import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; @@ -41,6 +42,7 @@ import be.nikiroo.fanfix.output.BasicOutput.OutputType; import be.nikiroo.fanfix.reader.LocalReaderBook.BookActionListener; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Version; +import be.nikiroo.utils.ui.ConfigEditor; import be.nikiroo.utils.ui.ProgressBar; /** @@ -108,18 +110,29 @@ class LocalReaderFrame extends JFrame { pgBar.addUpdateListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - revalidate(); + invalidate(); + validate(); repaint(); } }); - setJMenuBar(createMenu()); - booksByType = new HashMap(); booksByAuthor = new HashMap(); - addBookPane(type, true); - refreshBooks(); + pane.setVisible(false); + final Progress pg = new Progress(); + final String typeF = type; + outOfUi(pg, new Runnable() { + public void run() { + Instance.getLibrary().refresh(pg); + invalidate(); + setJMenuBar(createMenu()); + addBookPane(typeF, true); + refreshBooks(); + validate(); + pane.setVisible(true); + } + }); setVisible(true); } @@ -339,9 +352,65 @@ class LocalReaderFrame extends JFrame { bar.add(authors); + JMenu options = new JMenu("Options"); + options.setMnemonic(KeyEvent.VK_O); + options.add(createMenuItemConfig()); + options.add(createMenuItemUiConfig()); + bar.add(options); + return bar; } + /** + * Create the Fanfix Configuration menu item. + * + * @return the item + */ + private JMenuItem createMenuItemConfig() { + final String title = "Fanfix Configuration"; + JMenuItem item = new JMenuItem(title); + item.setMnemonic(KeyEvent.VK_F); + + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ConfigEditor ed = new ConfigEditor( + Config.class, Instance.getConfig(), + "This is where you configure the options of the program."); + JFrame frame = new JFrame(title); + frame.add(ed); + frame.setSize(800, 600); + frame.setVisible(true); + } + }); + + return item; + } + + /** + * Create the UI Configuration menu item. + * + * @return the item + */ + private JMenuItem createMenuItemUiConfig() { + final String title = "UI Configuration"; + JMenuItem item = new JMenuItem(title); + item.setMnemonic(KeyEvent.VK_U); + + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ConfigEditor ed = new ConfigEditor( + UiConfig.class, Instance.getUiConfig(), + "This is where you configure the graphical appearence of the program."); + JFrame frame = new JFrame(title); + frame.add(ed); + frame.setSize(800, 600); + frame.setVisible(true); + } + }); + + return item; + } + /** * Create the export menu item. * @@ -579,10 +648,10 @@ class LocalReaderFrame extends JFrame { public void run() { run.run(); refreshBooks(); - reload.setProgress(100); + reload.done(); if (!pg.isDone()) { // will trigger pgBar ActionListener: - pg.setProgress(pg.getMax()); + pg.done(); } } }, "outOfUi thread").start(); @@ -676,7 +745,7 @@ class LocalReaderFrame extends JFrame { onSuccess.run(); } } - pgOnSuccess.setProgress(100); + pgOnSuccess.done(); } }); } @@ -694,7 +763,10 @@ class LocalReaderFrame extends JFrame { */ @Override public void setEnabled(boolean b) { - bar.setEnabled(b); + if (bar != null) { + bar.setEnabled(b); + } + for (LocalReaderGroup group : booksByType.keySet()) { group.setEnabled(b); }