Search in sources :

Example 16 with RelativePoint

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

the class ShowUsagesAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return;
    Runnable searchEverywhere = mySearchEverywhereRunnable;
    mySearchEverywhereRunnable = null;
    hideHints();
    if (searchEverywhere != null) {
        searchEverywhere.run();
        return;
    }
    final RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.usages");
    UsageTarget[] usageTargets = e.getData(UsageView.USAGE_TARGETS_KEY);
    final Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (usageTargets == null) {
        FindUsagesAction.chooseAmbiguousTargetAndPerform(project, editor, element -> {
            startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE);
            return false;
        });
    } else if (ArrayUtil.getFirstElement(usageTargets) instanceof PsiElementUsageTarget) {
        PsiElement element = ((PsiElementUsageTarget) usageTargets[0]).getElement();
        if (element != null) {
            startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) RelativePoint(com.intellij.ui.awt.RelativePoint) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor) PsiElement(com.intellij.psi.PsiElement)

Example 17 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 18 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 19 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 20 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)

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