Search in sources :

Example 56 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class DetectionExcludesConfigurable method doAddAction.

private void doAddAction(AnActionButton button) {
    final List<FrameworkType> types = new ArrayList<>();
    for (FrameworkType type : FrameworkDetectorRegistry.getInstance().getFrameworkTypes()) {
        if (!isExcluded(type)) {
            types.add(type);
        }
    }
    Collections.sort(types, (o1, o2) -> o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()));
    types.add(0, null);
    final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<FrameworkType>("Framework to Exclude", types) {

        @Override
        public Icon getIconFor(FrameworkType value) {
            return value != null ? value.getIcon() : null;
        }

        @NotNull
        @Override
        public String getTextFor(FrameworkType value) {
            return value != null ? value.getPresentableName() : "All Frameworks...";
        }

        @Override
        public boolean hasSubstep(FrameworkType selectedValue) {
            return selectedValue != null;
        }

        @Override
        public PopupStep onChosen(final FrameworkType frameworkType, boolean finalChoice) {
            if (frameworkType == null) {
                return doFinalStep(() -> chooseDirectoryAndAdd(null));
            } else {
                return addExcludedFramework(frameworkType);
            }
        }
    });
    final RelativePoint popupPoint = button.getPreferredPopupPoint();
    if (popupPoint != null) {
        popup.show(popupPoint);
    } else {
        popup.showInCenterOf(myMainPanel);
    }
}
Also used : FrameworkType(com.intellij.framework.FrameworkType) ArrayList(java.util.ArrayList) ListPopup(com.intellij.openapi.ui.popup.ListPopup) RelativePoint(com.intellij.ui.awt.RelativePoint) NotNull(org.jetbrains.annotations.NotNull) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep)

Example 57 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class GotoDeclarationAction method startFindUsages.

private static boolean startFindUsages(@NotNull Editor editor, PsiElement element) {
    if (element != null) {
        ShowUsagesAction showUsages = (ShowUsagesAction) ActionManager.getInstance().getAction(ShowUsagesAction.ID);
        RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
        showUsages.startFindUsages(element, popupPosition, editor, ShowUsagesAction.USAGES_PAGE_SIZE);
        return true;
    }
    return false;
}
Also used : ShowUsagesAction(com.intellij.find.actions.ShowUsagesAction) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 58 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class BaseRunConfigurationAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
    final RunnerAndConfigurationSettings existing = context.findExisting();
    if (existing == null) {
        final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context);
        if (producers.isEmpty())
            return;
        if (producers.size() > 1) {
            final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
            Collections.sort(producers, ConfigurationFromContext.NAME_COMPARATOR);
            final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationFromContext>(ExecutionBundle.message("configuration.action.chooser.title"), producers) {

                @Override
                @NotNull
                public String getTextFor(final ConfigurationFromContext producer) {
                    return childActionName(producer.getConfigurationType(), producer.getConfiguration());
                }

                @Override
                public Icon getIconFor(final ConfigurationFromContext producer) {
                    return producer.getConfigurationType().getIcon();
                }

                @Override
                public PopupStep onChosen(final ConfigurationFromContext producer, final boolean finalChoice) {
                    perform(producer, context);
                    return FINAL_CHOICE;
                }
            });
            final InputEvent event = e.getInputEvent();
            if (event instanceof MouseEvent) {
                popup.show(new RelativePoint((MouseEvent) event));
            } else if (editor != null) {
                popup.showInBestPositionFor(editor);
            } else {
                popup.showInBestPositionFor(dataContext);
            }
        } else {
            perform(producers.get(0), context);
        }
        return;
    }
    perform(context);
}
Also used : MouseEvent(java.awt.event.MouseEvent) ListPopup(com.intellij.openapi.ui.popup.ListPopup) RelativePoint(com.intellij.ui.awt.RelativePoint) NotNull(org.jetbrains.annotations.NotNull) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) InputEvent(java.awt.event.InputEvent) Editor(com.intellij.openapi.editor.Editor)

Example 59 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class ConsoleGutterComponent method mouseMoved.

