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;
* @return the {@link BookInfo} to highlight, can be NULL
*/
public BookInfo getHighlight() {
- BasicLibrary lib = Instance.getInstance().getLibrary();
- if (tabs.getSelectedComponent() == sourceTab) {
- List<String> sel = sourceTab.getSelectedElements();
- if (!sel.isEmpty()) {
- return BookInfo.fromSource(lib, sel.get(0));
+ String selected1 = null;
+ Component selectedTab = tabs.getSelectedComponent();
+ if (selectedTab instanceof BasicTab) {
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ List<String> selectedAll = ((BasicTab) selectedTab).getSelectedElements();
+ if (!selectedAll.isEmpty()) {
+ selected1 = selectedAll.get(0);
}
- } else if (tabs.getSelectedComponent() == authorTab) {
- List<String> sel = authorTab.getSelectedElements();
- if (!sel.isEmpty()) {
- return BookInfo.fromAuthor(lib, sel.get(0));
- }
- } else if (tabs.getSelectedComponent() == tagsTab) {
- List<String> sel = tagsTab.getSelectedElements();
- if (!sel.isEmpty()) {
- return BookInfo.fromTag(lib, sel.get(0));
+ }
+
+ if (selected1 != null) {
+ BasicLibrary lib = Instance.getInstance().getLibrary();
+ if (tabs.getSelectedComponent() == sourceTab) {
+ return BookInfo.fromSource(lib, selected1);
+ } else if (tabs.getSelectedComponent() == authorTab) {
+ return BookInfo.fromAuthor(lib, selected1);
+ } else if (tabs.getSelectedComponent() == tagsTab) {
+ return BookInfo.fromTag(lib, selected1);
}
}
return tagsTab.getSelectedElements();
}
+ /**
+ * Reload all the data from the 3 tabs.
+ */
+ public void reloadData() {
+ sourceTab.reloadData();
+ authorTab.reloadData();
+ tagsTab.reloadData();
+ }
+
/**
* Adds the specified action listener to receive action events from this
* {@link SearchBar}.