Search in sources :

Example 41 with ListPopup

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

the class GitPushTargetPanel method showRemoteSelector.

private void showRemoteSelector(@NotNull Component component, @NotNull Point point) {
    List<PopupItem> remotes = getPopupItems();
    if (remotes.size() <= 1) {
        return;
    }
    ListPopup popup = new ListPopupImpl(new BaseListPopupStep<PopupItem>(null, remotes) {

        @Override
        public PopupStep onChosen(@NotNull PopupItem selectedValue, boolean finalChoice) {
            return doFinalStep(() -> {
                if (selectedValue.isDefineRemote()) {
                    showDefineRemoteDialog();
                } else {
                    myRemoteRenderer.updateLinkText(selectedValue.getPresentable());
                    if (myFireOnChangeAction != null && !myTargetEditor.isShowing()) {
                        //fireOnChange only when editing completed
                        myFireOnChangeAction.run();
                    }
                }
            });
        }

        @Nullable
        @Override
        public ListSeparator getSeparatorAbove(PopupItem value) {
            return value.isDefineRemote() ? new ListSeparator() : null;
        }
    }) {

        @Override
        public void cancel(InputEvent e) {
            super.cancel(e);
            if (myTargetEditor.isShowing()) {
                //repaint and force move focus to target editor component
                GitPushTargetPanel.this.repaint();
                IdeFocusManager.getInstance(myProject).requestFocus(myTargetEditor, true);
            }
        }
    };
    popup.show(new RelativePoint(component, point));
}
Also used : ListSeparator(com.intellij.openapi.ui.popup.ListSeparator) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) ListPopup(com.intellij.openapi.ui.popup.ListPopup) RelativePoint(com.intellij.ui.awt.RelativePoint) Nullable(org.jetbrains.annotations.Nullable) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep)

Example 42 with ListPopup

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

the class TemplateListPanel method addTemplateOrGroup.

private void addTemplateOrGroup(AnActionButton button) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new DumbAwareAction("Live Template") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            addTemplate();
        }
    });
    group.add(new DumbAwareAction("Template Group...") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Create New Group", null, "", new TemplateGroupInputValidator(null));
            if (newName != null) {
                TemplateGroup newGroup = new TemplateGroup(newName);
                setSelectedNode(insertNewGroup(newGroup));
            }
        }
    });
    DataContext context = DataManager.getInstance().getDataContext(button.getContextComponent());
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.ALPHA_NUMBERING, true, null);
    popup.show(button.getPreferredPopupPoint());
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

Example 43 with ListPopup

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

the class GotoActionAction method performAction.

public static void performAction(Object element, @Nullable final Component component, @Nullable final AnActionEvent e, @Nullable final Runnable callback) {
    // element could be AnAction (SearchEverywhere)
    if (component == null)
        return;
    final AnAction action = element instanceof AnAction ? (AnAction) element : ((GotoActionModel.ActionWrapper) element).getAction();
    TransactionGuard.getInstance().submitTransactionLater(ApplicationManager.getApplication(), () -> {
        DataManager instance = DataManager.getInstance();
        DataContext context = instance != null ? instance.getDataContext(component) : DataContext.EMPTY_CONTEXT;
        InputEvent inputEvent = e == null ? null : e.getInputEvent();
        AnActionEvent event = AnActionEvent.createFromAnAction(action, inputEvent, ActionPlaces.ACTION_SEARCH, context);
        if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
            if (action instanceof ActionGroup && ((ActionGroup) action).getChildren(event).length > 0) {
                ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(event.getPresentation().getText(), (ActionGroup) action, context, false, callback, -1);
                Window window = SwingUtilities.getWindowAncestor(component);
                if (window != null) {
                    popup.showInCenterOf(window);
                } else {
                    popup.showInFocusCenter();
                }
            } else {
                ActionUtil.performActionDumbAware(action, event);
                if (callback != null)
                    callback.run();
            }
        }
    });
}
Also used : ProgressWindow(com.intellij.openapi.progress.util.ProgressWindow) ListPopup(com.intellij.openapi.ui.popup.ListPopup) GotoActionModel(com.intellij.ide.util.gotoByName.GotoActionModel) DataManager(com.intellij.ide.DataManager)

Example 44 with ListPopup

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

the class SelectInAction method invoke.

private static void invoke(@NotNull DataContext dataContext, @NotNull SelectInContext context) {
    final List<SelectInTarget> targetVector = Arrays.asList(getSelectInManager(context.getProject()).getTargets());
    ListPopup popup;
    if (targetVector.isEmpty()) {
        DefaultActionGroup group = new DefaultActionGroup();
        group.add(new NoTargetsAction());
        popup = JBPopupFactory.getInstance().createActionGroupPopup(IdeBundle.message("title.popup.select.target"), group, dataContext, JBPopupFactory.ActionSelectionAid.MNEMONICS, true);
    } else {
        popup = JBPopupFactory.getInstance().createListPopup(new SelectInActionsStep(targetVector, context));
    }
    popup.showInBestPositionFor(dataContext);
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 45 with ListPopup

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

the class AddNewLibraryDependencyAction method chooseTypeAndCreate.

public static void chooseTypeAndCreate(final ClasspathPanel classpathPanel, final StructureConfigurableContext context, final JButton contextButton, @NotNull final LibraryCreatedCallback callback) {
    if (LibraryEditingUtil.hasSuitableTypes(classpathPanel)) {
        final ListPopup popup = JBPopupFactory.getInstance().createListPopup(LibraryEditingUtil.createChooseTypeStep(classpathPanel, libraryType -> doCreateLibrary(classpathPanel, context, callback, contextButton, libraryType)));
        popup.showUnderneathOf(contextButton);
    } else {
        doCreateLibrary(classpathPanel, context, callback, contextButton, null);
    }
}
Also used : Library(com.intellij.openapi.roots.libraries.Library) ListPopup(com.intellij.openapi.ui.popup.ListPopup) Nullable(org.jetbrains.annotations.Nullable) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibraryEditingUtil(com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryType(com.intellij.openapi.roots.libraries.LibraryType) NotNull(org.jetbrains.annotations.NotNull) ParameterizedRunnable(com.intellij.util.ParameterizedRunnable) javax.swing(javax.swing) 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