Search in sources :

Example 11 with ListPopup

use of com.intellij.openapi.ui.popup.ListPopup 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 12 with ListPopup

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

the class NewElementSamePlaceAction method showPopup.

protected void showPopup(DataContext context) {
    ListPopup popup = createPopup(context);
    Project project = CommonDataKeys.PROJECT.getData(context);
    if (project != null) {
        popup.showCenteredInCurrentWindow(project);
    } else {
        popup.showInBestPositionFor(context);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 13 with ListPopup

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

the class ComboBoxAction method createActionPopup.

@NotNull
private ListPopup createActionPopup(@NotNull DataContext context, @NotNull JComponent component, @Nullable Runnable disposeCallback) {
    DefaultActionGroup group = createPopupActionGroup(component, context);
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(myPopupTitle, group, context, false, shouldShowDisabledActions(), false, disposeCallback, getMaxRows(), getPreselectCondition());
    popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
    return popup;
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ListPopup

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

the class ComboBoxAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null)
        return;
    JFrame frame = WindowManager.getInstance().getFrame(project);
    if (!(frame instanceof IdeFrame))
        return;
    ListPopup popup = createActionPopup(e.getDataContext(), ((IdeFrame) frame).getComponent(), null);
    popup.showCenteredInCurrentWindow(project);
}
Also used : Project(com.intellij.openapi.project.Project) ListPopup(com.intellij.openapi.ui.popup.ListPopup) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 15 with ListPopup

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

the class GenerateAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    Project project = ObjectUtils.assertNotNull(getEventProject(e));
    final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(CodeInsightBundle.message("generate.list.popup.title"), wrapGroup(getGroup(), dataContext, project), dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
    popup.showInBestPositionFor(dataContext);
}
Also used : Project(com.intellij.openapi.project.Project) 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