Java Code Examples for com.intellij.openapi.ui.popup.ListPopup

The following examples show how to use com.intellij.openapi.ui.popup.ListPopup. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lsp4intellij   Source File: LSPServerStatusWidget.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Consumer<MouseEvent> getClickConsumer() {
    return (MouseEvent t) -> {
        JBPopupFactory.ActionSelectionAid mnemonics = JBPopupFactory.ActionSelectionAid.MNEMONICS;
        Component component = t.getComponent();
        List<AnAction> actions = new ArrayList<>();
        if (wrapper.getStatus() == ServerStatus.INITIALIZED) {
            actions.add(new ShowConnectedFiles());
        }
        actions.add(new ShowTimeouts());
        if (wrapper.isRestartable()) {
            actions.add(new Restart());
        }

        String title = "Server actions";
        DataContext context = DataManager.getInstance().getDataContext(component);
        DefaultActionGroup group = new DefaultActionGroup(actions);
        ListPopup popup = JBPopupFactory.getInstance()
                .createActionGroupPopup(title, group, context, mnemonics, true);
        Dimension dimension = popup.getContent().getPreferredSize();
        Point at = new Point(0, -dimension.height);
        popup.show(new RelativePoint(t.getComponent(), at));
    };
}
 
Example 2
Source Project: consulo   Source File: IntelliSortChooserPopupAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  VcsLogUi logUI = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogUiProperties properties = e.getRequiredData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);

  ActionGroup settingsGroup = new DefaultActionGroup(
          ContainerUtil.map(PermanentGraph.SortType.values(), (Function<PermanentGraph.SortType, AnAction>)sortType -> new SelectIntelliSortTypeAction(logUI, properties, sortType)));


  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, settingsGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUI.POPUP_PLACE);
  Component component = e.getInputEvent().getComponent();
  if (component instanceof ActionButtonComponent) {
    popup.showUnderneathOf(component);
  }
  else {
    popup.showInCenterOf(component);
  }
}
 
Example 3
Source Project: consulo   Source File: WelcomePopupAction.java    License: Apache License 2.0 6 votes vote down vote up
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
  Component focusedComponent = contextComponent != null ? contextComponent : context.getData(PlatformDataKeys.CONTEXT_COMPONENT);
  if (focusedComponent != null) {
    if (popup instanceof PopupFactoryImpl.ActionGroupPopup && focusedComponent instanceof JLabel) {
      ((PopupFactoryImpl.ActionGroupPopup)popup).showUnderneathOfLabel((JLabel)focusedComponent);
    } else {
      popup.showUnderneathOf(focusedComponent);
    }
  }
  else {
    Rectangle r;
    int x;
    int y;
    focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
    r = WindowManagerEx.getInstanceEx().getScreenBounds();
    x = r.x + r.width / 2;
    y = r.y + r.height / 2;
    Point point = new Point(x, y);
    SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());

    popup.showInScreenCoordinates(focusedComponent.getParent(), point);
  }
}
 
Example 4
Source Project: consulo   Source File: IdeStatusBarImpl.java    License: Apache License 2.0 6 votes vote down vote up
private MultipleTextValuesPresentationWrapper(@Nonnull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  myPresentation = presentation;
  setVisible(StringUtil.isNotEmpty(myPresentation.getSelectedValue()));
  setTextAlignment(Component.CENTER_ALIGNMENT);
  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);
}
 
