Example usage for com.intellij.openapi.ui.popup JBPopup showInScreenCoordinates

List of usage examples for com.intellij.openapi.ui.popup JBPopup showInScreenCoordinates

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup JBPopup showInScreenCoordinates.

Prototype

void showInScreenCoordinates(@NotNull Component owner, @NotNull Point point);

Source Link

Usage

From source file:com.intellij.xdebugger.impl.ui.DebuggerUIUtil.java

License:Apache License

public static void showValuePopup(@NotNull XFullValueEvaluator evaluator, @NotNull MouseEvent event,
        @NotNull Project project, @Nullable Editor editor) {
    EditorTextField textArea = new TextViewer("Evaluating...", project);
    textArea.setBackground(HintUtil.INFORMATION_COLOR);

    final FullValueEvaluationCallbackImpl callback = new FullValueEvaluationCallbackImpl(textArea);
    evaluator.startEvaluation(callback);

    Dimension size = DimensionService.getInstance().getSize(FULL_VALUE_POPUP_DIMENSION_KEY, project);
    if (size == null) {
        Dimension frameSize = WindowManager.getInstance().getFrame(project).getSize();
        size = new Dimension(frameSize.width / 2, frameSize.height / 2);
    }/*  w  ww.ja  v a2 s  . c o m*/

    textArea.setPreferredSize(size);

    JBPopup popup = createValuePopup(project, textArea, callback);
    if (editor == null) {
        Rectangle bounds = new Rectangle(event.getLocationOnScreen(), size);
        ScreenUtil.fitToScreenVertical(bounds, 5, 5, true);
        if (size.width != bounds.width || size.height != bounds.height) {
            size = bounds.getSize();
            textArea.setPreferredSize(size);
        }
        popup.showInScreenCoordinates(event.getComponent(), bounds.getLocation());
    } else {
        popup.showInBestPositionFor(editor);
    }
}