public static void showPopup(AnActionEvent e, JBPopup popup) {
   final InputEvent event = e.getInputEvent();
   if (event instanceof MouseEvent) {
     popup.showUnderneathOf(event.getComponent());
   } else {
     popup.showInBestPositionFor(e.getDataContext());
   }
 }
  void execute(@NotNull AnActionEvent e, @NotNull ExecutionEnvironment environment) {
    MyRunProfile profile = getRunProfile(environment);
    if (profile == null) {
      return;
    }

    final ExecutionEnvironmentBuilder environmentBuilder =
        new ExecutionEnvironmentBuilder(environment).runProfile(profile);

    final InputEvent event = e.getInputEvent();
    if (!(event instanceof MouseEvent) || !event.isShiftDown()) {
      performAction(environmentBuilder);
      return;
    }

    final LinkedHashMap<Executor, ProgramRunner> availableRunners = new LinkedHashMap<>();
    for (Executor ex :
        new Executor[] {
          DefaultRunExecutor.getRunExecutorInstance(),
          DefaultDebugExecutor.getDebugExecutorInstance()
        }) {
      final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(ex.getId(), profile);
      if (runner != null) {
        availableRunners.put(ex, runner);
      }
    }

    if (availableRunners.isEmpty()) {
      LOG.error(environment.getExecutor().getActionName() + " is not available now");
    } else if (availableRunners.size() == 1) {
      //noinspection ConstantConditions
      performAction(environmentBuilder.runner(availableRunners.get(environment.getExecutor())));
    } else {
      final JBList list = new JBList(availableRunners.keySet());
      list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      list.setSelectedValue(environment.getExecutor(), true);
      list.setCellRenderer(
          new DefaultListCellRenderer() {
            @NotNull
            @Override
            public Component getListCellRendererComponent(
                @NotNull JList list,
                Object value,
                int index,
                boolean isSelected,
                boolean cellHasFocus) {
              final Component component =
                  super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
              if (value instanceof Executor) {
                setText(UIUtil.removeMnemonic(((Executor) value).getStartActionText()));
                setIcon(((Executor) value).getIcon());
              }
              return component;
            }
          });
      //noinspection ConstantConditions
      JBPopupFactory.getInstance()
          .createListPopupBuilder(list)
          .setTitle("Restart Failed Tests")
          .setMovable(false)
          .setResizable(false)
          .setRequestFocus(true)
          .setItemChoosenCallback(
              () -> {
                final Object value = list.getSelectedValue();
                if (value instanceof Executor) {
                  //noinspection ConstantConditions
                  performAction(
                      environmentBuilder
                          .runner(availableRunners.get(value))
                          .executor((Executor) value));
                }
              })
          .createPopup()
          .showUnderneathOf(event.getComponent());
    }
  }