public void showInBestPositionFor(@NotNull Editor editor) {
    assert editor.getComponent().isShowing() : "Editor must be showing on the screen";

    DataContext context = ((EditorEx) editor).getDataContext();
    Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(context);
    if (dominantArea != null && !myRequestFocus) {
      final JLayeredPane layeredPane = editor.getContentComponent().getRootPane().getLayeredPane();
      show(relativePointWithDominantRectangle(layeredPane, dominantArea));
    } else {
      show(JBPopupFactory.getInstance().guessBestPopupLocation(editor));
    }
  }
Exemplo n.º 2
0
  @Override
  public void show(
      final Component owner,
      final int aScreenX,
      final int aScreenY,
      final boolean considerForcedXY) {
    LOG.assertTrue(!isDisposed());

    Rectangle targetBounds =
        new Rectangle(new Point(aScreenX, aScreenY), getContent().getPreferredSize());
    ScreenUtil.moveRectangleToFitTheScreen(targetBounds);

    if (getParent() != null) {
      final Rectangle parentBounds = getParent().getBounds();
      parentBounds.x += STEP_X_PADDING;
      parentBounds.width -= STEP_X_PADDING * 2;
      if (parentBounds.intersects(targetBounds)) {
        targetBounds.x = getParent().getBounds().x - targetBounds.width - STEP_X_PADDING;
      }
    }

    if (getParent() == null) {
      PopupDispatcher.setActiveRoot(this);
    } else {
      PopupDispatcher.setShowing(this);
    }

    LOG.assertTrue(!isDisposed(), "Disposed popup, parent=" + getParent());
    super.show(owner, targetBounds.x, targetBounds.y, true);
  }
 public void showInBestPositionFor(@NotNull DataContext dataContext) {
   final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
   if (editor != null) {
     showInBestPositionFor(editor);
   } else {
     show(relativePointByQuickSearch(dataContext));
   }
 }
 public void show(final Component owner) {
   show(owner, -1, -1, true);
 }
 public void showInScreenCoordinates(@NotNull Component owner, @NotNull Point point) {
   show(owner, point.x, point.y, false);
 }
 public void show(@NotNull RelativePoint aPoint) {
   final Point screenPoint = aPoint.getScreenPoint();
   show(aPoint.getComponent(), screenPoint.x, screenPoint.y, false);
 }
 public void showUnderneathOf(@NotNull Component aComponent) {
   show(new RelativePoint(aComponent, new Point(0, aComponent.getHeight())));
 }
 public void showInCenterOf(@NotNull Component aContainer) {
   final Point popupPoint = getCenterOf(aContainer, myContent);
   show(aContainer, popupPoint.x, popupPoint.y, false);
 }