Search in sources :

Example 46 with ListPopup

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

the class AddDomElementAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final AnAction[] actions = getChildren(e);
    if (actions.length > 1) {
        final DefaultActionGroup group = new DefaultActionGroup();
        for (final AnAction action : actions) {
            group.add(action);
        }
        final DataContext dataContext = e.getDataContext();
        final ListPopup groupPopup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, dataContext, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
        showPopup(groupPopup, e);
    } else if (actions.length == 1) {
        actions[0].actionPerformed(e);
    }
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 47 with ListPopup

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

the class StudyNewProjectPanel method setupBrowseButton.

private void setupBrowseButton() {
    if (SystemInfo.isMac && !UIUtil.isUnderDarcula())
        myBrowseButton.putClientProperty("JButton.buttonType", null);
    myBrowseButton.setIcon(InteractiveLearningIcons.InterpreterGear);
    final FileChooserDescriptor fileChooser = new FileChooserDescriptor(true, false, false, true, false, false) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return file.isDirectory() || StudyUtils.isZip(file.getName());
        }

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return StudyUtils.isZip(file.getName());
        }
    };
    myBrowseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final BaseListPopupStep<String> popupStep = new BaseListPopupStep<String>("", "Add local course", LOGIN_TO_STEPIC) {

                @Override
                public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
                    return doFinalStep(() -> {
                        if ("Add local course".equals(selectedValue)) {
                            Project[] projects = ProjectManager.getInstance().getOpenProjects();
                            FileChooser.chooseFile(fileChooser, null, projects.length == 0 ? null : projects[0].getBaseDir(), file -> {
                                String fileName = file.getPath();
                                int oldSize = myAvailableCourses.size();
                                CourseInfo courseInfo = myGenerator.addLocalCourse(fileName);
                                if (courseInfo != null) {
                                    if (oldSize != myAvailableCourses.size()) {
                                        myCoursesComboBox.addItem(courseInfo);
                                    }
                                    myCoursesComboBox.setSelectedItem(courseInfo);
                                    setOK();
                                } else {
                                    setError(INVALID_COURSE);
                                    myCoursesComboBox.removeAllItems();
                                    myCoursesComboBox.addItem(CourseInfo.INVALID_COURSE);
                                    for (CourseInfo course : myAvailableCourses) {
                                        myCoursesComboBox.addItem(course);
                                    }
                                    myCoursesComboBox.setSelectedItem(CourseInfo.INVALID_COURSE);
                                }
                            });
                        } else if (LOGIN_TO_STEPIC.equals(selectedValue)) {
                            showLoginDialog(true, "Signing In And Getting Stepik Course List");
                        }
                    });
                }
            };
            final ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep);
            popup.showInScreenCoordinates(myBrowseButton, myBrowseButton.getLocationOnScreen());
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) ActionListener(java.awt.event.ActionListener) VirtualFile(com.intellij.openapi.vfs.VirtualFile) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) StudyUtils(com.jetbrains.edu.learning.StudyUtils) DefaultProjectFactory(com.intellij.openapi.project.DefaultProjectFactory) ArrayList(java.util.ArrayList) FacetValidatorsManager(com.intellij.facet.ui.FacetValidatorsManager) DefaultProjectFactoryImpl(com.intellij.openapi.project.DefaultProjectFactoryImpl) ProjectManager(com.intellij.openapi.project.ProjectManager) StudyProjectGenerator(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator) Project(com.intellij.openapi.project.Project) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AncestorEvent(javax.swing.event.AncestorEvent) ComboBox(com.intellij.openapi.ui.ComboBox) ProgressManager(com.intellij.openapi.progress.ProgressManager) InteractiveLearningIcons(icons.InteractiveLearningIcons) com.jetbrains.edu.learning.stepic(com.jetbrains.edu.learning.stepic) StringUtil(com.intellij.openapi.util.text.StringUtil) ValidationResult(com.intellij.facet.ui.ValidationResult) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton) ActionEvent(java.awt.event.ActionEvent) SystemInfo(com.intellij.openapi.util.SystemInfo) JBScrollPane(com.intellij.ui.components.JBScrollPane) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) java.awt(java.awt) ListPopup(com.intellij.openapi.ui.popup.ListPopup) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) AncestorListenerAdapter(com.intellij.ui.AncestorListenerAdapter) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) CourseInfo(com.jetbrains.edu.learning.courseFormat.CourseInfo) PopupStep(com.intellij.openapi.ui.popup.PopupStep) ApplicationManager(com.intellij.openapi.application.ApplicationManager) PanelWithAnchor(com.intellij.ui.PanelWithAnchor) LabeledComponent(com.intellij.openapi.ui.LabeledComponent) NotNull(org.jetbrains.annotations.NotNull) FileChooser(com.intellij.openapi.fileChooser.FileChooser) Course(com.jetbrains.edu.learning.courseFormat.Course) javax.swing(javax.swing) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ActionEvent(java.awt.event.ActionEvent) ListPopup(com.intellij.openapi.ui.popup.ListPopup) CourseInfo(com.jetbrains.edu.learning.courseFormat.CourseInfo) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) PopupStep(com.intellij.openapi.ui.popup.PopupStep) ActionListener(java.awt.event.ActionListener) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep)

Aggregations

ListPopup (com.intellij.openapi.ui.popup.ListPopup)47 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)10 NotNull (org.jetbrains.annotations.NotNull)10 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)9 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)7 PopupStep (com.intellij.openapi.ui.popup.PopupStep)7 RelativePoint (com.intellij.ui.awt.RelativePoint)7 Project (com.intellij.openapi.project.Project)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5 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 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)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