List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys DOMINANT_HINT_AREA_RECTANGLE
DataKey DOMINANT_HINT_AREA_RECTANGLE
To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys DOMINANT_HINT_AREA_RECTANGLE.
Click Source Link
From source file:com.intellij.codeInsight.hint.HintManagerImpl.java
License:Apache License
/** * @return coordinates in layered pane coordinate system. *//*from www. ja v a 2 s . co m*/ public Point getHintPosition(@NotNull LightweightHint hint, @NotNull Editor editor, @PositionFlags short constraint) { JLayeredPane lp = editor.getComponent().getRootPane().getLayeredPane(); LogicalPosition pos = editor.getCaretModel().getLogicalPosition(); final DataContext dataContext = ((EditorEx) editor).getDataContext(); final Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(dataContext); LOG.assertTrue(SwingUtilities.isEventDispatchThread()); if (dominantArea == null) { for (HintInfo info : getHintsStackArray()) { if (!info.hint.isSelectingHint()) continue; IdeTooltip tooltip = info.hint.getCurrentIdeTooltip(); if (tooltip != null) { Point p = tooltip.getShowingPoint().getPoint(lp); if (info.hint != hint) { switch (constraint) { case ABOVE: if (tooltip.getPreferredPosition() == Balloon.Position.below) { p.y -= tooltip.getPositionChangeY(); } break; case UNDER: case RIGHT_UNDER: if (tooltip.getPreferredPosition() == Balloon.Position.above) { p.y += tooltip.getPositionChangeY(); } break; case RIGHT: if (tooltip.getPreferredPosition() == Balloon.Position.atLeft) { p.x += tooltip.getPositionChangeX(); } break; case LEFT: if (tooltip.getPreferredPosition() == Balloon.Position.atRight) { p.x -= tooltip.getPositionChangeX(); } break; } } return p; } Rectangle rectangle = info.hint.getBounds(); JComponent c = info.hint.getComponent(); rectangle = SwingUtilities.convertRectangle(c.getParent(), rectangle, lp); if (rectangle != null) { return getHintPositionRelativeTo(hint, editor, constraint, rectangle, pos); } } } else { return getHintPositionRelativeTo(hint, editor, constraint, dominantArea, pos); } return getHintPosition(hint, editor, pos, constraint); }
From source file:com.intellij.ui.components.labels.ActionLink.java
License:Apache License
@Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.is(dataId)) { final Point p = SwingUtilities.getRoot(this).getLocationOnScreen(); return new Rectangle(p.x, p.y + getHeight(), 0, 0); }//w w w . java 2 s .c o m if (PlatformDataKeys.CONTEXT_MENU_POINT.is(dataId)) { return SwingUtilities.convertPoint(this, 0, getHeight(), UIUtil.getRootPane(this)); } return null; }
From source file:com.intellij.ui.popup.AbstractPopup.java
License:Apache License
private RelativePoint relativePointByQuickSearch(final DataContext dataContext) { Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(dataContext); if (dominantArea != null) { final Component focusedComponent = getWndManager().getFocusedComponent(myProject); if (focusedComponent != null) { Window window = SwingUtilities.windowForComponent(focusedComponent); JLayeredPane layeredPane; if (window instanceof JFrame) { layeredPane = ((JFrame) window).getLayeredPane(); } else if (window instanceof JDialog) { layeredPane = ((JDialog) window).getLayeredPane(); } else if (window instanceof JWindow) { layeredPane = ((JWindow) window).getLayeredPane(); } else { throw new IllegalStateException( "cannot find parent window: project=" + myProject + "; window=" + window); }/*from www .j a v a 2 s . co m*/ return relativePointWithDominantRectangle(layeredPane, dominantArea); } } return JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); }
From source file:com.intellij.ui.popup.AbstractPopup.java
License:Apache License
@Override 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 {// www .j a va2 s . com show(guessBestPopupLocation(editor)); } }