Library can now be recognised as empty.
This commit is contained in:
parent
35649b5d60
commit
48a368e410
@ -98,9 +98,9 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
* @param libraryData List of songs.
|
* @param libraryData List of songs.
|
||||||
*/
|
*/
|
||||||
private void populateLibrary(List<Song> libraryData) {
|
private void populateLibrary(List<Song> libraryData) {
|
||||||
Collections.sort(libraryData);
|
|
||||||
DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
|
DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
|
||||||
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) model.getRoot();
|
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) model.getRoot();
|
||||||
|
Collections.sort(libraryData);
|
||||||
libraryData.forEach(x -> addNodeToTreeModel(model, parentNode, new DefaultMutableTreeNode(x)));
|
libraryData.forEach(x -> addNodeToTreeModel(model, parentNode, new DefaultMutableTreeNode(x)));
|
||||||
libraryView.setModel(model);
|
libraryView.setModel(model);
|
||||||
}
|
}
|
||||||
@ -172,6 +172,9 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
playlistTableModel.removeSong(invalidSong);
|
playlistTableModel.removeSong(invalidSong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the library with songs in the currently selected display format.
|
||||||
|
*/
|
||||||
public void refreshLibrary() {
|
public void refreshLibrary() {
|
||||||
DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
|
DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
|
||||||
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) model.getRoot();
|
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) model.getRoot();
|
||||||
@ -180,6 +183,14 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
libraryView.setModel(model);
|
libraryView.setModel(model);
|
||||||
Thread populateThread = new Thread(() -> {
|
Thread populateThread = new Thread(() -> {
|
||||||
libraryDisplayVariants.get(libraryDisplayType.getSelectedItem().toString()).run();
|
libraryDisplayVariants.get(libraryDisplayType.getSelectedItem().toString()).run();
|
||||||
|
// If we get here and the model hasn't changed, the library must be empty.
|
||||||
|
if(libraryView.getModel() == model){
|
||||||
|
DefaultTreeModel failedModel = new DefaultTreeModel(new DefaultMutableTreeNode());
|
||||||
|
DefaultMutableTreeNode failedParentNode = (DefaultMutableTreeNode) failedModel.getRoot();
|
||||||
|
DefaultMutableTreeNode failedNode = new DefaultMutableTreeNode("Library is empty!");
|
||||||
|
addNodeToTreeModel(failedModel, failedParentNode, failedNode);
|
||||||
|
libraryView.setModel(failedModel);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
populateThread.start();
|
populateThread.start();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user