//Unused
break;
case TableModelEvent.UPDATE:
ArrayList<Feed> feeds = new ArrayList<Feed>();
feeds.addAll(Settings.getInstance().getFeeds());
Feed feed = feeds.get(row);
String value = (String) feedTableModel.getValueAt(row, col);
if(col==0 && !value.isEmpty()) {
feed.setLabel(value);
}
else if(col==1 && !value.isEmpty()) {
try {
new URL(value);
feed.setLink(value);
}
catch (MalformedURLException exception) {
JOptionPane.showMessageDialog(frame, value + " is not a valid url, please try again.", "Warning: Invalid url", JOptionPane.ERROR_MESSAGE);
}
}
else if(col==2) {
try {
feed.setPriority(Integer.parseInt(value));
}
catch (NumberFormatException exception) {
JOptionPane.showMessageDialog(frame, value + " is not an integer, please try again.", "Warning: Not an integer", JOptionPane.ERROR_MESSAGE);
}
}
updateFeedTable(true);
break;
case TableModelEvent.DELETE:
//Unused
break;
}
}
});
feedTable.getColumnModel().getColumn(1).setPreferredWidth(300);
JPanel feedSettingsButtonPanel = new JPanel();
GridBagConstraints gbc_feedSettingsButtonPanel = new GridBagConstraints();
gbc_feedSettingsButtonPanel.weightx = 0.1;
gbc_feedSettingsButtonPanel.fill = GridBagConstraints.BOTH;
gbc_feedSettingsButtonPanel.gridx = 0;
gbc_feedSettingsButtonPanel.gridy = 1;
feedSettingsPanel.add(feedSettingsButtonPanel, gbc_feedSettingsButtonPanel);
JButton btnAddFeed = new JButton("Add Feed");
btnAddFeed.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String inputLabel = JOptionPane.showInputDialog(frame, "Enter the feed name: ");
String inputURL = JOptionPane.showInputDialog(frame, "Enter the feed URL: ");
String inputPriority = JOptionPane.showInputDialog(frame, "Enter the feed priority: ");
try {
new URL(inputURL);
int priority = Integer.parseInt(inputPriority);
Feed feed = new Feed(inputLabel, inputURL, priority);
Settings.getInstance().addFeed(feed);
updateFeedTable(true);
} catch (MalformedURLException ex) {
JOptionPane.showMessageDialog(frame, inputURL + " is not a valid url, please try again.", "Warning: Invalid url", JOptionPane.ERROR_MESSAGE);
} catch (NumberFormatException ex) {