Search in sources :

Example 21 with ListPopup

use of com.intellij.openapi.ui.popup.ListPopup in project android by JetBrains.

the class FlatComboAction method createPopup.

protected JBPopup createPopup(Runnable onDispose, DataContext context) {
    DefaultActionGroup group = createPopupActionGroup();
    JBPopupFactory factory = JBPopupFactory.getInstance();
    ListPopup popup = factory.createActionGroupPopup(null, group, context, true, onDispose, getMaxRows());
    popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
    return popup;
}
Also used : JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 22 with ListPopup

use of com.intellij.openapi.ui.popup.ListPopup in project intellij-plugins by JetBrains.

the class CucumberCreateStepFixBase method applyFix.

public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
    final GherkinStep step = (GherkinStep) descriptor.getPsiElement();
    final GherkinFile featureFile = (GherkinFile) step.getContainingFile();
    // TODO + step defs pairs from other content roots
    final List<Pair<PsiFile, BDDFrameworkType>> pairs = ContainerUtil.newArrayList(getStepDefinitionContainers(featureFile));
    if (!pairs.isEmpty()) {
        pairs.add(0, null);
        final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
        final ListPopup popupStep = popupFactory.createListPopup(new BaseListPopupStep<Pair<PsiFile, BDDFrameworkType>>(CucumberBundle.message("choose.step.definition.file"), ContainerUtil.newArrayList(pairs)) {

            @Override
            public boolean isSpeedSearchEnabled() {
                return true;
            }

            @NotNull
            @Override
            public String getTextFor(Pair<PsiFile, BDDFrameworkType> value) {
                if (value == null) {
                    return CucumberBundle.message("create.new.file");
                }
                final VirtualFile file = value.getFirst().getVirtualFile();
                assert file != null;
                CucumberStepsIndex stepsIndex = CucumberStepsIndex.getInstance(value.getFirst().getProject());
                StepDefinitionCreator stepDefinitionCreator = stepsIndex.getExtensionMap().get(value.getSecond()).getStepDefinitionCreator();
                return stepDefinitionCreator.getStepDefinitionFilePath(value.getFirst());
            }

            @Override
            public Icon getIconFor(Pair<PsiFile, BDDFrameworkType> value) {
                return value == null ? AllIcons.Actions.CreateFromUsage : value.getFirst().getIcon(0);
            }

            @Override
            public PopupStep onChosen(final Pair<PsiFile, BDDFrameworkType> selectedValue, boolean finalChoice) {
                return doFinalStep(() -> createStepOrSteps(step, selectedValue));
            }
        });
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
            popupStep.showCenteredInCurrentWindow(step.getProject());
        } else {
            createStepOrSteps(step, pairs.get(1));
        }
    } else {
        createFileOrStepDefinition(step, null);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GherkinStep(org.jetbrains.plugins.cucumber.psi.GherkinStep) ListPopup(com.intellij.openapi.ui.popup.ListPopup) NotNull(org.jetbrains.annotations.NotNull) CucumberStepsIndex(org.jetbrains.plugins.cucumber.steps.CucumberStepsIndex) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) PsiFile(com.intellij.psi.PsiFile) GherkinFile(org.jetbrains.plugins.cucumber.psi.GherkinFile) Pair(com.intellij.openapi.util.Pair)

Example 23 with ListPopup

use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.

the class WelcomePopupAction method showPopup.

private void showPopup(final AnActionEvent e) {
    final DefaultActionGroup group = new DefaultActionGroup();
    fillActions(group);
    if (group.getChildrenCount() == 1 && isSilentlyChooseSingleOption()) {
        final AnAction[] children = group.getChildren(null);
        children[0].actionPerformed(e);
        return;
    }
    if (group.getChildrenCount() == 0) {
        group.add(new AnAction(getTextForEmpty()) {

            public void actionPerformed(AnActionEvent e) {
                group.setPopup(false);
            }
        });
    }
    final DataContext context = e.getDataContext();
    final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(getCaption(), group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
    JComponent contextComponent = null;
    InputEvent inputEvent = e.getInputEvent();
    if (inputEvent instanceof MouseEvent) {
        if (inputEvent.getSource() instanceof JComponent) {
            contextComponent = (JComponent) inputEvent.getSource();
        }
    }
    showPopup(context, popup, contextComponent);
}
Also used : MouseEvent(java.awt.event.MouseEvent) ListPopup(com.intellij.openapi.ui.popup.ListPopup) InputEvent(java.awt.event.InputEvent)

Example 24 with ListPopup

use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.

the class XDebuggerSmartStepIntoHandler method doSmartStepInto.

private static <V extends XSmartStepIntoVariant> void doSmartStepInto(final XSmartStepIntoHandler<V> handler, XSourcePosition position, final XDebugSession session, Editor editor) {
    List<V> variants = handler.computeSmartStepVariants(position);
    if (variants.isEmpty()) {
        session.stepInto();
        return;
    } else if (variants.size() == 1) {
        session.smartStepInto(handler, variants.get(0));
        return;
    }
    ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<V>(handler.getPopupTitle(position), variants) {

        @Override
        public Icon getIconFor(V aValue) {
            return aValue.getIcon();
        }

        @NotNull
        @Override
        public String getTextFor(V value) {
            return value.getText();
        }

        @Override
        public PopupStep onChosen(V selectedValue, boolean finalChoice) {
            session.smartStepInto(handler, selectedValue);
            return FINAL_CHOICE;
        }
    });
    DebuggerUIUtil.showPopupForEditorLine(popup, editor, position.getLine());
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) NotNull(org.jetbrains.annotations.NotNull) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep)

Example 25 with ListPopup

use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.

the class QuickSwitchSchemeAction method showPopup.

private void showPopup(AnActionEvent e, DefaultActionGroup group) {
    if (!myShowPopupWithNoActions && group.getChildrenCount() == 0)
        return;
    JBPopupFactory.ActionSelectionAid aid = getAidMethod();
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(getPopupTitle(e), group, e.getDataContext(), aid, true, null, -1, (a) -> a.getTemplatePresentation().getIcon() != ourCurrentAction, myActionPlace);
    showPopup(e, popup);
}
Also used : JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Aggregations

ListPopup (com.intellij.openapi.ui.popup.ListPopup)49 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)11 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)10 NotNull (org.jetbrains.annotations.NotNull)10 RelativePoint (com.intellij.ui.awt.RelativePoint)8 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)7 Project (com.intellij.openapi.project.Project)7 PopupStep (com.intellij.openapi.ui.popup.PopupStep)7 DataContext (com.intellij.openapi.actionSystem.DataContext)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)4 MouseEvent (java.awt.event.MouseEvent)4 ArrayList (java.util.ArrayList)4 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Nullable (org.jetbrains.annotations.Nullable)3 JBScrollPane (com.intellij.ui.components.JBScrollPane)2 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)2 java.awt (java.awt)2