/**
* Invoked when an action occurs. This implementation supports the add and
* delete buttons.
*
* @param e
* the event that has occurred
*/
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if (action.equals(DELETE)) {
deleteArgument();
}
else
if (action.equals(ADD)) {
addArgument();
}
}
/**
* Remove the currently selected argument from the table.
*/
protected void deleteArgument() {
// If a table cell is being edited, we must cancel the editing before
// deleting the row
if (table.isEditing()) {
TableCellEditor cellEditor = table.getCellEditor(table.getEditingRow(), table.getEditingColumn());
cellEditor.cancelCellEditing();
}
int rowSelected = table.getSelectedRow();
if (rowSelected >= 0) {
tableModel.removeRow(rowSelected);
tableModel.fireTableDataChanged();
// Disable DELETE if there are no rows in the table to delete.
if (tableModel.getRowCount() == 0) {
delete.setEnabled(false);
}
// Table still contains one or more rows, so highlight (select)
// the appropriate one.
else {
int rowToSelect = rowSelected;
if (rowSelected >= tableModel.getRowCount()) {
rowToSelect = rowSelected - 1;
}
table.setRowSelectionInterval(rowToSelect, rowToSelect);
}
}
}
/**
* Add a new argument row to the table.
*/
protected void addArgument() {
// If a table cell is being edited, we should accept the current value
// and stop the editing before adding a new row.
stopTableEditing();
tableModel.addRow( [[#variabledfdbd80]]());
// Enable DELETE (which may already be enabled, but it won't hurt)
delete.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = tableModel.getRowCount() - 1;
table.setRowSelectionInterval(rowToSelect, rowToSelect);
}
/**
* Create a new LDAPArgument object.
*
* @return a new LDAPArgument object
*/
/**
* Create a new Argument object.
*
* @return a new Argument object
*/
protected Object [[#variabledfdbd80]]() {
return new [[#variabledfdb920]]( [[#variabledfdbd20]], ""); // $NON-NLS-1$ // $NON-NLS-2$
}
|