List of usage examples for com.intellij.openapi.ui.popup ListPopup showInCenterOf
void showInCenterOf(@NotNull Component component);
From source file:com.atlassian.theplugin.idea.action.issues.RecentlyOpenIssuesAction.java
License:Apache License
@Override public void actionPerformed(final AnActionEvent e) { final Project project = IdeaHelper.getCurrentProject(e); if (project == null) { return;/*from ww w . ja v a2 s . co m*/ } final IssueListToolWindowPanel issuesWindow = IdeaHelper.getIssueListToolWindowPanel(e); if (issuesWindow == null) { return; } final JiraWorkspaceConfiguration conf = IdeaHelper.getProjectComponent(e, JiraWorkspaceConfiguration.class); if (conf == null) { return; } final List<IssueRecentlyOpenBean> recentlyOpenIssues = conf.getRecentlyOpenIssuess(); if (recentlyOpenIssues.size() > 0) { // prepare list of recentlyOpenIssues from the config list List<JiraIssueAdapter> issues = issuesWindow.getLoadedRecenltyOpenIssues(); ListPopup popup = JBPopupFactory.getInstance() .createListPopup(new IssueListPopupStep("Recently Viewed Issues", issues, issuesWindow)); // popup.showCenteredInCurrentWindow(project); that can cause NPE inside IDEA OpenAPI popup.showInCenterOf(e.getInputEvent().getComponent()); } else { Messages.showInfoMessage(project, "No recently viewed issues found.", PluginUtil.PRODUCT_NAME); } }
From source file:com.atlassian.theplugin.idea.config.TestDefaultCredentials.java
License:Apache License
public void run(Collection<ServerDataExt> servers) { if (servers != null && servers.size() > 0) { for (ServerDataExt server : servers) { switch (server.getServerType()) { case BAMBOO_SERVER: testGenericConnection(server.getServerData(), bambooServerFacade); break; case JIRA_SERVER: testGenericConnection(server.getServerData(), jiraServerFacade); break; default: PluginUtil.getLogger().warn("Unknown host type " + server); }/*from w w w. ja v a 2 s .co m*/ } final ArrayList<ServerData> serverDatas = MiscUtil.buildArrayList(); for (ServerDataExt server : servers) { serverDatas.add(server.getServerData()); } final DefaultCredentialsServerList list = new DefaultCredentialsServerList( "Default credentials tests result", serverDatas); ListPopup popup = JBPopupFactory.getInstance().createListPopup(list); // popup.showCenteredInCurrentWindow(project); that can cause NPE inside IDEA OpenAPI popup.showInCenterOf(parentComponent); } else { Messages.showInfoMessage(project, "None of servers configuration use default credentials", "Default credentials"); } }
From source file:com.intellij.uiDesigner.actions.CreateComponentAction.java
License:Apache License
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) { Processor<ComponentItem> processor = new Processor<ComponentItem>() { public boolean process(final ComponentItem selectedValue) { if (selectedValue != null) { myLastCreatedComponent = selectedValue; editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection)); }/*from www. ja v a 2 s . co m*/ return true; } }; PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor, UIDesignerBundle.message("create.component.title")); final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step); if (selection.size() > 0) { FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0)); } else { listPopup.showInCenterOf(editor.getRootContainer().getDelegee()); } }
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 {// w w w. ja va 2 s .c o m groupPopup.showInBestPositionFor(e.getDataContext()); } } else { super.showPopup(groupPopup, e); } }
From source file:org.mustbe.consulo.microsoft.dotnet.sdk.MicrosoftDotNetSdkType.java
License:Apache License
@Override public void showCustomCreateUI(SdkModel sdkModel, JComponent parentComponent, final Consumer<Sdk> sdkCreatedCallback) { FileChooserDescriptor singleFolderDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); VirtualFile microNetVirtualFile = FileChooser.chooseFile(singleFolderDescriptor, null, LocalFileSystem.getInstance().findFileByIoFile(new File(suggestHomePath()))); if (microNetVirtualFile == null) { return;/*w w w . jav a 2 s . c o m*/ } File microNet = VfsUtil.virtualToIoFile(microNetVirtualFile); List<Pair<String, File>> list = getValidSdkDirs(microNet); val thisSdks = SdkTable.getInstance().getSdksOfType(this); DefaultActionGroup actionGroup = new DefaultActionGroup(); for (val pair : list) { actionGroup.add(new AnAction(pair.getFirst()) { @Override public void actionPerformed(AnActionEvent anActionEvent) { val path = pair.getSecond(); val absolutePath = path.getAbsolutePath(); String uniqueSdkName = SdkConfigurationUtil.createUniqueSdkName(MicrosoftDotNetSdkType.this, absolutePath, thisSdks); SdkImpl sdk = new SdkImpl(uniqueSdkName, MicrosoftDotNetSdkType.this); sdk.setVersionString(getVersionString(absolutePath)); sdk.setHomePath(absolutePath); sdkCreatedCallback.consume(sdk); } }); } DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent); ListPopup choose = JBPopupFactory.getInstance().createActionGroupPopup("Choose", actionGroup, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); choose.showInCenterOf(parentComponent); }
From source file:org.mustbe.consulo.mono.dotnet.sdk.MonoSdkType.java
License:Apache License
@Override public void showCustomCreateUI(SdkModel sdkModel, JComponent parentComponent, final Consumer<Sdk> sdkCreatedCallback) { File monoLib = null;//from www.j a v a2 s . c o m if (SystemInfo.isLinux) { File file = new File(LINUX_COMPILER); if (!file.exists()) { Messages.showErrorDialog(parentComponent, "\'" + LINUX_COMPILER + "\' not found."); return; } monoLib = new File("/usr/lib/mono"); } else if (SystemInfo.isWindows || SystemInfo.isMac) { FileChooserDescriptor singleFolderDescriptor = FileChooserDescriptorFactory .createSingleFolderDescriptor(); val toSelectPath = suggestHomePath(); val toSelect = toSelectPath == null ? null : LocalFileSystem.getInstance().findFileByPath(toSelectPath); VirtualFile monoDir = FileChooser.chooseFile(singleFolderDescriptor, null, toSelect); if (monoDir == null) { return; } monoLib = new File(monoDir.getPath(), "lib/mono"); } if (monoLib == null) { Messages.showErrorDialog(parentComponent, "Current OS is not supported: " + SystemInfo.OS_NAME); return; } if (!monoLib.exists()) { Messages.showErrorDialog(parentComponent, "File: " + monoLib.getAbsolutePath() + " is not exists."); return; } val list = new ArrayList<Pair<String, File>>(); File[] files = monoLib.listFiles(); if (files != null) { for (File file : files) { if (isValidSdkHome(file.getAbsolutePath())) { list.add(new Pair<String, File>(file.getName(), file)); } } } val thisSdks = SdkTable.getInstance().getSdksOfType(this); DefaultActionGroup actionGroup = new DefaultActionGroup(); for (val pair : list) { actionGroup.add(new AnAction(pair.getFirst()) { @Override public void actionPerformed(AnActionEvent anActionEvent) { val path = pair.getSecond(); val absolutePath = path.getAbsolutePath(); String uniqueSdkName = SdkConfigurationUtil.createUniqueSdkName(MonoSdkType.this, absolutePath, thisSdks); SdkImpl sdk = new SdkImpl(uniqueSdkName, MonoSdkType.this); sdk.setVersionString(getVersionString(absolutePath)); sdk.setHomePath(absolutePath); sdkCreatedCallback.consume(sdk); } }); } DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent); ListPopup choose = JBPopupFactory.getInstance().createActionGroupPopup("Choose", actionGroup, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); choose.showInCenterOf(parentComponent); }
From source file:org.twodividedbyzero.idea.findbugs.gui.toolwindow.view.CloudCommentsPaneIntellij.java
License:Open Source License
protected void showCloudChooser(final List<CloudPlugin> plugins, final List<String> descriptions) { final JBPopupFactory factory = JBPopupFactory.getInstance(); final ListPopup popup = factory .createListPopup(new BaseListPopupStep<String>("Store comments in:", descriptions) { @Override//from w w w. ja v a 2s. co m public PopupStep<?> onChosen(final String selectedValue, final boolean finalChoice) { if (selectedValue != null) { final int index = descriptions.indexOf(selectedValue); if (index == -1) { LOGGER.error("Error - not found - '" + selectedValue + "' among " + descriptions); } else { final CloudPlugin newPlugin = plugins.get(index); final String newCloudId = newPlugin.getId(); changeCloud(newCloudId); } } return super.onChosen(selectedValue, finalChoice); } @Override public void canceled() { super.canceled(); } }); popup.showInCenterOf(signInOutLink); }