}
}
private void createAllShowsMenu(Menu allShows) {
for(int i=0;i<ShowLibrary.getInstance().shows.size();i++) {
final Show s1 = ShowLibrary.getInstance().shows.get(i);
int numSeasons = s1.seasons.size();
if(numSeasons>0) {
final String title = s1.getTitle();
final Menu showMenu = new Menu(title);
allShows.add(showMenu);
for(Season mySeason : s1.seasons) {
final int mySeasonNum = mySeason.getNumber();
int numEpisodes = mySeason.getEpisodes().size();
for(Episode myEpisode : mySeason.getEpisodes()) {
//Var setup
final int myEpisodeNum = myEpisode.getNumber();
final String myLink;
final String myLabel;
String formattedSeasonEp = mySeason.formatSeasonEp(myEpisodeNum);
myLink = myEpisode.getLink();
myLabel = myEpisode.getLinkLabel();
//Menu setup
MenuItem remove = new MenuItem("Remove");
MenuItem linkItem = new MenuItem(myLabel);
//Link menu item functionality
if(!myLink.equals(" ")) {
final URI myURL = URI.create(myLink);
linkItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().browse(myURL);
} catch (IOException e1) {
LOGGER.warning("IO error " + e1.toString());
}
}
});
}
//Remove menu item functionality
final Season season = mySeason;
final Episode episode = myEpisode;
remove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int result = JOptionPane.showConfirmDialog(null,"Are you sure you want to remove " + title + " season " + mySeasonNum + " episode " + myEpisodeNum, "Remove Episode?", JOptionPane.YES_NO_OPTION);
if(result==0) {
season.removeEpisode(episode);
LOGGER.fine("Removed episode " + episode.getNumber() + " from " + title);
if (season.getEpisodes().size()==0) {
Show show = ShowLibrary.getInstance().getShow(title);
show.removeSeason(season);
LOGGER.fine("Season " + season.getNumber() + " of " + title + " is removed because it was empty.");
}
showLib.doUpdates();
}
}