Java 类com.intellij.ui.popup.PopupPositionManager 实例源码

项目:educational-plugin    文件:StudyShowHintAction.java   
private static void showHintPopUp(Project project, StudyState studyState, Editor editor, StudyToolWindow hintComponent) {
  final JBPopup popup =
    JBPopupFactory.getInstance().createComponentPopupBuilder(hintComponent, hintComponent)
      .setDimensionServiceKey(project, "StudyHint", false)
      .setResizable(true)
      .setMovable(true)
      .setRequestFocus(true)
      .setTitle(studyState.getTask().getName())
      .createPopup();
  Disposer.register(popup, hintComponent);

  final Component focusOwner = IdeFocusManager.getInstance(project).getFocusOwner();
  DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  PopupPositionManager.positionPopupInBestPosition(popup, editor, dataContext);
}
项目:intellij-ce-playground    文件:SearchEverywhereAction.java   
private void adjustPopup() {
//    new PopupPositionManager.PositionAdjuster(getField().getParent(), 0).adjust(myPopup, PopupPositionManager.Position.BOTTOM);
    final Dimension d = PopupPositionManager.PositionAdjuster.getPopupSize(myPopup);
    final JComponent myRelativeTo = myBalloon.getContent();
    Point myRelativeOnScreen = myRelativeTo.getLocationOnScreen();
    Rectangle screen = ScreenUtil.getScreenRectangle(myRelativeOnScreen);
    Rectangle popupRect = null;
    Rectangle r = new Rectangle(myRelativeOnScreen.x, myRelativeOnScreen.y + myRelativeTo.getHeight(), d.width, d.height);

      if (screen.contains(r)) {
        popupRect = r;
      }

    if (popupRect != null) {
      Point location = new Point(r.x, r.y);
      if (!location.equals(myPopup.getLocationOnScreen())) {
        myPopup.setLocation(location);
      }
    }
    else {
      if (r.y + d.height > screen.y + screen.height) {
        r.height =  screen.y + screen.height - r.y - 2;
      }
      if (r.width > screen.width) {
        r.width = screen.width - 50;
      }
      if (r.x + r.width > screen.x + screen.width) {
        r.x = screen.x + screen.width - r.width - 2;
      }

      myPopup.setSize(r.getSize());
      myPopup.setLocation(r.getLocation());
    }

  }
项目:consulo    文件:SearchEverywhereAction.java   
private void adjustPopup() {
//    new PopupPositionManager.PositionAdjuster(getField().getParent(), 0).adjust(myPopup, PopupPositionManager.Position.BOTTOM);
    final Dimension d = PopupPositionManager.PositionAdjuster.getPopupSize(myPopup);
    final JComponent myRelativeTo = myBalloon.getContent();
    Point myRelativeOnScreen = myRelativeTo.getLocationOnScreen();
    Rectangle screen = ScreenUtil.getScreenRectangle(myRelativeOnScreen);
    Rectangle popupRect = null;
    Rectangle r = new Rectangle(myRelativeOnScreen.x, myRelativeOnScreen.y + myRelativeTo.getHeight(), d.width, d.height);

    if (screen.contains(r)) {
      popupRect = r;
    }

    if (popupRect != null) {
      myPopup.setLocation(new Point(r.x - 1, r.y));
    }
    else {
      if (r.y + d.height > screen.y + screen.height) {
        r.height = screen.y + screen.height - r.y - 2;
      }
      if (r.width > screen.width) {
        r.width = screen.width - 50;
      }
      if (r.x + r.width > screen.x + screen.width) {
        r.x = screen.x + screen.width - r.width - 2;
      }

      myPopup.setSize(r.getSize());
      myPopup.setLocation(r.getLocation());
    }

  }
项目:intellij-ce-playground    文件:DocumentationManager.java   
void showHint(final JBPopup hint) {
  final Component focusOwner = IdeFocusManager.getInstance(myProject).getFocusOwner();
  DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  PopupPositionManager.positionPopupInBestPosition(hint, myEditor, dataContext);
}
项目:intellij-ce-playground    文件:ChooseByNameBase.java   
public void repositionHint() {
  if (myHint == null || !myHint.isVisible()) return;
  PopupPositionManager.positionPopupInBestPosition(myHint, null, null);
}
项目:tools-idea    文件:DocumentationManager.java   
void showHint(final JBPopup hint) {
  final Component focusOwner = IdeFocusManager.getInstance(myProject).getFocusOwner();
  DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  PopupPositionManager.positionPopupInBestPosition(hint, myEditor, dataContext);
}
项目:tools-idea    文件:ChooseByNameBase.java   
public void repositionHint() {
  if (myHint == null || !myHint.isVisible()) return;
  PopupPositionManager.positionPopupInBestPosition(myHint, null, null);
}
项目:consulo    文件:DocumentationManager.java   
void showHint(final JBPopup hint) {
  final Component focusOwner = IdeFocusManager.getInstance(myProject).getFocusOwner();
  DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  PopupPositionManager.positionPopupInBestPosition(hint, myEditor, dataContext);
}
项目:consulo    文件:ChooseByNameBase.java   
public void repositionHint() {
  if (myHint == null || !myHint.isVisible()) return;
  PopupPositionManager.positionPopupInBestPosition(myHint, null, null);
}