Fixed swing models missing generics.
This commit is contained in:
parent
9e36003152
commit
5eb3446416
@ -8,8 +8,8 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
class LibraryConfigGUI {
|
||||
private JList listLibraryFolders;
|
||||
private final LibraryListModel listModel = new LibraryListModel();
|
||||
private JList<File> listLibraryFolders;
|
||||
private final LibraryListModel<File> listModel = new LibraryListModel<>();
|
||||
private JPanel mainPanel;
|
||||
|
||||
public LibraryConfigGUI(){
|
||||
@ -25,7 +25,7 @@ class LibraryConfigGUI {
|
||||
private JPanel createUI() {
|
||||
mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout(0, 0));
|
||||
listLibraryFolders = new JList();
|
||||
listLibraryFolders = new JList<>();
|
||||
listLibraryFolders.setModel(listModel);
|
||||
mainPanel.add(listLibraryFolders, BorderLayout.CENTER);
|
||||
final JPanel panel2 = new JPanel();
|
||||
|
@ -43,7 +43,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
||||
private final JTree libraryView = new JTree();
|
||||
private final JTable playList = new JTable();
|
||||
private JSlider seekBar;
|
||||
private final JComboBox libraryDisplayType = new JComboBox();
|
||||
private final JComboBox<String> libraryDisplayType = new JComboBox<>();
|
||||
private final Player player = new Player(this);
|
||||
private final PlaylistTableModel playlistTableModel = new PlaylistTableModel(new ArrayList<>());
|
||||
private static final DefaultMutableTreeNode updatingNode = new DefaultMutableTreeNode();
|
||||
|
@ -5,9 +5,9 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryListModel extends AbstractListModel {
|
||||
public class LibraryListModel<T extends File> extends AbstractListModel<T> {
|
||||
|
||||
private List<File> libraryFolders = new ArrayList<>();
|
||||
private List<T> libraryFolders = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
@ -15,7 +15,7 @@ public class LibraryListModel extends AbstractListModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
public T getElementAt(int index) {
|
||||
return libraryFolders.get(index);
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ public class LibraryListModel extends AbstractListModel {
|
||||
* Add a directory to the list of directories used for library indexing.
|
||||
* @param folder Directory to add.
|
||||
*/
|
||||
public void addFolder(File folder){
|
||||
public void addFolder(T folder){
|
||||
if(folder.exists() && folder.isDirectory()) {
|
||||
libraryFolders.add(folder);
|
||||
fireAllContentsChanged();
|
||||
@ -33,7 +33,7 @@ public class LibraryListModel extends AbstractListModel {
|
||||
/**
|
||||
* @return List of directories currently used for library indexing.
|
||||
*/
|
||||
public List<File> currentFolderList(){
|
||||
public List<T> currentFolderList(){
|
||||
return new ArrayList<>(libraryFolders); // Copy? Don't want modification via here.
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class LibraryListModel extends AbstractListModel {
|
||||
* @param file File to find.
|
||||
* @return Does file exist in libraryFolders.
|
||||
*/
|
||||
public boolean contains(File file){
|
||||
public boolean contains(T file){
|
||||
return libraryFolders.contains(file);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class LibraryListModel extends AbstractListModel {
|
||||
* Set the list contained in libraryFolders.
|
||||
* @param folderList New directory list.
|
||||
*/
|
||||
public void setFolderList(List<File> folderList){
|
||||
public void setFolderList(List<T> folderList){
|
||||
if(folderList != null && folderList.size() > 0)
|
||||
libraryFolders = new ArrayList<>(folderList);
|
||||
else
|
||||
@ -62,7 +62,7 @@ public class LibraryListModel extends AbstractListModel {
|
||||
* Remove a directory from libraryFolders.
|
||||
* @param file Directory to be removed.
|
||||
*/
|
||||
public void removeFile(File file){
|
||||
public void removeFile(T file){
|
||||
libraryFolders.remove(file);
|
||||
fireAllContentsChanged();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user