use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ListPopupImpl method showUnderneathOfLabel.
public void showUnderneathOfLabel(@NotNull JLabel label) {
int offset = -UIUtil.getListCellHPadding() - UIUtil.getListViewportPadding().left;
if (label.getIcon() != null) {
offset += label.getIcon().getIconWidth() + label.getIconTextGap();
}
show(new RelativePoint(label, new Point(offset, label.getHeight() + 1)));
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class PopupFactoryImpl method guessBestPopupLocation.
@NotNull
@Override
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);
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class InplaceChangeSignature method showBalloon.
protected void showBalloon() {
NonFocusableCheckBox checkBox = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
checkBox.addActionListener(e -> {
myDelegate = checkBox.isSelected();
updateCurrentInfo();
});
JPanel content = new JPanel(new BorderLayout());
content.add(new JBLabel("Performed signature modifications:"), BorderLayout.NORTH);
content.add(myPreview.getComponent(), BorderLayout.CENTER);
updateMethodSignature(myStableChange);
content.add(checkBox, BorderLayout.SOUTH);
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(content, null).setSmallVariant(true);
myBalloon = balloonBuilder.createBalloon();
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
@Override
public RelativePoint recalculateLocation(Balloon object) {
int offset = myStableChange.getMethod().getTextOffset();
VisualPosition visualPosition = myEditor.offsetToVisualPosition(offset);
Point point = myEditor.visualPositionToXY(new VisualPosition(visualPosition.line, visualPosition.column));
return new RelativePoint(myEditor.getContentComponent(), point);
}
}, Balloon.Position.above);
Disposer.register(myBalloon, () -> {
EditorFactory.getInstance().releaseEditor(myPreview);
myPreview = null;
});
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ShowPopupMenuAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final RelativePoint relPoint = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
Component focusOwner = focusManager.getFocusOwner();
Point popupMenuPoint = relPoint.getPoint(focusOwner);
final Editor editor = e.getData(CommonDataKeys.EDITOR);
int coord = editor != null ? //To avoid cursor jump to the line below. http://www.jetbrains.net/jira/browse/IDEADEV-10644
Math.max(0, popupMenuPoint.y - 1) : popupMenuPoint.y;
focusOwner.dispatchEvent(new MouseEvent(focusOwner, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, popupMenuPoint.x, coord, 1, true));
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class EncodingPanel method showPopup.
private void showPopup(@NotNull MouseEvent e) {
if (!actionEnabled) {
return;
}
DataContext dataContext = getContext();
ListPopup popup = new ChangeFileEncodingAction().createPopup(dataContext);
if (popup != null) {
Dimension dimension = popup.getContent().getPreferredSize();
Point at = new Point(0, -dimension.height);
popup.show(new RelativePoint(e.getComponent(), at));
// destroy popup on unexpected project close
Disposer.register(this, popup);
}
}
Aggregations