private static <T> void setupCommonListControls(final JBList<T> list,
                                                  final CollectionListModel<T> model,
                                                  final JButton addButton,
                                                  final JButton editButton,
                                                  final @NlsContexts.DialogMessage String modificationDialogTitle,
                                                  final String modificationDialogHint,
                                                  final @NlsContexts.StatusText String emptyListHint, DataAdapter<T, String> adapter) {
    list.setModel(model);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setCellRenderer(BuilderKt.textListCellRenderer(adapter::toPresentation));
    addButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        final T value = list.getSelectedValue();
        @NonNls String defaultValue = "https://";
        String initialValue = value == null ? defaultValue : adapter.toPresentation(value);
        final String text = Messages.showInputDialog(
          modificationDialogTitle, JavaUiBundle.message("dialog.title.add.repository.0", modificationDialogHint), Messages.getQuestionIcon(),
          initialValue, new URLInputValidator()
        );
        if (StringUtil.isNotEmpty(text)) {
          model.add(adapter.create(text));
          list.setSelectedValue(text, true);
        }
      }
    });
    editButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        final int index = list.getSelectedIndex();
        final T element = model.getElementAt(index);
        final String text = Messages.showInputDialog(
          modificationDialogTitle, JavaUiBundle.message("dialog.title.edit.repository.0", modificationDialogHint), Messages.getQuestionIcon(), adapter.toPresentation(element), new URLInputValidator()
        );
        if (StringUtil.isNotEmpty(text)) {
          model.setElementAt(adapter.change(element, text), index);
        }
      }
    });
    ListUtil.disableWhenNoSelection(editButton, list);
    list.getEmptyText().setText(emptyListHint);
  }
private static <T> void setupCommonListControls(final JBList<T> list,
                                                  final CollectionListModel<T> model,
                                                  final JButton addButton,
                                                  final JButton editButton,
                                                  final @NlsContexts.DialogMessage String modificationDialogTitle,
                                                  final String modificationDialogHint,
                                                  final @NlsContexts.StatusText String emptyListHint, DataAdapter<T, String> adapter)