Example 5
Source Project: consulo   Source File: ChangeFileEncodingAction.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
public ListPopup createPopup(@Nonnull DataContext dataContext) {
  final VirtualFile virtualFile = dataContext.getData(CommonDataKeys.VIRTUAL_FILE);
  if (virtualFile == null) return null;
  boolean enabled = checkEnabled(virtualFile);
  if (!enabled) return null;
  Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
  FileDocumentManager documentManager = FileDocumentManager.getInstance();
  final Document document = documentManager.getDocument(virtualFile);
  if (!allowDirectories && virtualFile.isDirectory() || document == null && !virtualFile.isDirectory()) return null;

  final byte[] bytes;
  try {
    bytes = virtualFile.isDirectory() ? null : VfsUtilCore.loadBytes(virtualFile);
  }
  catch (IOException e) {
    return null;
  }
  DefaultActionGroup group = createActionGroup(virtualFile, editor, document, bytes, null);

  return JBPopupFactory.getInstance().createActionGroupPopup(getTemplatePresentation().getText(), group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
}
 
Example 6
Source Project: consulo   Source File: ShowFilePathAction.java    License: Apache License 2.0 6 votes vote down vote up
private static ListPopup createPopup(List<VirtualFile> files, List<Image> icons) {
  final BaseListPopupStep<VirtualFile> step = new BaseListPopupStep<VirtualFile>("File Path", files, icons.stream().map(TargetAWT::to).collect(Collectors.toList())) {
    @Nonnull
    @Override
    public String getTextFor(final VirtualFile value) {
      return value.getPresentableName();
    }

    @Override
    public PopupStep onChosen(final VirtualFile selectedValue, final boolean finalChoice) {
      final File selectedFile = new File(getPresentableUrl(selectedValue));
      if (selectedFile.exists()) {
        Application.get().executeOnPooledThread((Runnable)() -> openFile(selectedFile));
      }
      return FINAL_CHOICE;
    }
  };

  return JBPopupFactory.getInstance().createListPopup(step);
}
 
Example 7
Source Project: consulo   Source File: XDebuggerEditorBase.java    License: Apache License 2.0 6 votes vote down vote up
private ListPopup createLanguagePopup() {
  DefaultActionGroup actions = new DefaultActionGroup();
  for (Language language : getSupportedLanguages()) {
    //noinspection ConstantConditions
    actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {
      @RequiredUIAccess
      @Override
      public void actionPerformed(@Nonnull AnActionEvent e) {
        XExpression currentExpression = getExpression();
        setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
        requestFocusInEditor();
      }
    });
  }

  DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
  return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext,
                                                             JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                             false);
}
 
Example 8
Source Project: consulo   Source File: GenerateAction.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull final AnActionEvent e) {
  DataContext dataContext = e.getDataContext();

  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  final ListPopup popup =
          JBPopupFactory.getInstance().createActionGroupPopup(
                  CodeInsightBundle.message("generate.list.popup.title"),
                  wrapGroup(getGroup(), dataContext, project),
                  dataContext,
                  JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                  false);

  popup.showInBestPositionFor(dataContext);
}
 
Example 9
Source Project: consulo   Source File: LookupImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void showElementActions(@Nullable InputEvent event) {
  if (!isVisible()) return;

  LookupElement element = getCurrentItem();
  if (element == null) {
    return;
  }

  Collection<LookupElementAction> actions = getActionsFor(element);
  if (actions.isEmpty()) {
    return;
  }

  //UIEventLogger.logUIEvent(UIEventId.LookupShowElementActions);

  Rectangle itemBounds = getCurrentItemBounds();
  Rectangle visibleRect = SwingUtilities.convertRectangle(myList, myList.getVisibleRect(), getComponent());
  ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(new LookupActionsStep(actions, this, element));
  Point p = (itemBounds.intersects(visibleRect) || event == null)
            ? new Point(itemBounds.x + itemBounds.width, itemBounds.y)
            : SwingUtilities.convertPoint(event.getComponent(), new Point(0, event.getComponent().getHeight() + JBUIScale.scale(2)), getComponent());

  listPopup.show(new RelativePoint(getComponent(), p));
}
 
Example 10
Source Project: otto-intellij-plugin   Source File: PickAction.java    License: Apache License 2.0 6 votes vote down vote up
public static void startPicker(Type[] displayedTypes, RelativePoint relativePoint,
                               final Callback callback) {

  ListPopup listPopup = JBPopupFactory.getInstance()
      .createListPopup(new BaseListPopupStep<Type>("Select Type", displayedTypes) {
        @NotNull @Override public String getTextFor(Type value) {
          return value.toString();
        }

        @Override public PopupStep onChosen(Type selectedValue, boolean finalChoice) {
          callback.onTypeChose(selectedValue);
          return super.onChosen(selectedValue, finalChoice);
        }
      });

  listPopup.show(relativePoint);
}
 
