List of usage examples for com.intellij.openapi.ui.popup ListPopup showInBestPositionFor
void showInBestPositionFor(@NotNull DataContext dataContext);
From source file:com.intellij.codeInsight.generation.actions.GenerateAction.java
License:Apache License
@Override public void actionPerformed(final AnActionEvent e) { DataContext dataContext = e.getDataContext(); final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup( CodeInsightBundle.message("generate.list.popup.title"), getGroup(), dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); popup.showInBestPositionFor(dataContext); }
From source file:com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler.java
License:Apache License
@RequiredDispatchThread @Override//from w w w. ja va 2s . co m public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) { if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return; DefaultActionGroup group = createActionGroup(project, editor, file); if (group == null) return; final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup( CodeInsightBundle.message("templates.select.template.chooser.title"), group, DataManager.getInstance().getDataContext(editor.getContentComponent()), JBPopupFactory.ActionSelectionAid.MNEMONICS, false); popup.showInBestPositionFor(editor); }
From source file:com.intellij.execution.actions.BaseRunConfigurationAction.java
License:Apache License
@Override public void actionPerformed(final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext); final RunnerAndConfigurationSettings existing = context.findExisting(); if (existing == null) { final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context); if (producers.isEmpty()) return; if (producers.size() > 1) { final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); Collections.sort(producers, ConfigurationFromContext.NAME_COMPARATOR); final ListPopup popup = JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<ConfigurationFromContext>( ExecutionBundle.message("configuration.action.chooser.title"), producers) { @Override @NotNull/*from w ww . j av a2s . c om*/ public String getTextFor(final ConfigurationFromContext producer) { return producer.getConfigurationType().getDisplayName(); } @Override public Icon getIconFor(final ConfigurationFromContext producer) { return producer.getConfigurationType().getIcon(); } @Override public PopupStep onChosen(final ConfigurationFromContext producer, final boolean finalChoice) { perform(producer, context); return FINAL_CHOICE; } }); final InputEvent event = e.getInputEvent(); if (event instanceof MouseEvent) { popup.show(new RelativePoint((MouseEvent) event)); } else if (editor != null) { popup.showInBestPositionFor(editor); } else { popup.showInBestPositionFor(dataContext); } } else { perform(producers.get(0), context); } return; } perform(context); }
From source file:com.intellij.ide.actions.GotoActionAction.java
License:Apache License
public static void performAction(Object element, @Nullable final Component component, @Nullable final AnActionEvent e) { // element could be AnAction (SearchEverywhere) final AnAction action = element instanceof AnAction ? (AnAction) element : ((GotoActionModel.ActionWrapper) element).getAction(); if (action != null) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override//w ww .ja v a 2s . co m public void run() { if (component == null) return; Presentation presentation = action.getTemplatePresentation().clone(); DataContext context = DataManager.getInstance().getDataContext(component); AnActionEvent event = new AnActionEvent(e == null ? null : e.getInputEvent(), context, ActionPlaces.ACTION_SEARCH, presentation, ActionManager.getInstance(), e == null ? 0 : e.getModifiers()); if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) { if (action instanceof ActionGroup && ((ActionGroup) action).getChildren(event).length > 0) { ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup( presentation.getText(), (ActionGroup) action, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); if (component.isShowing()) { popup.showInBestPositionFor(context); } else { popup.showInFocusCenter(); } } else { ActionUtil.performActionDumbAware(action, event); } } } }, ModalityState.NON_MODAL); } }
From source file:com.intellij.ide.actions.SelectInAction.java
License:Apache License
private static void invoke(DataContext dataContext, SelectInContext context) { final List<SelectInTarget> targetVector = Arrays .asList(getSelectInManager(context.getProject()).getTargets()); ListPopup popup; if (targetVector.isEmpty()) { DefaultActionGroup group = new DefaultActionGroup(); group.add(new NoTargetsAction()); popup = JBPopupFactory.getInstance().createActionGroupPopup( IdeBundle.message("title.popup.select.target"), group, dataContext, JBPopupFactory.ActionSelectionAid.MNEMONICS, true); } else {//from ww w . j av a2 s. c o m popup = JBPopupFactory.getInstance().createListPopup(new SelectInActionsStep(targetVector, context)); } popup.showInBestPositionFor(dataContext); }
From source file:com.intellij.ide.actions.ShowFilePathAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { show(getFile(e), new ShowAction() { @Override//from w ww . j av a2s. c o m public void show(final ListPopup popup) { DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() { @Override public void consume(DataContext context) { popup.showInBestPositionFor(context); } }); } }); }
From source file:com.intellij.refactoring.actions.RefactoringQuickListPopupAction.java
License:Apache License
@Override protected void showPopup(AnActionEvent e, ListPopup popup) { final Editor editor = e.getData(PlatformDataKeys.EDITOR); if (editor != null) { popup.showInBestPositionFor(editor); } else {//from w w w. j av a2 s .co m super.showPopup(e, popup); } }
From source file:com.intellij.util.xml.tree.actions.AddElementInCollectionAction.java
License:Apache License
protected void showPopup(final ListPopup groupPopup, final AnActionEvent e) { if (myTreeView == null) { if (e.getPlace().equals(DomModelTreeView.DOM_MODEL_TREE_VIEW_POPUP)) { groupPopup.showInCenterOf(getTreeView(e).getTree()); } else {//from w w w . j a v a2 s .c o m groupPopup.showInBestPositionFor(e.getDataContext()); } } else { super.showPopup(groupPopup, e); } }
From source file:com.intellij.util.xml.ui.actions.AddDomElementAction.java
License:Apache License
protected void showPopup(final ListPopup groupPopup, final AnActionEvent e) { final Component component = e.getInputEvent().getComponent(); if (component instanceof ActionButtonComponent) { groupPopup.showUnderneathOf(component); } else {/*w w w. ja va 2 s .co m*/ groupPopup.showInBestPositionFor(e.getDataContext()); } }
From source file:com.mnr.java.intellij.idea.plugin.base64helper.MainActionHandler.java
License:Apache License
private EditorActionHandler getEditorActionHandler() { return new EditorActionHandler() { @Override/*from w w w . j a v a2 s .c o m*/ protected void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) { ListPopup listPopup = getListPopup(editor); listPopup.showInBestPositionFor(editor); } }; }