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