Java Code Examples for com.intellij.openapi.ui.popup.JBPopup#showCenteredInCurrentWindow()
The following examples show how to use
com.intellij.openapi.ui.popup.JBPopup#showCenteredInCurrentWindow() .
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: ShowBaseRevisionAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void onSuccess() { if (myProject.isDisposed() || ! myProject.isOpen()) return; if (myDescription != null) { NotificationPanel panel = new NotificationPanel(); panel.setText(createMessage(myDescription, selectedFile)); final JBPopup message = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, panel.getLabel()).createPopup(); if (vcsContext.getEditor() != null) { message.showInBestPositionFor(vcsContext.getEditor()); } else { message.showCenteredInCurrentWindow(vcsContext.getProject()); } } }
Example 2
Source File: RunAnythingManager.java From consulo with Apache License 2.0 | 6 votes |
private void calcPositionAndShow(Project project, JBPopup balloon) { Point savedLocation = WindowStateService.getInstance(myProject).getLocation(LOCATION_SETTINGS_KEY); if (project != null) { balloon.showCenteredInCurrentWindow(project); } else { balloon.showInFocusCenter(); } //for first show and short mode popup should be shifted to the top screen half if (savedLocation == null && myRunAnythingUI.getViewType() == RunAnythingPopupUI.ViewType.SHORT) { Point location = balloon.getLocationOnScreen(); location.y /= 2; balloon.setLocation(location); } }
Example 3
Source File: ManageRecentProjectsAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { Disposable disposable = Disposable.newDisposable(); NewRecentProjectPanel panel = new NewRecentProjectPanel(disposable, false); JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel.getRootPanel(), panel.getList()) .setTitle("Recent Projects") .setFocusable(true) .setRequestFocus(true) .setMayBeParent(true) .setMovable(true) .createPopup(); consulo.disposer.Disposer.register(popup, disposable); Project project = e.getRequiredData(CommonDataKeys.PROJECT); popup.showCenteredInCurrentWindow(project); }
Example 4
Source File: TranslateQueryAction.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@Override protected void actionPerformed(AnActionEvent e, Project project, Editor editor, String query, Map<String, Object> parameters) { String gremlin = new OpenCypherGremlinSimpleTranslator().translate(query, parameters); JTextArea translation = new JTextArea(gremlin); translation.setEditable(false); translation.setLineWrap(true); JButton configure = new JButton("Configure/optimize translation"); configure.addActionListener(v -> LandingPageAction.open()); JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(translation, null) .setAdText("Query translated using Cypher for Gremlin") .setSettingButtons(configure) .setCancelButton(new IconButton("Cancel", AllIcons.Actions.Cancel)) .setRequestFocus(true) .setResizable(true) .setMovable(true) .setMinSize(new Dimension(200, 150)) .createPopup(); if (editor == null) { popup.showCenteredInCurrentWindow(project); } else { popup.showInBestPositionFor(editor); } }
Example 5
Source File: TemplateCreateByNameLocalQuickFix.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void applyFix(@NotNull Project project) { Collection<String> templatePaths = TwigUtil.getCreateAbleTemplatePaths(project, templateName); if(templatePaths.size() == 0) { Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); // notify error if editor is focused if(editor != null) { HintManager.getInstance().showErrorHint(editor, "Can not find a target dir"); } return; } JBList<String> list = new JBList<>(templatePaths); JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list) .setTitle("Twig: Template Path") .setItemChoosenCallback(() -> { final String selectedValue = list.getSelectedValue(); String commandName = "Create Template: " + (selectedValue.length() > 15 ? selectedValue.substring(selectedValue.length() - 15) : selectedValue); new WriteCommandAction.Simple(project, commandName) { @Override protected void run() { createFile(project, selectedValue); } }.execute(); }) .createPopup(); // show popup in scope Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if(selectedTextEditor != null) { popup.showInBestPositionFor(selectedTextEditor); } else { popup.showCenteredInCurrentWindow(project); } }
Example 6
Source File: RecentLocationsAction.java From consulo with Apache License 2.0 | 5 votes |
private static void showPopup(@Nonnull Project project, @Nonnull JBPopup popup) { Point savedLocation = DimensionService.getInstance().getLocation(LOCATION_SETTINGS_KEY, project); Window recentFocusedWindow = TargetAWT.to(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow()); if (savedLocation != null && recentFocusedWindow != null) { popup.showInScreenCoordinates(recentFocusedWindow, savedLocation); } else { popup.showCenteredInCurrentWindow(project); } }
Example 7
Source File: SearchEverywhereManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private void calcPositionAndShow(Project project, JBPopup balloon) { Point savedLocation = WindowStateService.getInstance(myProject).getLocation(LOCATION_SETTINGS_KEY); //for first show and short mode popup should be shifted to the top screen half if (savedLocation == null && mySearchEverywhereUI.getViewType() == SearchEverywhereUI.ViewType.SHORT) { Window window = project != null ? TargetAWT.to(WindowManager.getInstance().suggestParentWindow(project)) : KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); Component parent = UIUtil.findUltimateParent(window); if (parent != null) { JComponent content = balloon.getContent(); Dimension balloonSize = content.getPreferredSize(); Point screenPoint = new Point((parent.getSize().width - balloonSize.width) / 2, parent.getHeight() / 4 - balloonSize.height / 2); SwingUtilities.convertPointToScreen(screenPoint, parent); Rectangle screenRectangle = ScreenUtil.getScreenRectangle(screenPoint); Insets insets = content.getInsets(); int bottomEdge = screenPoint.y + mySearchEverywhereUI.getExpandedSize().height + insets.bottom + insets.top; int shift = bottomEdge - (int)screenRectangle.getMaxY(); if (shift > 0) { screenPoint.y = Integer.max(screenPoint.y - shift, screenRectangle.y); } RelativePoint showPoint = new RelativePoint(screenPoint); balloon.show(showPoint); return; } } if (project != null) { balloon.showCenteredInCurrentWindow(project); } else { balloon.showInFocusCenter(); } }