Search in sources :

Example 6 with ListPopup

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

the class PythonSdkDetailsStep method show.

public static void show(final Project project, final Sdk[] existingSdks, @Nullable final DialogWrapper moreDialog, JComponent ownerComponent, final Point popupPoint, final NullableConsumer<Sdk> sdkAddedCallback, boolean isNewProject) {
    final PythonSdkDetailsStep sdkHomesStep = new PythonSdkDetailsStep(project, moreDialog, ownerComponent, existingSdks, sdkAddedCallback);
    sdkHomesStep.setNewProject(isNewProject);
    final ListPopup popup = JBPopupFactory.getInstance().createListPopup(sdkHomesStep);
    popup.showInScreenCoordinates(ownerComponent, popupPoint);
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 7 with ListPopup

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

the class IpnbEditablePanel method addRightClickMenu.

@Override
protected void addRightClickMenu() {
    myViewPanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e) && e.getClickCount() == 1) {
                final DefaultActionGroup group = new DefaultActionGroup(new IpnbMergeCellAboveAction(), new IpnbMergeCellBelowAction());
                final ListPopup menu = createPopupMenu(group);
                menu.show(RelativePoint.fromScreen(e.getLocationOnScreen()));
            }
        }
    });
    myEditableTextArea.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e) && e.getClickCount() == 1) {
                final DefaultActionGroup group = new DefaultActionGroup(new IpnbSplitCellAction());
                final ListPopup menu = createPopupMenu(group);
                menu.show(RelativePoint.fromScreen(e.getLocationOnScreen()));
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) IpnbMergeCellBelowAction(org.jetbrains.plugins.ipnb.editor.actions.IpnbMergeCellBelowAction) MouseAdapter(java.awt.event.MouseAdapter) ListPopup(com.intellij.openapi.ui.popup.ListPopup) IpnbMergeCellAboveAction(org.jetbrains.plugins.ipnb.editor.actions.IpnbMergeCellAboveAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) IpnbSplitCellAction(org.jetbrains.plugins.ipnb.editor.actions.IpnbSplitCellAction)

Example 8 with ListPopup

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

the class LineSeparatorPanel method showPopup.

private void showPopup(MouseEvent e) {
    if (!myActionEnabled) {
        return;
    }
    DataContext dataContext = getContext();
    AnAction group = ActionManager.getInstance().getAction("ChangeLineSeparators");
    if (!(group instanceof ActionGroup)) {
        return;
    }
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Line separator", (ActionGroup) group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
    Dimension dimension = popup.getContent().getPreferredSize();
    Point at = new Point(0, -dimension.height);
    popup.show(new RelativePoint(e.getComponent(), at));
    // destroy popup on unexpected project close
    Disposer.register(this, popup);
}
Also used : SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) ListPopup(com.intellij.openapi.ui.popup.ListPopup) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 9 with ListPopup

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

the class IntelliSortChooserPopupAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    VcsLogUi logUI = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
    VcsLogUiProperties properties = e.getRequiredData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);
    ActionGroup settingsGroup = new DefaultActionGroup(ContainerUtil.map(PermanentGraph.SortType.values(), (Function<PermanentGraph.SortType, AnAction>) sortType -> new SelectIntelliSortTypeAction(logUI, properties, sortType)));
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, settingsGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUi.POPUP_PLACE);
    Component component = e.getInputEvent().getComponent();
    if (component instanceof ActionButtonComponent) {
        popup.showUnderneathOf(component);
    } else {
        popup.showInCenterOf(component);
    }
}
Also used : Function(com.intellij.util.Function) MainVcsLogUiProperties(com.intellij.vcs.log.impl.MainVcsLogUiProperties) VcsLogUiProperties(com.intellij.vcs.log.impl.VcsLogUiProperties) ListPopup(com.intellij.openapi.ui.popup.ListPopup) VcsLogUi(com.intellij.vcs.log.VcsLogUi) PermanentGraph(com.intellij.vcs.log.graph.PermanentGraph)

Example 10 with ListPopup

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

the class ToolWindowContentUi method toggleContentPopup.

public void toggleContentPopup() {
    if (myShouldNotShowPopup) {
        myShouldNotShowPopup = false;
        return;
    }
    final Ref<AnAction> selected = Ref.create();
    final Ref<AnAction> selectedTab = Ref.create();
    final Content[] contents = myManager.getContents();
    final Content selectedContent = myManager.getSelectedContent();
    final AnAction[] actions = new AnAction[contents.length];
    for (int i = 0; i < actions.length; i++) {
        final Content content = contents[i];
        if (content instanceof TabbedContent) {
            final TabbedContent tabbedContent = (TabbedContent) content;
            final List<Pair<String, JComponent>> tabs = ((TabbedContent) content).getTabs();
            final AnAction[] tabActions = new AnAction[tabs.size()];
            for (int j = 0; j < tabActions.length; j++) {
                final int index = j;
                tabActions[j] = new DumbAwareAction(tabs.get(index).first) {

                    @Override
                    public void actionPerformed(@NotNull AnActionEvent e) {
                        myManager.setSelectedContent(tabbedContent);
                        tabbedContent.selectContent(index);
                    }
                };
            }
            final DefaultActionGroup group = new DefaultActionGroup(tabActions);
            group.getTemplatePresentation().setText(((TabbedContent) content).getTitlePrefix());
            group.setPopup(true);
            actions[i] = group;
            if (content == selectedContent) {
                selected.set(group);
                final int selectedIndex = ContentUtilEx.getSelectedTab(tabbedContent);
                if (selectedIndex != -1) {
                    selectedTab.set(tabActions[selectedIndex]);
                }
            }
        } else {
            actions[i] = new DumbAwareAction() {

                {
                    getTemplatePresentation().setText(content.getTabName(), false);
                }

                @Override
                public void actionPerformed(@NotNull AnActionEvent e) {
                    myManager.setSelectedContent(content, true, true);
                }
            };
            if (content == selectedContent) {
                selected.set(actions[i]);
            }
        }
    }
    final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, new DefaultActionGroup(actions), DataManager.getInstance().getDataContext(myManager.getComponent()), false, true, true, null, -1, action -> action == selected.get() || action == selectedTab.get());
    getCurrentLayout().showContentPopup(popup);
    if (selectedContent instanceof TabbedContent) {
        new Alarm(Alarm.ThreadToUse.SWING_THREAD, popup).addRequest(() -> popup.handleSelect(true), 30);
    }
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) Alarm(com.intellij.util.Alarm) Pair(com.intellij.openapi.util.Pair)

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