1 package com.melloware.jukes.gui.view.node;
2
3 import java.util.Iterator;
4
5 import javax.swing.Icon;
6
7 import org.apache.commons.lang.StringUtils;
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 import com.melloware.jukes.db.orm.Disc;
12 import com.melloware.jukes.db.orm.Track;
13 import com.melloware.jukes.gui.tool.Resources;
14
15
16
17
18
19
20
21
22
23
24 public final class DiscNode
25 extends AbstractTreeNode {
26
27 private static final Log LOG = LogFactory.getLog(DiscNode.class);
28
29
30
31
32
33
34
35 public DiscNode(NavigationNode aParent, Disc aModel) {
36 super(aParent, aModel);
37 this.settings = ((AbstractTreeNode)aParent).settings;
38 }
39
40
41
42
43
44
45
46 public Disc getDisc() {
47 return (Disc)getModel();
48 }
49
50
51
52
53
54
55
56
57 public Icon getIcon(final boolean sel) {
58 Icon icon = null;
59 if (StringUtils.contains(getDisc().getName().toLowerCase(), "from the vault")) {
60 icon = Resources.DISC_GD_ICON;
61 } else if (StringUtils.contains(getDisc().getName().toLowerCase(),"dark side of the moon")) {
62 icon = Resources.DISC_PF_ICON;
63 } else {
64 icon = Resources.DISC_TREE_ICON;
65 }
66 return icon;
67 }
68
69
70
71
72
73
74 public String getName() {
75 return getDisc().getDisplayText(this.settings.getDisplayFormatDisc());
76 }
77
78
79
80
81 public void loadChildren() {
82 if (!childrenLoaded) {
83 loadingChildren = true;
84 LOG.debug("Loading children");
85 final Iterator iter = getDisc().getTracks().iterator();
86 while (iter.hasNext()) {
87 final Track track = (Track)iter.next();
88 if (LOG.isDebugEnabled()) {
89 LOG.debug("Loading track " + track.getName());
90 }
91 this.add(new TrackNode(this, track));
92
93 }
94
95 loadingChildren = false;
96 childrenLoaded = true;
97 }
98
99 }
100
101 }