X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReaderFrame.java;h=03df7fbdf5cf133d86ac5d11634392e7edb61632;hp=ca49470476c50581d44242d87a4cb2cdd46fa4b9;hb=70c9b112926f1cf95b2fddd0bb504ab37d6ddd1e;hpb=4f661b2bb0f64ed54c3e849c0c2c5b6bcfe844df diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index ca49470..03df7fb 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -13,6 +13,7 @@ import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -142,7 +143,8 @@ class LocalReaderFrame extends JFrame { * the selected type or author. * * @param value - * the author or the type + * the author or the type, or NULL to get all the + * authors-or-types * @param type * TRUE for type, FALSE for author */ @@ -188,6 +190,7 @@ class LocalReaderFrame extends JFrame { popup.add(createMenuItemOpenBook()); popup.addSeparator(); popup.add(createMenuItemExport()); + popup.add(createMenuItemMove()); popup.add(createMenuItemClearCache()); popup.add(createMenuItemRedownload()); popup.addSeparator(); @@ -265,6 +268,7 @@ class LocalReaderFrame extends JFrame { file.add(createMenuItemOpenBook()); file.add(createMenuItemExport()); + file.add(createMenuItemMove()); file.addSeparator(); file.add(imprt); file.add(imprtF); @@ -527,6 +531,68 @@ class LocalReaderFrame extends JFrame { return refresh; } + /** + * Create the delete menu item. + * + * @return the item + */ + private JMenuItem createMenuItemMove() { + JMenu moveTo = new JMenu("Move to..."); + moveTo.setMnemonic(KeyEvent.VK_M); + + List types = new ArrayList(); + types.add(null); + types.addAll(Instance.getLibrary().getTypes()); + + for (String type : types) { + JMenuItem item = new JMenuItem(type == null ? "New type..." : type); + + moveTo.add(item); + if (type == null) { + moveTo.addSeparator(); + } + + final String ftype = type; + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (selectedBook != null) { + String type = ftype; + if (type == null) { + Object rep = JOptionPane.showInputDialog( + LocalReaderFrame.this, "Move to:", + "Moving story", + JOptionPane.QUESTION_MESSAGE, null, null, + selectedBook.getMeta().getSource()); + if (rep == null) { + return; + } else { + type = rep.toString(); + } + } + + final String ftype = type; + outOfUi(null, new Runnable() { + public void run() { + reader.changeType(selectedBook.getMeta() + .getLuid(), ftype); + + selectedBook = null; + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setJMenuBar(createMenu()); + } + }); + } + }); + } + } + }); + } + + return moveTo; + } + /** * Create the redownload (then delete original) menu item. * @@ -648,10 +714,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(); @@ -745,7 +811,7 @@ class LocalReaderFrame extends JFrame { onSuccess.run(); } } - pgOnSuccess.setProgress(100); + pgOnSuccess.done(); } }); }