Diff for revision 1233
=== modified file 'src/com/pugh/sockso/gui/MusicPanel.java'
--- src/com/pugh/sockso/gui/MusicPanel.java 2010-02-20 14:57:53 +0000
+++ src/com/pugh/sockso/gui/MusicPanel.java 2010-02-20 17:40:39 +0000
@@ -71,7 +71,7 @@
final ActionListener importPlaylistAction = new ImportPlaylist( parent, db, cm, r );
- final MusicTree musicTree = new MusicTree( db, cm, r );
+ final MusicTree musicTree = new MusicTree( db );
final JSplitPane playlistsPanel = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
getSitePlaylistsPanel( sitePlaylists, importPlaylistAction ),
@@ -79,7 +79,9 @@
);
final JTabbedPane tabbedPane = getTabbedPane( musicTree, playlistsPanel );
+ musicTree.setCellRenderer( new MusicTreeCellRenderer(r) );
musicTree.init();
+ cm.addCollectionManagerListener( musicTree );
setLayout( new BorderLayout() );
add(
=== modified file 'src/com/pugh/sockso/gui/MusicTree.java'
--- src/com/pugh/sockso/gui/MusicTree.java 2010-02-20 14:57:53 +0000
+++ src/com/pugh/sockso/gui/MusicTree.java 2010-02-20 17:40:39 +0000
@@ -50,25 +50,19 @@
private DragSource dragSource;
private final Database db;
- private final CollectionManager cm;
- private final Resources r;
/**
* constructor
*
* @param db database connection
- * @param cm collection manager
- * @param r resources
*
*/
- public MusicTree( Database db, CollectionManager cm, Resources r ) {
+ public MusicTree( Database db ) {
super( new MusicTreeNode(new Collection()) );
this.db = db;
- this.cm = cm;
- this.r = r;
}
@@ -78,14 +72,11 @@
*/
public void init() {
-
- cm.addCollectionManagerListener( this );
dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer( this, DnDConstants.ACTION_COPY, this );
setShowsRootHandles( true );
- setCellRenderer( new MusicTreeCellRenderer(r) );
refresh();
@@ -192,7 +183,8 @@
final Artist artist = new Artist( item.getId(), item.getName() );
final String sql = " select al.id, al.name " +
" from albums al " +
- " where al.artist_id = ? ";
+ " where al.artist_id = ? " +
+ " order by al.name asc ";
st = db.prepare( sql );
st.setInt( 1, item.getId() );
@@ -234,7 +226,8 @@
try {
final String sql = Track.getSelectFromSql() +
- " where t.album_id = ? ";
+ " where t.album_id = ? " +
+ " order by t.track_no asc, t.name asc ";
st = db.prepare( sql );
st.setInt( 1, item.getId() );
=== modified file 'test/com/pugh/sockso/gui/MusicTreeTest.java'
--- test/com/pugh/sockso/gui/MusicTreeTest.java 2010-02-20 14:57:53 +0000
+++ test/com/pugh/sockso/gui/MusicTreeTest.java 2010-02-20 17:40:39 +0000
@@ -1,20 +1,13 @@
package com.pugh.sockso.gui;
-import com.pugh.sockso.music.CollectionManager;
-import com.pugh.sockso.resources.FileResources;
-import com.pugh.sockso.resources.Resources;
import com.pugh.sockso.tests.SocksoTestCase;
import com.pugh.sockso.tests.TestDatabase;
-import javax.swing.JTree;
import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
-import static org.easymock.EasyMock.*;
-
public class MusicTreeTest extends SocksoTestCase {
private MusicTree t;
@@ -23,18 +16,16 @@
@Override
public void setUp() throws Exception {
- Resources r = new FileResources();
- CollectionManager cm = createNiceMock( CollectionManager.class );
TestDatabase db = new TestDatabase();
db.fixture( "musicTree" );
- t = new MusicTree( db, cm, r );
+ t = new MusicTree( db );
t.init();
model = (DefaultTreeModel) t.getModel();
root = (DefaultMutableTreeNode) model.getRoot();
}
public void testConstructorDoesNoWork() {
- new MusicTree( null, null, null );
+ new MusicTree( null );
}
public void testTreeCreatedWhenInitialised() {