use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class DebuggerUIUtil method showBreakpointEditor.
public static Balloon showBreakpointEditor(Project project, final JComponent mainPanel, final Point whereToShow, final JComponent component, @Nullable final Runnable showMoreOptions, Object breakpoint) {
final BreakpointEditor editor = new BreakpointEditor();
editor.setPropertiesPanel(mainPanel);
editor.setShowMoreOptionsLink(true);
final JPanel panel = editor.getMainPanel();
final Balloon balloon = JBPopupFactory.getInstance().createDialogBalloonBuilder(panel, null).setHideOnClickOutside(true).setCloseButtonEnabled(false).setAnimationCycle(0).setBlockClicksThroughBalloon(true).createBalloon();
editor.setDelegate(new BreakpointEditor.Delegate() {
@Override
public void done() {
balloon.hide();
}
@Override
public void more() {
assert showMoreOptions != null;
balloon.hide();
showMoreOptions.run();
}
});
ComponentAdapter moveListener = new ComponentAdapter() {
@Override
public void componentMoved(ComponentEvent e) {
balloon.hide();
}
};
component.addComponentListener(moveListener);
Disposer.register(balloon, () -> component.removeComponentListener(moveListener));
HierarchyBoundsListener hierarchyBoundsListener = new HierarchyBoundsAdapter() {
@Override
public void ancestorMoved(HierarchyEvent e) {
balloon.hide();
}
};
component.addHierarchyBoundsListener(hierarchyBoundsListener);
Disposer.register(balloon, () -> component.removeHierarchyBoundsListener(hierarchyBoundsListener));
if (whereToShow == null) {
balloon.showInCenterOf(component);
} else {
//todo[kb] modify and move to BalloonImpl?
final Window window = SwingUtilities.windowForComponent(component);
final RelativePoint p = new RelativePoint(component, whereToShow);
if (window != null) {
final RelativePoint point = new RelativePoint(window, new Point(0, 0));
if (p.getScreenPoint().getX() - point.getScreenPoint().getX() < 40) {
// triangle + offsets is ~40px
p.getPoint().x += 40;
}
}
balloon.show(p, Balloon.Position.below);
}
BreakpointsDialogFactory.getInstance(project).setBalloonToHide(balloon, breakpoint);
return balloon;
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class DebuggerUIUtil method calcPopupLocation.
@Deprecated
public static RelativePoint calcPopupLocation(@NotNull Editor editor, final int line) {
Point p = editor.logicalPositionToXY(new LogicalPosition(line + 1, 0));
final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
if (!visibleArea.contains(p)) {
p = new Point((visibleArea.x + visibleArea.width) / 2, (visibleArea.y + visibleArea.height) / 2);
}
return new RelativePoint(editor.getContentComponent(), p);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class CustomPopupFullValueEvaluator method evaluate.
@Override
public void evaluate(@NotNull final XFullValueEvaluationCallback callback) {
final T data = getData();
DebuggerUIUtil.invokeLater(() -> {
if (callback.isObsolete())
return;
final JComponent comp = createComponent(data);
Project project = getEvaluationContext().getProject();
JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null);
JFrame frame = WindowManager.getInstance().getFrame(project);
Dimension frameSize = frame.getSize();
Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
popup.setSize(size);
if (comp instanceof Disposable) {
Disposer.register(popup, (Disposable) comp);
}
callback.evaluated("");
popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2)));
});
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ArtifactEditorFindUsagesActionBase method getPointToShowResults.
@Override
protected RelativePoint getPointToShowResults() {
final int selectedRow = myTree.getSelectionRows()[0];
final Rectangle rowBounds = myTree.getRowBounds(selectedRow);
final Point location = rowBounds.getLocation();
location.y += rowBounds.height;
return new RelativePoint(myTree, location);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class DockableEditorTabbedContainer method add.
@Override
public void add(@NotNull DockableContent content, RelativePoint dropTarget) {
EditorWindow window = null;
if (myCurrentOver != null) {
final DataProvider provider = myCurrentOver.getDataProvider();
if (provider != null) {
window = EditorWindow.DATA_KEY.getData(provider);
}
}
final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor) content;
VirtualFile file = dockableEditor.getFile();
if (window == null || window.isDisposed()) {
window = mySplitters.getOrCreateCurrentWindow(file);
}
if (myCurrentOver != null) {
int index = ((JBTabsImpl) myCurrentOver).getDropInfoIndex();
file.putUserData(EditorWindow.INITIAL_INDEX_KEY, index);
}
((FileEditorManagerImpl) FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true);
window.setFilePinned(file, dockableEditor.isPinned());
}
Aggregations