use of com.intellij.codeInsight.lookup.LookupEvent in project intellij-community by JetBrains.
the class PopupPositionManager method positionPopupInBestPosition.
public static void positionPopupInBestPosition(final JBPopup hint, @Nullable final Editor editor, @Nullable DataContext dataContext) {
final LookupEx lookup = LookupManager.getActiveLookup(editor);
if (lookup != null && lookup.getCurrentItem() != null && lookup.getComponent().isShowing()) {
new PositionAdjuster(lookup.getComponent()).adjust(hint);
lookup.addLookupListener(new LookupAdapter() {
@Override
public void lookupCanceled(LookupEvent event) {
if (hint.isVisible()) {
hint.cancel();
}
}
});
return;
}
final PositionAdjuster positionAdjuster = createPositionAdjuster();
if (positionAdjuster != null) {
positionAdjuster.adjust(hint);
return;
}
if (editor != null && editor.getComponent().isShowing()) {
hint.showInBestPositionFor(editor);
return;
}
if (dataContext != null) {
hint.showInBestPositionFor(dataContext);
}
}
Aggregations