Example 11
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) return;

  JFrame frame = WindowManager.getInstance().getFrame(project);
  if (!(frame instanceof IdeFrame)) return;

  ListPopup popup = createActionPopup(e.getDataContext(), ((IdeFrame)frame).getComponent(), null);
  popup.showCenteredInCurrentWindow(project);
}
 
Example 12
@NotNull
private ListPopup createActionPopup(@NotNull DataContext context, @NotNull JComponent component, @Nullable Runnable disposeCallback) {
  DefaultActionGroup group = createPopupActionGroup(component, context);
  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
    myPopupTitle, group, context, false, shouldShowDisabledActions(), false, disposeCallback, getMaxRows(), getPreselectCondition());
  popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
  return popup;
}
 
Example 13
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) return;

  JFrame frame = WindowManager.getInstance().getFrame(project);
  if (!(frame instanceof IdeFrame)) return;

  ListPopup popup = createActionPopup(e.getDataContext(), ((IdeFrame)frame).getComponent(), null);
  popup.showCenteredInCurrentWindow(project);
}
 
Example 14
@NotNull
private ListPopup createActionPopup(@NotNull DataContext context, @NotNull JComponent component, @Nullable Runnable disposeCallback) {
  DefaultActionGroup group = createPopupActionGroup(component, context);
  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
    myPopupTitle, group, context, false, shouldShowDisabledActions(), false, disposeCallback, getMaxRows(), getPreselectCondition());
  popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
  return popup;
}
 
Example 15
@Override
public void actionPerformed(AnActionEvent e) {
    Project project = getEventProject(e);
    if (project == null) {
        Notifier.error("Query execution error", "No project present.");
        return;
    }
    MessageBus messageBus = project.getMessageBus();
    ParametersService parameterService = ServiceManager.getService(project, ParametersService.class);
    PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);

    StatementCollector statementCollector = new StatementCollector(messageBus, parameterService);

    // This should never happen
    if (psiFile == null) {
        Notifier.error("Internal error", "No PsiFile present.");
    }
    psiFile.acceptChildren(statementCollector);
    if (!statementCollector.hasErrors()) {
        ExecuteQueryPayload executeQueryPayload =
            new ExecuteQueryPayload(statementCollector.getQueries(), statementCollector.getParameters(), psiFile.getName());
        ConsoleToolWindow.ensureOpen(project);

        DataSourcesComponent dataSourcesComponent = project.getComponent(DataSourcesComponent.class);
        ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            "Choose Data Source",
            new ChooseDataSourceActionGroup(messageBus, dataSourcesComponent, executeQueryPayload),
            e.getDataContext(),
            JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
            false
        );
        popup.showInBestPositionFor(e.getDataContext());
    } else {
        Notifier.error("Query execution error", "File contains errors");
    }
}
 
Example 16
protected void actionPerformed(AnActionEvent e, Project project, Editor editor, String query, Map<String, Object> parameters) {
    VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
    MessageBus messageBus = project.getMessageBus();
    DataSourcesComponent dataSourcesComponent = project.getComponent(DataSourcesComponent.class);

    query = decorateQuery(query);

    ExecuteQueryPayload executeQueryPayload = new ExecuteQueryPayload(query, parameters, editor);
    ConsoleToolWindow.ensureOpen(project);

    if (nonNull(virtualFile)) {
        String fileName = virtualFile.getName();
        if (fileName.startsWith(GraphConstants.BOUND_DATA_SOURCE_PREFIX)) {
            Optional<? extends DataSourceApi> boundDataSource = dataSourcesComponent.getDataSourceContainer()
                    .findDataSource(NameUtil.extractDataSourceUUID(fileName));
            if (boundDataSource.isPresent()) {
                executeQuery(messageBus, boundDataSource.get(), executeQueryPayload);
                return;
            }
        }
    }

    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            "Choose Data Source",
            new ChooseDataSourceActionGroup(messageBus, dataSourcesComponent, executeQueryPayload),
            e.getDataContext(),
            JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
            false
    );

    Component eventComponent = e.getInputEvent().getComponent();
    if (eventComponent instanceof ActionButtonComponent) {
        popup.showUnderneathOf(eventComponent);
    } else {
        popup.showInBestPositionFor(e.getDataContext());
    }
}
 
