list.setModel(m);
restrictedPlaylist = _playlist;
}
else
{
DefaultListModel newModel = new DefaultListModel();
if (lastSearch != null)
{
if (searchString.length() <= 1 || !searchString.substring(searchString.length() - 2).equals(lastSearch))
{
list.setModel(m);
restrictedPlaylist = _playlist;
}
}
Vector pI = restrictedPlaylist;
restrictedPlaylist = new Vector();
for (int a = 0; a < s.length; a++)
{
String currentS = s[a];
int size = list.getModel().getSize();
boolean[] remove = new boolean[size];
for (int i = 0; i < size; i++)
{
final int TITLE_SEARCH = 0;
final int ARTIST_SEARCH = 1;
final int ALBUM_SEARCH = 2;
final int FILENAME_SEARCH = 3;
TagInfo pli = ((PlaylistItem) pI.get(i)).getTagInfo();
remove[i] = false;
boolean found = false;
int searchType;
if (artist.isSelected())
{
searchType = ARTIST_SEARCH;
}
else if (album.isSelected())
{
searchType = ALBUM_SEARCH;
}
else if (title.isSelected())
{
searchType = TITLE_SEARCH;
}
else
{
searchType = -1;
}
for (int j = 0; j <= FILENAME_SEARCH; j++)
{
String listString = "";
if (pli == null)
{
if (searchType != -1)
{
break;
}
j = FILENAME_SEARCH;
}
else if (searchType != -1)
{
j = searchType;
}
switch (j)
{
case (TITLE_SEARCH):
if (pli.getTitle() != null) listString = pli.getTitle().toLowerCase();
break;
case (ARTIST_SEARCH):
if (pli.getArtist() != null) listString = pli.getArtist().toLowerCase();
break;
case (ALBUM_SEARCH):
if (pli.getAlbum() != null) listString = pli.getAlbum().toLowerCase();
break;
case (FILENAME_SEARCH):
String location = ((PlaylistItem) pI.get(i)).getLocation().toLowerCase();
listString = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf("."));
break;
}
currentS = currentS.toLowerCase();
if (found = search(currentS, listString))
{
break;
}
if (searchType != -1)
{
break;
}
}
//if(found)foundAt[a] = i;
if (found && a == 0)
{
//todo new
newModel.addElement(getDisplayString((PlaylistItem) pI.get(i)));
restrictedPlaylist.add(pI.get(i));
}
if (!found && a != 0)
{
remove[i] = true;
}
}
//remove all unmatching items
for (int x = size - 1; x >= 0; x--)
{
if (remove[x])
{
newModel.remove(x);
restrictedPlaylist.remove(x);
}
}
pI = restrictedPlaylist;
list.setModel(newModel);