From: Niki Roo Date: Wed, 8 Apr 2020 15:43:21 +0000 (+0200) Subject: fix details panel for author/tags X-Git-Tag: fanfix-3.1.2~20^2~12^2~19 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=76b3e6cfa8728ce526988da373819f810a8e965e;p=fanfix.git fix details panel for author/tags --- diff --git a/src/be/nikiroo/fanfix_swing/gui/BrowserPanel.java b/src/be/nikiroo/fanfix_swing/gui/BrowserPanel.java index 25f7c9d..9a6ee1a 100644 --- a/src/be/nikiroo/fanfix_swing/gui/BrowserPanel.java +++ b/src/be/nikiroo/fanfix_swing/gui/BrowserPanel.java @@ -1,12 +1,14 @@ package be.nikiroo.fanfix_swing.gui; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; @@ -144,15 +146,24 @@ public class BrowserPanel extends JPanel { * @return the {@link BookInfo} to highlight, can be NULL */ public BookInfo getHighlight() { - BasicLibrary lib = Instance.getInstance().getLibrary(); - List sel = sourceTab.getSelectedElements(); - if (!sel.isEmpty()) { + String selected1 = null; + Component selectedTab = tabs.getSelectedComponent(); + if (selectedTab instanceof BasicTab) { + @SuppressWarnings({ "unchecked", "rawtypes" }) + List selectedAll = ((BasicTab) selectedTab).getSelectedElements(); + if (!selectedAll.isEmpty()) { + selected1 = selectedAll.get(0); + } + } + + if (selected1 != null) { + BasicLibrary lib = Instance.getInstance().getLibrary(); if (tabs.getSelectedComponent() == sourceTab) { - return BookInfo.fromSource(lib, sel.get(0)); + return BookInfo.fromSource(lib, selected1); } else if (tabs.getSelectedComponent() == authorTab) { - return BookInfo.fromAuthor(lib, sel.get(0)); + return BookInfo.fromAuthor(lib, selected1); } else if (tabs.getSelectedComponent() == tagsTab) { - return BookInfo.fromTag(lib, sel.get(0)); + return BookInfo.fromTag(lib, selected1); } }