Example 17
private void initAddAction() {
    decorator.setAddAction(anActionButton -> {
        ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
                "New Data Source",
                new NewDataSourceActionGroup(project, dataSourcesView),
                anActionButton.getDataContext(),
                JBPopupFactory.ActionSelectionAid.NUMBERING,
                true
        );
        popup.show(anActionButton.getPreferredPopupPoint());
    });
}
 
Example 18
@Override
public void showPopup(DataContext dataContext) {
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            dataSourceApi.getName(),
            new DataSourceActionGroup(dataSourceApi),
            dataContext,
            JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
            true
    );

    popup.showInBestPositionFor(dataContext);
}
 
Example 19
@Override
public void showPopup(DataContext dataContext) {
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            data,
            new MetadataActionGroup(metadataType, data, dataSourceApi.getUUID()),
            dataContext,
            JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
            true
    );

    popup.showInBestPositionFor(dataContext);
}
 
Example 20
@Override
public void showPopup(DataContext dataContext) {
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            entity.getRepresentation(),
            new EntityActionGroup(dataSourceApi, entity),
            dataContext,
            JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
            true
    );

    popup.showInBestPositionFor(dataContext);
}
 
Example 21
Source Project: azure-devops-intellij   Source File: FilterDropDown.java    License: MIT License 5 votes vote down vote up
/**
 * Displays the dropdown menu with the latest items
 */
private void showDropDownMenu() {
    if (isEnabled) {
        final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(this), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
        popup.showUnderneathOf(this);
    }
}
 
Example 22
@Override
public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) {

    final String introspect = "Get GraphQL Schema from Endpoint (introspection)";
    final String createScratch = "New GraphQL Scratch File (for query, mutation testing)";
    ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Choose Endpoint Action", introspect, createScratch) {

        @Override
        public PopupStep onChosen(String selectedValue, boolean finalChoice) {
            return doFinalStep(() -> {
                if (introspect.equals(selectedValue)) {
                    GraphQLIntrospectionHelper.getService(myProject).performIntrospectionQueryAndUpdateSchemaPathFile(myProject, endpoint);
                } else if (createScratch.equals(selectedValue)) {
                    final String configBaseDir = endpoint.configPackageSet.getConfigBaseDir().getPresentableUrl();
                    final String text = "# " + GRAPHQLCONFIG_COMMENT + configBaseDir + "!" + Optional.ofNullable(projectKey).orElse("") + "\n\nquery ScratchQuery {\n\n}";
                    final VirtualFile scratchFile = ScratchRootType.getInstance().createScratchFile(myProject, "scratch.graphql", GraphQLLanguage.INSTANCE, text);
                    if (scratchFile != null) {
                        FileEditor[] fileEditors = FileEditorManager.getInstance(myProject).openFile(scratchFile, true);
                        for (FileEditor editor : fileEditors) {
                            if (editor instanceof TextEditor) {
                                final JSGraphQLEndpointsModel endpointsModel = ((TextEditor) editor).getEditor().getUserData(JS_GRAPH_QL_ENDPOINTS_MODEL);
                                if (endpointsModel != null) {
                                    endpointsModel.setSelectedItem(endpoint);
                                }
                            }
                        }
                    }
                }
            });
        }
    });
    if (inputEvent instanceof KeyEvent) {
        listPopup.showInFocusCenter();
    } else if (inputEvent instanceof MouseEvent) {
        listPopup.show(new RelativePoint((MouseEvent) inputEvent));
    }
}
 
Example 23
Source Project: p4ic4idea   Source File: ConfigPartStack.java    License: Apache License 2.0 5 votes vote down vote up
private void showAddItemPopup() {
    final ListPopup popup = createConfigPartPopup(factory -> {
        if (factory != null) {
            addChildFirst(factory.createEmpty(vcsRoot, connectionController));
        }
    });
    popup.showUnderneathOf(myAddItemButton);
}
 
