String name = tl.trackName.getText();
if (name == null || name.length() == 0) {
break;
}
int tCount = medium.getTracks().size();
Track t;
if (tCount == 0 || tCount < idx) {
t = new Track();
tracksToAdd.add(t);
} else {
t = medium.getTracks().get(idx);
}
t.setPosition(idx);
t.setName(tl.trackName.getText());
t.setMedium(medium);
Number bpmNum = (Number) tl.bpm.getValue();
if (bpmNum != null) {
t.setBpm(bpmNum.intValue());
}
t.setArtist(artist);
t.setGenre1((Genre) tl.genre1.getSelectedItem());
if (tl.genre2.getSelectedItem() == null) {
continue;
}
t.setGenreWeight(((Integer) tl.genreAssign.getSelectedItem())
.intValue());
t.setGenre2((Genre) tl.genre2.getSelectedItem());
t.setDuration(tl.duration.getText());
idx++;
}
if (tracksToAdd.size()>0) {
medium.addTracks(tracksToAdd);