1 package com.melloware.jukes.gui.view.node;
2
3 import javax.swing.Icon;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7
8 import com.melloware.jukes.db.orm.Track;
9 import com.melloware.jukes.file.filter.MusicFilter;
10 import com.melloware.jukes.gui.tool.Resources;
11
12
13
14
15
16
17
18
19
20
21 public final class TrackNode
22 extends AbstractTreeNode {
23
24 private static final Log LOG = LogFactory.getLog(TrackNode.class);
25
26
27
28
29
30
31
32 public TrackNode(NavigationNode aParent, Track aModel) {
33 super(aParent, aModel);
34 this.settings = ((AbstractTreeNode)aParent).settings;
35 }
36
37
38
39
40
41
42
43 public Icon getIcon(final boolean sel) {
44 final String extension = getTrack().getTrackUrl().toLowerCase();
45 if ((extension.endsWith(MusicFilter.OGG)) || (extension.endsWith(MusicFilter.SPEEX))) {
46 return Resources.OGG_VORBIS_ICON;
47 } else if (extension.endsWith(MusicFilter.FLAC)) {
48 return Resources.FLAC_ICON;
49 } else {
50 return Resources.TRACK_TREE_ICON;
51 }
52 }
53
54
55
56
57
58
59 public String getName() {
60 return getTrack().getDisplayText(this.settings.getDisplayFormatTrack());
61 }
62
63
64
65
66
67
68
69 public Track getTrack() {
70 return (Track)getModel();
71 }
72
73
74
75
76 public void loadChildren() {
77 if (!childrenLoaded) {
78 loadingChildren = true;
79 LOG.debug("Loading children");
80 loadingChildren = false;
81 childrenLoaded = true;
82 }
83 }
84
85 }