X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix_swing%2Fgui%2FDetailsPanel.java;h=751e37f511c5ed58fda8a7f7aa1885495755e5ea;hb=d6c8579cb5debbdf7657d405e6529ba324903fcd;hp=da1af4c480af6f757c69b9bb53ef75b26ddb0e07;hpb=3cdf3fd8a60d22a592e1cd0634cb108faa1f5f9f;p=fanfix.git diff --git a/src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java b/src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java index da1af4c..751e37f 100644 --- a/src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java +++ b/src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java @@ -31,6 +31,8 @@ public class DetailsPanel extends JPanel { private JLabel name; private JLabel opt; + private BookInfo info; + /** * Create a new {@link DetailsPanel}. */ @@ -77,25 +79,45 @@ public class DetailsPanel extends JPanel { * @param info the {@link BookInfo} to display */ public void setBook(final BookInfo info) { + this.info = info; + icon.setIcon(null); if (info == null) { name.setText(null); opt.setText(null); + } else if (info.getMainInfo() == null) { + name.setText("All the " + info.getType().toString().toLowerCase() + "s"); + opt.setText(info.getSecondaryInfo(true)); } else { + final String myId = info.getId(); + name.setText(info.getMainInfo()); opt.setText(info.getSecondaryInfo(true)); + new SwingWorker() { @Override protected Image doInBackground() throws Exception { - return BookBlock.generateCoverImage(Instance.getInstance().getLibrary(), info); + Thread.sleep(20); + + BookInfo current = DetailsPanel.this.info; + if (current != null && current.getId().equals(myId)) { + return BookBlock.generateCoverImage(Instance.getInstance().getLibrary(), info); + } + + return null; } @Override protected void done() { - try { - icon.setIcon(new ImageIcon(get())); - } catch (InterruptedException e) { - } catch (ExecutionException e) { + BookInfo current = DetailsPanel.this.info; + if (current != null && current.getId().equals(myId)) { + try { + Image img = get(); + if (img != null) + icon.setIcon(new ImageIcon(img)); + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } } } }.execute();