- private void addSourcePanes() {
- // Sources -> i18n
- GuiReaderGroup bookPane = new GuiReaderGroup(reader, "Sources", color);
-
- List<MetaData> sources = new ArrayList<MetaData>();
- for (String source : reader.getLibrary().getSources()) {
- MetaData mSource = new MetaData();
- mSource.setLuid(null);
- mSource.setTitle(source);
- mSource.setSource(source);
- sources.add(mSource);
- }
-
- bookPane.refreshBooks(sources, false);
-
- this.invalidate();
- pane.invalidate();
- pane.add(bookPane);
- pane.validate();
- this.validate();
-
- bookPane.setActionListener(new BookActionListener() {
- @Override
- public void select(GuiReaderBook book) {
- selectedBook = book;
- }
-
- @Override
- public void popupRequested(GuiReaderBook book, MouseEvent e) {
- JPopupMenu popup = new JPopupMenu();
- popup.add(createMenuItemOpenBook());
- popup.show(e.getComponent(), e.getX(), e.getY());
- }
-
- @Override
- public void action(final GuiReaderBook book) {
- removeBookPanes();
- addBookPane(book.getMeta().getSource(), true);
- refreshBooks();
- }
- });
- }
-
- /**
- * Add a new {@link GuiReaderGroup} on the frame to display the books of the
- * selected type or author.
- *
- * @param value
- * the author or the type, or NULL to get all the
- * authors-or-types
- * @param type
- * TRUE for type, FALSE for author
- */
- private void addBookPane(String value, boolean type) {
- if (value == null) {
- if (type) {
- if (Instance.getUiConfig().getBoolean(UiConfig.SOURCE_PAGE,
- false)) {
- addSourcePanes();
- } else {
- for (String tt : reader.getLibrary().getSources()) {
- if (tt != null) {
- addBookPane(tt, type);
- }
- }
- }
- } else {
- for (String tt : reader.getLibrary().getAuthors()) {
- if (tt != null) {
- addBookPane(tt, type);
- }
- }
- }
-
- return;
- }
-
- GuiReaderGroup bookPane = new GuiReaderGroup(reader, value, color);
- if (type) {
- booksByType.put(bookPane, value);
- } else {
- booksByAuthor.put(bookPane, value);
- }
-
- this.invalidate();
- pane.invalidate();
- pane.add(bookPane);
- pane.validate();
- this.validate();
-
- bookPane.setActionListener(new BookActionListener() {
- @Override
- public void select(GuiReaderBook book) {
- selectedBook = book;
- }
-
- @Override
- public void popupRequested(GuiReaderBook book, MouseEvent e) {
- JPopupMenu popup = new JPopupMenu();
- popup.add(createMenuItemOpenBook());
- popup.addSeparator();
- popup.add(createMenuItemExport());
- popup.add(createMenuItemMove(true));
- popup.add(createMenuItemSetCover());
- popup.add(createMenuItemClearCache());
- popup.add(createMenuItemRedownload());
- popup.addSeparator();
- popup.add(createMenuItemDelete());
- popup.show(e.getComponent(), e.getX(), e.getY());
- }
-
- @Override
- public void action(final GuiReaderBook book) {
- openBook(book);
- }
- });
+ @Override
+ public JPopupMenu createBookPopup() {
+ JPopupMenu popup = new JPopupMenu();
+ popup.add(createMenuItemOpenBook());
+ popup.addSeparator();
+ popup.add(createMenuItemExport());
+ popup.add(createMenuItemMoveTo(true));
+ popup.add(createMenuItemSetCoverForSource());
+ popup.add(createMenuItemSetCoverForAuthor());
+ popup.add(createMenuItemClearCache());
+ popup.add(createMenuItemRedownload());
+ popup.addSeparator();
+ popup.add(createMenuItemRename(true));
+ popup.add(createMenuItemSetAuthor(true));
+ popup.addSeparator();
+ popup.add(createMenuItemDelete());
+ popup.addSeparator();
+ popup.add(createMenuItemProperties());
+ return popup;