List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys CONTEXT_MENU_POINT
DataKey CONTEXT_MENU_POINT
To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys CONTEXT_MENU_POINT.
Click Source Link
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); }//from www . j ava 2s. 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.PopupFactoryImpl.java
License:Apache License
@NotNull @Override/*from w w w . j a v a2s . c o m*/ public RelativePoint guessBestPopupLocation(@NotNull DataContext dataContext) { Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext); JComponent focusOwner = component instanceof JComponent ? (JComponent) component : null; if (focusOwner == null) { Project project = CommonDataKeys.PROJECT.getData(dataContext); IdeFrameImpl frame = project == null ? null : ((WindowManagerEx) WindowManager.getInstance()).getFrame(project); focusOwner = frame == null ? null : frame.getRootPane(); if (focusOwner == null) { throw new IllegalArgumentException("focusOwner cannot be null"); } } final Point point = PlatformDataKeys.CONTEXT_MENU_POINT.getData(dataContext); if (point != null) { return new RelativePoint(focusOwner, point); } Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (editor != null && focusOwner == editor.getContentComponent()) { return guessBestPopupLocation(editor); } else { return guessBestPopupLocation(focusOwner); } }