List of usage examples for com.intellij.openapi.ui.popup ListPopup showCenteredInCurrentWindow
void showCenteredInCurrentWindow(@NotNull Project project);
From source file:com.intellij.ide.actions.QuickSwitchSchemeAction.java
License:Apache License
protected void showPopup(AnActionEvent e, ListPopup popup) { popup.showCenteredInCurrentWindow(e.getData(CommonDataKeys.PROJECT)); }
From source file:com.thoughtworks.gauge.annotator.CreateStepImplFix.java
License:Open Source License
@Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override//w w w.j ava2 s .co m public void run() { List<PsiFile> javaFiles = Gauge.getSubModules(GaugeUtil.moduleForPsiElement(file)).stream() .map(FileManager::getAllJavaFiles).flatMap(List::stream).collect(Collectors.toList()); javaFiles.add(0, NEW_FILE_HOLDER); ListPopup stepImplChooser = JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<PsiFile>("Choose implementation class", javaFiles) { @Override public boolean isSpeedSearchEnabled() { return true; } @Override public PopupStep onChosen(final PsiFile selectedValue, boolean finalChoice) { return doFinalStep(() -> { if (selectedValue == NEW_FILE_HOLDER) { createFileAndAddImpl(editor); } else { addImpl(project, selectedValue.getVirtualFile()); } }); } @Override public Icon getIconFor(PsiFile aValue) { return aValue == null ? AllIcons.Actions.CreateFromUsage : aValue.getIcon(0); } @NotNull @Override public String getTextFor(PsiFile value) { return value == null ? "Create new file" : getJavaFileName(value); } }); stepImplChooser.showCenteredInCurrentWindow(step.getProject()); } private String getJavaFileName(PsiFile value) { PsiJavaFile javaFile = (PsiJavaFile) value; if (!javaFile.getPackageName().equals("")) { return javaFile.getPackageName() + "." + javaFile.getName(); } return javaFile.getName(); } }); }
From source file:com.vladsch.MissingInActions.util.ui.ComboBoxAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { JComponent button = (JComponent) e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY); if (button == null) { Component contextComponent = e.getData(PlatformDataKeys.CONTEXT_COMPONENT); JRootPane rootPane = UIUtil.getParentOfType(JRootPane.class, contextComponent); if (rootPane != null) { button = (ComboBoxButton) UIUtil.uiTraverser(rootPane).bfsTraversal() .filter(component -> component instanceof ComboBoxButton && ((ComboBoxButton) component).getMyAction() == this) .first();/*from ww w.jav a2 s.c o m*/ } if (button == null) return; } //if (!button.isShowing()) return; if (button instanceof ComboBoxButton && button.isShowing()) { final Editor editor = e.getData(PlatformDataKeys.EDITOR); ((ComboBoxButton) button).myPresentation.putClientProperty(COMBO_BOX_EDITOR_PROPERTY, editor); ((ComboBoxButton) button).showPopup(); } else { DataContext context = e.getDataContext(); Project project = e.getProject(); if (project == null) return; final Editor editor = e.getData(PlatformDataKeys.EDITOR); DefaultActionGroup group = createPopupActionGroup(button, editor); ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(myPopupTitle, group, context, myShowNumbers, shouldShowDisabledActions(), false, null, getMaxRows(), getPreselectCondition()); popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight())); JComponent finalButton = button; popup.addListSelectionListener(ev -> { actionSelected(finalButton, editor, ev); }); popup.addListener(new JBPopupListener() { @Override public void beforeShown(final LightweightWindowEvent event) { popupStart(finalButton, editor); } @Override public void onClosed(final LightweightWindowEvent event) { popupDone(finalButton, editor); } }); popup.showCenteredInCurrentWindow(project); } }
From source file:org.intellij.ideaplugins.basictabsfilter.MainAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent event) { final Project eventProject = getEventProject(event); if (eventProject == null) { return;/*from www. jav a2 s. co m*/ } final FileEditorManagerImpl instance = (FileEditorManagerImpl) FileEditorManager.getInstance(eventProject); final DefaultActionGroup actionGroup = new DefaultActionGroup(); final VirtualFile[] allOpenFiles = instance.getOpenFiles(); for (VirtualFile file : allOpenFiles) { final String name = EditorUtil.INSTANCE.getText(eventProject, file); actionGroup.add(new SelectTabAction(name, file, eventProject)); } ListPopup actionGroupPopup = JBPopupFactory.getInstance().createActionGroupPopup("Go To Tab", actionGroup, event.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true); actionGroupPopup.showCenteredInCurrentWindow(eventProject); }
From source file:ru.scratch.OpenScratchListAction.java
License:Apache License
private void showListPopup(AnActionEvent event, DefaultActionGroup actionGroup, Project project) { JBPopupFactory factory = JBPopupFactory.getInstance(); ListPopup listPopup = factory.createActionGroupPopup(POPUP_TITLE, actionGroup, event.getDataContext(), NUMBERING, true);/* w ww .j a va 2s . co m*/ listPopup.showCenteredInCurrentWindow(project); }