Java Code Examples for com.intellij.openapi.ui.popup.JBPopupFactory#guessBestPopupLocation()

The following examples show how to use com.intellij.openapi.ui.popup.JBPopupFactory#guessBestPopupLocation() . 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: GotoTestDataAction.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project != null) {
        DataContext dataContext = e.getDataContext();
        List<String> fileNames = findRelatedFiles(project, dataContext);
        if (fileNames.isEmpty()) {
            Notifications.Bus.notify(new ORNotification("testdata", "Found no testdata files", "Cannot find related files", INFORMATION, null), project);
            return;
        }

        Editor editor = e.getData(CommonDataKeys.EDITOR);
        JBPopupFactory popupFactory = JBPopupFactory.getInstance();
        RelativePoint point = editor == null ? popupFactory.guessBestPopupLocation(dataContext) : popupFactory.guessBestPopupLocation(editor);

        TestDataNavigationHandler.navigate(point, fileNames, project);
    }
}
 
Example 2
Source File: GLSLDeduceExpressionTypeAction.java    From glsl4idea with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void showBalloon(AnActionEvent e, String html) {
    final Editor editor = e.getData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
    if(editor == null) return;
    final JBPopupFactory factory = JBPopupFactory.getInstance();
    final BalloonBuilder builder = factory.createBalloonBuilder(new JLabel(html));
    Balloon balloon = builder.createBalloon();
    RelativePoint position = factory.guessBestPopupLocation(editor);
    balloon.show(position, Balloon.Position.below);
}