}
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setText("Duplicate record");
DatasetEditor datasetEditor = getDatasetEditor(e);
if (datasetEditor == null ||!datasetEditor.getActiveConnection().isConnected()) {
presentation.setEnabled(false);
} else {
presentation.setEnabled(true);
presentation.setVisible(!datasetEditor.isReadonlyData());
if (datasetEditor.isInserting() || datasetEditor.isLoading() || datasetEditor.isReadonly()) {
presentation.setEnabled(false);
} else {
DatasetEditorTable editorTable = datasetEditor.getEditorTable();
int[] selectedrows =
editorTable == null ? null :
editorTable.getSelectedRows();
presentation.setEnabled(selectedrows != null && selectedrows.length == 1 && selectedrows[0] < editorTable.getModel().getSize());
}