From 76b3e6cfa8728ce526988da373819f810a8e965e Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Wed, 8 Apr 2020 17:43:21 +0200 Subject: [PATCH] fix details panel for author/tags --- .../fanfix_swing/gui/BrowserPanel.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) 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); } } -- 2.27.0