mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
leave inplace popup on the old place when best location become invisible (IDEA-89827)
This commit is contained in:
+7
-5
@@ -36,10 +36,7 @@ import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.command.impl.FinishMarkAction;
|
||||
import com.intellij.openapi.command.impl.StartMarkAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
@@ -699,10 +696,15 @@ public abstract class InplaceRefactoring {
|
||||
}
|
||||
});
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
|
||||
myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
|
||||
@Override
|
||||
public RelativePoint recalculateLocation(Balloon object) {
|
||||
final RelativePoint target = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor);
|
||||
if (myTarget != null && !popupFactory.isBestPopupLocationVisible(myEditor)) {
|
||||
return myTarget;
|
||||
}
|
||||
final RelativePoint target = popupFactory.guessBestPopupLocation(myEditor);
|
||||
if (target == null) return myTarget;
|
||||
final Point screenPoint = target.getScreenPoint();
|
||||
int y = screenPoint.y;
|
||||
if (target.getPoint().getY() > myEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
|
||||
|
||||
@@ -247,6 +247,13 @@ public abstract class JBPopupFactory {
|
||||
*/
|
||||
public abstract RelativePoint guessBestPopupLocation(Editor editor);
|
||||
|
||||
/**
|
||||
* @param editor the editor over which the popup is shown.
|
||||
* @return true if popup location is located in visible area
|
||||
* false if center would be suggested instead
|
||||
*/
|
||||
public abstract boolean isBestPopupLocationVisible(Editor editor);
|
||||
|
||||
public abstract Point getCenterOf(JComponent container, JComponent content);
|
||||
|
||||
@Nullable
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user