Java Code Examples for com.intellij.openapi.ui.popup.ListPopup#showInBestPositionFor()
The following examples show how to use
com.intellij.openapi.ui.popup.ListPopup#showInBestPositionFor() .
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 File: GenerateAction.java From consulo with Apache License 2.0 | 6 votes |
@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 2
Source File: ExecuteAllAction.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@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 3
Source File: ExecuteQueryAction.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
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 4
Source File: DataSourceContextMenu.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@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 5
Source File: MetadataContextMenu.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@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 6
Source File: EntityContextMenu.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@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 7
Source File: ChangeFileEncodingAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public final void actionPerformed(@Nonnull final AnActionEvent e) { DataContext dataContext = e.getDataContext(); ListPopup popup = createPopup(dataContext); if (popup != null) { popup.showInBestPositionFor(dataContext); } }
Example 8
Source File: LossyEncodingInspection.java From consulo with Apache License 2.0 | 5 votes |
@Override public void applyFix(@Nonnull Project project, @Nonnull ProblemDescriptor descriptor) { PsiFile psiFile = descriptor.getPsiElement().getContainingFile(); VirtualFile virtualFile = psiFile.getVirtualFile(); Editor editor = PsiUtilBase.findEditor(psiFile); DataContext dataContext = createDataContext(editor, editor == null ? null : editor.getComponent(), virtualFile, project); ListPopup popup = new ChangeFileEncodingAction().createPopup(dataContext); if (popup != null) { popup.showInBestPositionFor(dataContext); } }
Example 9
Source File: SurroundWithTemplateHandler.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void invoke(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull 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); }
Example 10
Source File: ShowAddPackagingElementPopupAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final DefaultActionGroup group = new DefaultActionGroup(); for (PackagingElementType type : PackagingElementFactory.getInstance(e.getProject()).getAllElementTypes()) { group.add(new AddNewPackagingElementAction((PackagingElementType<?>)type, myArtifactEditor)); } final DataContext dataContext = e.getDataContext(); final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Add", group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); popup.showInBestPositionFor(dataContext); }
Example 11
Source File: SelectInAction.java From consulo with Apache License 2.0 | 5 votes |
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 { popup = JBPopupFactory.getInstance().createListPopup(new SelectInActionsStep(targetVector, context)); } popup.showInBestPositionFor(dataContext); }
Example 12
Source File: RefactoringQuickListPopupAction.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void showPopup(AnActionEvent e, ListPopup popup) { final Editor editor = e.getData(PlatformDataKeys.EDITOR); if (editor != null) { popup.showInBestPositionFor(editor); } else { super.showPopup(e, popup); } }
Example 13
Source File: TagTextIntention.java From weex-language-support with MIT License | 4 votes |
@Override public void invoke(@NotNull final Project project, final Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { Set<String> vars = new HashSet<String>(); boolean isFunc = false; if (guessFunction(element)) { vars = WeexFileUtil.getAllFunctionNames(element); isFunc = true; } else { vars = WeexFileUtil.getAllVarNames(element).keySet(); isFunc = false; } final boolean isFuncFinal = isFunc; ListPopup listPopup = JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<String>(null, vars.toArray(new String[vars.size()])) { @Override public Icon getIconFor(String value) { return isFuncFinal ? PlatformIcons.FUNCTION_ICON : PlatformIcons.VARIABLE_ICON; } @Override public PopupStep onChosen(final String selectedValue, final boolean finalChoice) { new WriteCommandAction(project) { @Override protected void run(@NotNull Result result) throws Throwable { editor.getDocument().insertString(editor.getCaretModel().getOffset(), "{{" + selectedValue + "}}"); int start = editor.getSelectionModel().getSelectionStart(); int end = editor.getSelectionModel().getSelectionEnd(); editor.getDocument().replaceString(start, end, ""); } }.execute(); return super.onChosen(selectedValue, finalChoice); } }); listPopup.setMinimumSize(new Dimension(240, -1)); listPopup.showInBestPositionFor(editor); }
Example 14
Source File: GitLabOpenInBrowserAction.java From IDEA-GitLab-Integration with MIT License | 4 votes |
@Override public void actionPerformed(final AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); final VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); final Editor editor = e.getData(PlatformDataKeys.EDITOR); if (virtualFile == null || project == null || project.isDisposed()) { return; } GitRepositoryManager manager = GitUtil.getRepositoryManager(project); final GitRepository repository = manager.getRepositoryForFile(virtualFile); if (repository == null) { StringBuilder details = new StringBuilder("file: " + virtualFile.getPresentableUrl() + "; Git repositories: "); for (GitRepository repo : manager.getRepositories()) { details.append(repo.getPresentableUrl()).append("; "); } showError(project, CANNOT_OPEN_IN_BROWSER, "Can't find git repository", details.toString()); return; } final String rootPath = repository.getRoot().getPath(); final String path = virtualFile.getPath(); List<AnAction> remoteSelectedActions = new ArrayList<AnAction>(); for (GitRemote remote : repository.getRemotes()) { remoteSelectedActions.add(new RemoteSelectedAction(project, repository, editor, remote, rootPath, path)); } if (remoteSelectedActions.size() > 1) { DefaultActionGroup remotesActionGroup = new DefaultActionGroup(); remotesActionGroup.addAll(remoteSelectedActions); DataContext dataContext = e.getDataContext(); final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup( "Select remote", remotesActionGroup, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true); popup.showInBestPositionFor(dataContext); } else if (remoteSelectedActions.size() == 1) { remoteSelectedActions.get(0).actionPerformed(null); } else { showError(project, CANNOT_OPEN_IN_BROWSER, "Can't find gitlab remote"); } }