if(row==-1) {
JOptionPane.showMessageDialog(frame, "Please select a show in the above table first.", "Error", JOptionPane.ERROR_MESSAGE);
}
else {
ShowLibrary showLib = ShowLibrary.getInstance();
Show show = showLib.shows.get(row);
int result = JOptionPane.showConfirmDialog(frame,"Are you sure you want to delete " + show.getTitle(), "Delete " + show.getTitle() + "?", JOptionPane.YES_NO_OPTION);
if(result==0) {
LOGGER.info("Deleted " + show.getTitle() + ".");
showLib.shows.remove(show);
updateShowTable(true);
}
}
}
});
bottomPanel.add(btnDeleteShow);
JButton btnAddAltTitle = new JButton("Add Alternate Title");
btnAddAltTitle.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int row = showTable.getSelectedRow();
if(row==-1) {
JOptionPane.showMessageDialog(frame, "Please select a show in the above table first.", "Error", JOptionPane.ERROR_MESSAGE);
}
else {
ShowLibrary showLib = ShowLibrary.getInstance();
Show show = showLib.shows.get(row);
String altTitle = JOptionPane.showInputDialog(frame,"Enter the alternate title you want to add to " + show.getTitle());
if(!(altTitle==null || altTitle.isEmpty() || altTitle.startsWith("No alternate")) ) {
show.addAltTitle(altTitle);
updateShowTable(true);
}
}
}
});
bottomPanel.add(btnAddAltTitle);
JButton btnRemoveAltTitle = new JButton("Remove Alternate Title");
btnRemoveAltTitle.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int row = showTable.getSelectedRow();
if(row==-1) {
JOptionPane.showMessageDialog(frame, "Please select a show in the above table first.", "Error", JOptionPane.ERROR_MESSAGE);
}
else {
ShowLibrary showLib = ShowLibrary.getInstance();
Show show = showLib.shows.get(row);
String[] altTitles = show.getAltTitles().split("<br>");
String altTitle = (String) JOptionPane.showInputDialog(frame,"Selecte the alternate title you want to remove from " + show.getTitle(), "Remove alternate title from " + show.getTitle(), JOptionPane.INFORMATION_MESSAGE, null, altTitles, altTitles[0]);
if(!(altTitle==null || altTitle.isEmpty())) {
show.removeAltTitle(altTitle);
updateShowTable(true);
}
}
}
});