+ /**
+ * Create the delete menu item.
+ *
+ * @return the item
+ */
+ private JMenuItem createMenuItemMove() {
+ JMenu moveTo = new JMenu("Move to...");
+ moveTo.setMnemonic(KeyEvent.VK_M);
+
+ List<String> types = new ArrayList<String>();
+ 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.
+ *
+ * @return the item
+ */
+ private JMenuItem createMenuItemRedownload() {
+ JMenuItem refresh = new JMenuItem("Redownload", KeyEvent.VK_R);
+ refresh.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (selectedBook != null) {
+ final MetaData meta = selectedBook.getMeta();
+ imprt(meta.getUrl(), new Runnable() {
+ public void run() {
+ reader.delete(meta.getLuid());
+ LocalReaderFrame.this.selectedBook = null;
+ }
+ }, "Removing old copy");
+ }
+ }
+ });
+
+ return refresh;
+ }
+