return;
} else if (selectedRow == 0) {
Toolkit.getDefaultToolkit().beep();
} else {
tableModel.moveRowUp(selectedRow);
ListSelectionModel lsm = annotationsTable.getSelectionModel();
int newSelectedRow = selectedRow - 1;
lsm.setSelectionInterval(newSelectedRow, newSelectedRow);
StyleMapEntry e = (StyleMapEntry) styleList.get(selectedRow);
styleList.remove(selectedRow);
styleList.add(newSelectedRow, e);
}
} else if (source == moveRowDownButton) {
int selectedRow = annotationsTable.getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(source, "Select table row", "Error",
JOptionPane.ERROR_MESSAGE);
return;
} else if (selectedRow == (tableModel.getRowCount() - 1)) {
Toolkit.getDefaultToolkit().beep();
} else {
tableModel.moveRowDown(selectedRow);
ListSelectionModel lsm = annotationsTable.getSelectionModel();
int newSelectedRow = selectedRow + 1;
lsm.setSelectionInterval(newSelectedRow, newSelectedRow);
StyleMapEntry e = (StyleMapEntry) styleList.get(selectedRow);
styleList.remove(selectedRow);
styleList.add(newSelectedRow, e);
}
} else if (source == addTableEntryButton) {
String typeName = annotationFeaturesViewer.getSelection();
if (typeName == null) {
JOptionPane.showMessageDialog(source,
"You must first select an annotation type or feature", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
addRow(typeName);
} else if (source == removeTableRowButton) {
int row = annotationsTable.getSelectedRow();
if (row >= 0) {
String message = "Are you sure you want to remove "
+ tableModel.getValueAt(row, StyleConstants.LABEL_COLUMN);
int rv = JOptionPane.showConfirmDialog(removeTableRowButton, message, "Remove Table Row",
JOptionPane.YES_NO_OPTION);
if (rv == JOptionPane.YES_OPTION) {
styleList.remove(row);
styleList.trimToSize();
tableModel.removeRow(row);
ListSelectionModel lsm = annotationsTable.getSelectionModel();
int newSelectedRow = (row == styleList.size() ? (row - 1) : row);
lsm.setSelectionInterval(newSelectedRow, newSelectedRow);
}
} else {
JOptionPane.showMessageDialog(source, "You must first select a table row to remove",
"Error", JOptionPane.ERROR_MESSAGE);
}