Example 24
Source Project: GitToolBox   Source File: GitStatusWidget.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ListPopup getPopupStep() {
  if (visible.get() && rootActions.update()) {
    String title = ResBundle.message("statusBar.status.menu.title");
    return new StatusActionGroupPopup(title, rootActions, myProject, Conditions.alwaysTrue());
  } else {
    return null;
  }
}
 
Example 25
@Override
protected PanelTestingFrame getPanelTestingFrame() {
    executor = mock(XQueryDataSourceTypeBasedActionExecutor.class);
    popup = new DataSourceTypesListPopup(executor);
    final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(popup);

    mainPanel = (JPanel) listPopup.getContent();
    listPopup.show((Component) null);
    return new PanelTestingFrame(mainPanel);
}
 
Example 26
Source Project: EclipseCodeFormatter   Source File: ProjectSettingsForm.java    License: Apache License 2.0 5 votes vote down vote up
public ListPopup createConfirmation(String title, final String yesText, String noText, final Runnable onYes, final Runnable onNo, int defaultOptionIndex) {

		final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) {
			@Override
			public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
				if (selectedValue.equals(yesText)) {
					onYes.run();
				} else {
					onNo.run();
				}
				return FINAL_CHOICE;
			}

			@Override
			public void canceled() {
			}

			@Override
			public boolean isMnemonicsNavigationEnabled() {
				return true;
			}
		};
		step.setDefaultOptionIndex(defaultOptionIndex);

		final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
		return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
	}
 
Example 27
Source Project: dagger-intellij-plugin   Source File: PickTypeAction.java    License: Apache License 2.0 5 votes vote down vote up
public void startPickTypes(RelativePoint relativePoint, PsiParameter[] psiParameters,
    final Callback callback) {
  if (psiParameters.length == 0) return;

  ListPopup listPopup = JBPopupFactory.getInstance()
      .createListPopup(new BaseListPopupStep<PsiParameter>("Select Type", psiParameters) {
        @NotNull @Override public String getTextFor(PsiParameter value) {
          StringBuilder builder = new StringBuilder();

          Set<String> annotations = PsiConsultantImpl.getQualifierAnnotations(value);
          for (String annotation : annotations) {
            String trimmed = annotation.substring(annotation.lastIndexOf(".") + 1);
            builder.append("@").append(trimmed).append(" ");
          }

          PsiClass notLazyOrProvider = PsiConsultantImpl.checkForLazyOrProvider(value);
          return builder.append(notLazyOrProvider.getName()).toString();
        }

        @Override public PopupStep onChosen(PsiParameter selectedValue, boolean finalChoice) {
          callback.onParameterChosen(selectedValue);
          return super.onChosen(selectedValue, finalChoice);
        }
      });

  listPopup.show(relativePoint);
}
 
Example 28
Source Project: consulo   Source File: MasterDetailsComponent.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  final ListPopupStep step = popupFactory.createActionsStep(myActionGroup, e.getDataContext(), false, false,
                                                            myActionGroup.getTemplatePresentation().getText(), myTree, true,
                                                            myPreselection != null ? myPreselection.getDefaultIndex() : 0, true);
  final ListPopup listPopup = popupFactory.createListPopup(step);
  listPopup.setHandleAutoSelectionBeforeShow(true);
  listPopup.showUnderneathOf(myNorthPanel);
}
 
Example 29
Source Project: consulo   Source File: QuickSwitchSchemeAction.java    License: Apache License 2.0 5 votes vote down vote up
private void showPopup(AnActionEvent e, DefaultActionGroup group) {
  if (!myShowPopupWithNoActions && group.getChildrenCount() == 0) return;
  final ListPopup popup = JBPopupFactory.getInstance()
    .createActionGroupPopup(getPopupTitle(e),
                            group,
                            e.getDataContext(), getAidMethod(),
                            true, myActionPlace);

  showPopup(e, popup);
}
 
Example 30
Source Project: consulo   Source File: VcsLogGearActionGroup.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  DefaultActionGroup group = new DefaultActionGroup(ActionManager.getInstance().getAction(myActionGroup));

  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUI.POPUP_PLACE);
  Component component = e.getInputEvent().getComponent();
  if (component instanceof ActionButtonComponent) {
    popup.showUnderneathOf(component);
  }
  else {
    popup.showInCenterOf(component);
  }
}