private @NotNull ToolbarDecorator setupActions(@NotNull ToolbarDecorator decorator, @NotNull String defaultElement) {
    return decorator.setAddAction(new AnActionButtonRunnable() {
        @Override
        public void run(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();
        }

        private void setDefaultElement() {
          final ListWrappingTableModel tableModel = table.getModel();
          tableModel.addRow(defaultElement);
          EventQueue.invokeLater(() -> {
            final int lastRowIndex = tableModel.getRowCount() - 1;
            final Rectangle rectangle =
              table.getCellRect(lastRowIndex, 0, true);
            table.scrollRectToVisible(rectangle);
            table.editCellAt(lastRowIndex, 0);
            final ListSelectionModel selectionModel =
              table.getSelectionModel();
            selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex);
            final TableCellEditor editor = table.getCellEditor();
            final Component component =
              editor.getTableCellEditorComponent(table,
                                                 defaultElement, true, lastRowIndex, 0);
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(component, true));
          });
        }
      })
      .setRemoveAction(button -> TableUtil.removeSelectedItems(table))
      .disableUpDownActions();
  }
private @NotNull ToolbarDecorator setupActions(@NotNull ToolbarDecorator decorator, @NotNull String defaultElement)