void (AnActionButton button) { if (myNewElementSupplier != null) { final DataContext dataContext = DataManager.getInstance().getDataContext(table); final Project project = CommonDataKeys.PROJECT.getData(dataContext); final int rowIndex; final ListWrappingTableModel tableModel = table.getModel(); if (project != null) { String newElement = myNewElementSupplier.apply(project); if (newElement == null) { setDefaultElement(); return; } final int index = tableModel.indexOf(newElement, 0); if (index < 0) { tableModel.addRow(newElement); rowIndex = tableModel.getRowCount() - 1; } else { rowIndex = index; } table.setRowSelectionInterval(rowIndex, rowIndex); return; } } setDefaultElement(); }