Search in sources :

Example 16 with BaseListPopupStep

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

the class ModuleDependenciesPanel method createTableWithButtons.

@NotNull
private JComponent createTableWithButtons() {
    myEntryTable.getSelectionModel().addListSelectionListener(e -> {
        if (e.getValueIsAdjusting()) {
            return;
        }
        updateButtons();
    });
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable);
    decorator.setAddAction(button -> {
        ImmutableList<PopupAction> popupActions = ImmutableList.of(new PopupAction(AndroidIcons.MavenLogo, 1, "Library dependency") {

            @Override
            public void run() {
                addExternalDependency();
            }
        }, new PopupAction(PlatformIcons.LIBRARY_ICON, 2, "Jar dependency") {

            @Override
            public void run() {
                addFileDependency();
            }
        }, new PopupAction(AllIcons.Nodes.Module, 3, "Module dependency") {

            @Override
            public void run() {
                addModuleDependency();
            }
        });
        final JBPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<PopupAction>(null, popupActions) {

            @Override
            public Icon getIconFor(PopupAction value) {
                return value.myIcon;
            }

            @Override
            public boolean hasSubstep(PopupAction value) {
                return false;
            }

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

            @Override
            public PopupStep onChosen(final PopupAction value, final boolean finalChoice) {
                return doFinalStep(value);
            }

            @Override
            @NotNull
            public String getTextFor(PopupAction value) {
                return "&" + value.myIndex + "  " + value.myTitle;
            }
        });
        popup.show(button.getPreferredPopupPoint());
    });
    decorator.setRemoveAction(button -> removeSelectedItems());
    decorator.setMoveUpAction(button -> moveSelectedRows(-1));
    decorator.setMoveDownAction(button -> moveSelectedRows(+1));
    final JPanel panel = decorator.createPanel();
    myRemoveButton = ToolbarDecorator.findRemoveButton(panel);
    return panel;
}
Also used : JBPopup(com.intellij.openapi.ui.popup.JBPopup) NotNull(org.jetbrains.annotations.NotNull) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with BaseListPopupStep

use of com.intellij.openapi.ui.popup.util.BaseListPopupStep in project yii2support by nvlad.

the class OpenViewCalls method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    // TODO: insert action logic here
    PsiFile psiFile = e.getData(PlatformDataKeys.PSI_FILE);
    if (psiFile == null) {
        return;
    }
    Collection<PsiReference> references = ReferencesSearch.search(psiFile).findAll();
    if (references.size() == 0) {
        return;
    }
    if (references.size() == 1) {
        ReferenceListPopupStep.openReference(references.iterator().next());
        return;
    }
    JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    BaseListPopupStep popupStep = new ReferenceListPopupStep("Render this View from", references);
    ListPopup popup = popupFactory.createListPopup(popupStep);
    Project project = e.getProject();
    if (project == null) {
        popup.showInFocusCenter();
    } else {
        popup.showCenteredInCurrentWindow(project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) ListPopup(com.intellij.openapi.ui.popup.ListPopup) PsiReference(com.intellij.psi.PsiReference) PsiFile(com.intellij.psi.PsiFile)

Example 18 with BaseListPopupStep

use of com.intellij.openapi.ui.popup.util.BaseListPopupStep 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 19 with BaseListPopupStep

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

the class DependenciesConfigurable method addItem.

private void addItem(AnActionButton button) {
    initPopupActions();
    final JBPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<AddItemPopupAction>(FlexBundle.message("add.dependency.popup.title"), myPopupActions) {

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

        @Override
        public boolean hasSubstep(AddItemPopupAction selectedValue) {
            return selectedValue.hasSubStep();
        }

        public boolean isMnemonicsNavigationEnabled() {
            return true;
        }

        public PopupStep onChosen(final AddItemPopupAction selectedValue, final boolean finalChoice) {
            if (selectedValue.hasSubStep()) {
                return selectedValue.createSubStep();
            }
            return doFinalStep(() -> selectedValue.run());
        }

        @NotNull
        public String getTextFor(AddItemPopupAction value) {
            return "&" + value.getIndex() + "  " + value.getTitle();
        }
    });
    popup.show(button.getPreferredPopupPoint());
}
Also used : JBPopup(com.intellij.openapi.ui.popup.JBPopup) NotNull(org.jetbrains.annotations.NotNull) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep)

Example 20 with BaseListPopupStep

use of com.intellij.openapi.ui.popup.util.BaseListPopupStep 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)

Aggregations

BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)33 PopupStep (com.intellij.openapi.ui.popup.PopupStep)18 NotNull (org.jetbrains.annotations.NotNull)15 ListPopup (com.intellij.openapi.ui.popup.ListPopup)10 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)10 RelativePoint (com.intellij.ui.awt.RelativePoint)8 Project (com.intellij.openapi.project.Project)7 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)5 JBPopup (com.intellij.openapi.ui.popup.JBPopup)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 PsiFile (com.intellij.psi.PsiFile)4 Nullable (org.jetbrains.annotations.Nullable)3 AllIcons (com.intellij.icons.AllIcons)2 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)2 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 Editor (com.intellij.openapi.editor.Editor)2 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)2 FileChooser (com.intellij.openapi.fileChooser.FileChooser)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2