@Override
public void mouseMoved(MouseEvent e) {
    int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
    if (line == lastGutterToolTipLine) {
        return;
    }
    TooltipController controller = TooltipController.getInstance();
    if (lastGutterToolTipLine != -1) {
        controller.cancelTooltip(TOOLTIP_GROUP, e, true);
    }
    String toolTip = gutterContentProvider.getToolTip(line, editor);
    setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    if (toolTip == null) {
        lastGutterToolTipLine = -1;
        controller.cancelTooltip(TOOLTIP_GROUP, e, false);
    } else {
        lastGutterToolTipLine = line;
        RelativePoint showPoint = new RelativePoint(this, e.getPoint());
        controller.showTooltipByMouseMove(editor, showPoint, ((EditorMarkupModel) editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip), false, TOOLTIP_GROUP, new HintHint(this, e.getPoint()).setAwtTooltip(true));
    }
}
Also used : HintHint(com.intellij.ui.HintHint) TooltipController(com.intellij.codeInsight.hint.TooltipController) RelativePoint(com.intellij.ui.awt.RelativePoint) HintHint(com.intellij.ui.HintHint) RelativePoint(com.intellij.ui.awt.RelativePoint) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel)

Example 60 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class FindPopupPanel method showUI.

public void showUI() {
    if (myBalloon != null && myBalloon.isVisible()) {
        return;
    }
    if (myBalloon != null && !myBalloon.isDisposed()) {
        myBalloon.cancel();
    }
    if (myBalloon == null || myBalloon.isDisposed()) {
        final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(this, mySearchComponent);
        myBalloon = builder.setProject(myHelper.getProject()).setMovable(true).setResizable(true).setMayBeParent(true).setCancelOnClickOutside(true).setModalContext(false).setRequestFocus(true).setCancelCallback(() -> {
            if (!myCanClose.get())
                return false;
            if (!ApplicationManager.getApplication().isActive())
                return false;
            List<JBPopup> popups = JBPopupFactory.getInstance().getChildPopups(this);
            if (!popups.isEmpty()) {
                for (JBPopup popup : popups) {
                    popup.cancel();
                }
                return false;
            }
            if (myScopeUI.hideAllPopups()) {
                return false;
            }
            DimensionService.getInstance().setSize(SERVICE_KEY, myBalloon.getSize(), myHelper.getProject());
            DimensionService.getInstance().setLocation(SERVICE_KEY, myBalloon.getLocationOnScreen(), myHelper.getProject());
            return true;
        }).createPopup();
        Disposer.register(myBalloon, myDisposable);
        registerCloseAction(myBalloon);
        final Window window = WindowManager.getInstance().suggestParentWindow(myProject);
        Component parent = UIUtil.findUltimateParent(window);
        RelativePoint showPoint = null;
        Point screenPoint = DimensionService.getInstance().getLocation(SERVICE_KEY);
        if (screenPoint != null) {
            showPoint = new RelativePoint(screenPoint);
        }
        if (parent != null && showPoint == null) {
            int height = UISettings.getInstance().getShowNavigationBar() ? 135 : 115;
            if (parent instanceof IdeFrameImpl && ((IdeFrameImpl) parent).isInFullScreen()) {
                height -= 20;
            }
            showPoint = new RelativePoint(parent, new Point((parent.getSize().width - getPreferredSize().width) / 2, height));
        }
        mySearchComponent.selectAll();
        WindowMoveListener windowListener = new WindowMoveListener(this);
        myTitleLabel.addMouseListener(windowListener);
        myTitleLabel.addMouseMotionListener(windowListener);
        Dimension panelSize = getPreferredSize();
        Dimension prev = DimensionService.getInstance().getSize(SERVICE_KEY);
        if (!myCbPreserveCase.isVisible()) {
            panelSize.width += myCbPreserveCase.getPreferredSize().width + 8;
        }
        panelSize.height *= 2;
        if (prev != null && prev.height < panelSize.height)
            prev.height = panelSize.height;
        myBalloon.setMinimumSize(panelSize);
        if (prev == null)
            panelSize.height = panelSize.height * 3 / 2;
        myBalloon.setSize(prev != null ? prev : panelSize);
        if (showPoint != null && showPoint.getComponent() != null) {
            myBalloon.show(showPoint);
        } else {
            myBalloon.showCenteredInCurrentWindow(myProject);
        }
    }
}
Also used : IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) ComponentPopupBuilder(com.intellij.openapi.ui.popup.ComponentPopupBuilder) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBPopup(com.intellij.openapi.ui.popup.JBPopup) 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