Search in sources :

Example 21 with RelativePoint

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;
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 22 with RelativePoint

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);
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 23 with RelativePoint

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)));
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) Project(com.intellij.openapi.project.Project) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Example 24 with RelativePoint

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);
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 25 with RelativePoint

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());
}
Also used : DataProvider(com.intellij.openapi.actionSystem.DataProvider) VirtualFile(com.intellij.openapi.vfs.VirtualFile) JBTabsImpl(com.intellij.ui.tabs.impl.JBTabsImpl) RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

RelativePoint (com.intellij.ui.awt.RelativePoint)127 Project (com.intellij.openapi.project.Project)16 Balloon (com.intellij.openapi.ui.popup.Balloon)15 JBPopup (com.intellij.openapi.ui.popup.JBPopup)15 NotNull (org.jetbrains.annotations.NotNull)15 MouseEvent (java.awt.event.MouseEvent)12 Nullable (org.jetbrains.annotations.Nullable)10 Editor (com.intellij.openapi.editor.Editor)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 PsiElement (com.intellij.psi.PsiElement)8 JBList (com.intellij.ui.components.JBList)8 Disposable (com.intellij.openapi.Disposable)7 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)7 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)7 ArrayList (java.util.ArrayList)7 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)6 ListPopup (com.intellij.openapi.ui.popup.ListPopup)6 PsiFile (com.intellij.psi.PsiFile)5 HintHint (com.intellij.ui.HintHint)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4