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());
   }
 }
 @Override
 public void actionPerformed(AnActionEvent e) {
   JPanel result = new JPanel(new BorderLayout());
   JLabel label = new JLabel("Lines around:");
   label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0));
   JPanel wrapper = new JPanel(new BorderLayout());
   wrapper.add(label, BorderLayout.NORTH);
   result.add(wrapper, BorderLayout.WEST);
   final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1);
   slider.setMinorTickSpacing(1);
   slider.setPaintTicks(true);
   slider.setPaintTrack(true);
   slider.setSnapToTicks(true);
   UIUtil.setSliderIsFilled(slider, true);
   slider.setPaintLabels(true);
   slider.setLabelTable(LABELS);
   result.add(slider, BorderLayout.CENTER);
   final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject);
   for (int i = 0; i < ourMarks.length; i++) {
     int mark = ourMarks[i];
     if (mark == configuration.SHORT_DIFF_EXTRA_LINES) {
       slider.setValue(i + 1);
     }
   }
   JBPopup popup =
       JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).createPopup();
   popup.setFinalRunnable(
       new Runnable() {
         @Override
         public void run() {
           int value = slider.getModel().getValue();
           if (configuration.SHORT_DIFF_EXTRA_LINES != ourMarks[value - 1]) {
             configuration.SHORT_DIFF_EXTRA_LINES = ourMarks[value - 1];
             myFragmentedContent.recalculate();
             refreshData(myFragmentedContent);
           }
         }
       });
   InputEvent inputEvent = e.getInputEvent();
   if (inputEvent instanceof MouseEvent) {
     int width = result.getPreferredSize().width;
     MouseEvent inputEvent1 = (MouseEvent) inputEvent;
     Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY());
     RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1);
     popup.show(point);
   } else {
     popup.showInBestPositionFor(e.getDataContext());
   }
 }
 @Override
 public void actionPerformed(AnActionEvent e) {
   final DefaultActionGroup dag = new DefaultActionGroup();
   dag.add(myUsual);
   dag.add(myNumbered);
   dag.add(mySoftWrapsAction);
   final ListPopup popup =
       JBPopupFactory.getInstance()
           .createActionGroupPopup(
               null,
               dag,
               e.getDataContext(),
               JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
               false);
   if (e.getInputEvent() instanceof MouseEvent) {
     popup.show(new RelativePoint((MouseEvent) e.getInputEvent()));
   } else {
     // todo correct
     /*final Dimension dimension = popup.getContent().getPreferredSize();
     final Point at = new Point(-dimension.width / 2, 0);
     popup.show(new RelativePoint(myParent, at));*/
     popup.showInBestPositionFor(e.getDataContext());
   }
 }
 private AnActionEvent stopConsole(AnActionEvent e) {
   if (myPydevConsoleCommunication != null) {
     e =
         new AnActionEvent(
             e.getInputEvent(),
             e.getDataContext(),
             e.getPlace(),
             e.getPresentation(),
             e.getActionManager(),
             e.getModifiers());
     try {
       closeCommunication();
       // waiting for REPL communication before destroying process handler
       Thread.sleep(300);
     } catch (Exception ignored) {
       // Ignore
     }
   }
   return e;
 }