Commit | Line | Data |
---|---|---|
3cdf3fd8 NR |
1 | package be.nikiroo.fanfix_swing.gui.browser; |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.List; | |
5 | ||
6 | import javax.swing.tree.DefaultMutableTreeNode; | |
7 | ||
8 | import be.nikiroo.fanfix.Instance; | |
e915ed77 | 9 | import be.nikiroo.fanfix.bundles.StringIdGui; |
3cdf3fd8 NR |
10 | |
11 | public class AuthorTab extends BasicTab<List<String>> { | |
12 | public AuthorTab(int index, String listenerCommand) { | |
13 | super(index, listenerCommand); | |
14 | } | |
15 | ||
16 | @Override | |
17 | protected List<String> createEmptyData() { | |
18 | return new ArrayList<String>(); | |
19 | } | |
20 | ||
21 | @Override | |
22 | protected void fillData(List<String> data) { | |
23 | try { | |
24 | List<String> authors = Instance.getInstance().getLibrary().getAuthors(); | |
25 | for (String author : authors) { | |
26 | data.add(author); | |
27 | } | |
28 | } catch (Exception e) { | |
29 | // TODO | |
30 | e.printStackTrace(); | |
31 | } | |
32 | } | |
33 | ||
34 | @Override | |
35 | protected String keyToElement(String key) { | |
36 | return key; | |
37 | } | |
38 | ||
39 | @Override | |
40 | protected String keyToDisplay(String key) { | |
e915ed77 NR |
41 | if (key.trim().isEmpty()) { |
42 | key = Instance.getInstance().getTransGui().getString(StringIdGui.MENU_AUTHORS_UNKNOWN); | |
43 | } | |
44 | ||
3cdf3fd8 NR |
45 | return key; |
46 | } | |
47 | ||
48 | @Override | |
49 | protected int loadData(DefaultMutableTreeNode root, List<String> authors, String filter) { | |
50 | for (String author : authors) { | |
51 | if (checkFilter(filter, author)) { | |
52 | DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(author); | |
53 | root.add(sourceNode); | |
54 | } | |
55 | } | |
56 | ||
57 | return authors.size(); | |
58 | } | |
59 | } |