Search in sources :

Example 1 with ListPopupStep

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

the class ConfigureTasksActivationDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            ProjectItem projectItem = (ProjectItem) projectCombobox.getSelectedItem();
            if (projectItem == null)
                return;
            final ExternalProjectInfo projectData = ProjectDataManager.getInstance().getExternalProjectData(myProject, myProjectSystemId, projectItem.myProjectSettings.getExternalProjectPath());
            if (projectData == null || projectData.getExternalProjectStructure() == null)
                return;
            final List<ProjectPopupItem> popupItems = ContainerUtil.newArrayList();
            for (DataNode<ModuleData> moduleDataNode : ExternalSystemApiUtil.findAllRecursively(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) {
                if (moduleDataNode.isIgnored())
                    continue;
                final List<String> tasks = ContainerUtil.map(ExternalSystemApiUtil.findAll(moduleDataNode, ProjectKeys.TASK), node -> node.getData().getName());
                if (!tasks.isEmpty()) {
                    popupItems.add(new ProjectPopupItem(moduleDataNode.getData(), tasks));
                }
            }
            final ChooseProjectStep projectStep = new ChooseProjectStep(popupItems);
            final List<ProjectPopupItem> projectItems = projectStep.getValues();
            ListPopupStep step = projectItems.size() == 1 ? (ListPopupStep) projectStep.onChosen(projectItems.get(0), false) : projectStep;
            assert step != null;
            JBPopupFactory.getInstance().createListPopup(step).show(ObjectUtils.notNull(button.getPreferredPopupPoint(), RelativePoint.getSouthEastOf(projectCombobox)));
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            List<TaskActivationEntry> tasks = findSelectedTasks();
            myTaskActivator.removeTasks(tasks);
            updateTree(null);
        }
    }).setMoveUpAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            moveAction(-1);
        }
    }).setMoveUpActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return isMoveActionEnabled(-1);
        }
    }).setMoveDownAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            moveAction(+1);
        }
    }).setMoveDownActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return isMoveActionEnabled(+1);
        }
    }).setToolbarPosition(ActionToolbarPosition.RIGHT).setToolbarBorder(IdeBorderFactory.createEmptyBorder());
    tasksPanel.add(decorator.createPanel());
    return contentPane;
}
Also used : BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) ListPopupStep(com.intellij.openapi.ui.popup.ListPopupStep) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData)

Example 2 with ListPopupStep

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

the class GroupToolbarAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final ListPopupStep popupStep = popupFactory.createActionsStep(myGroup, e.getDataContext(), false, false, myGroup.getTemplatePresentation().getText(), myToolbarComponent, false, 0, false);
    popupFactory.createListPopup(popupStep).showUnderneathOf(myToolbarComponent);
}
Also used : ListPopupStep(com.intellij.openapi.ui.popup.ListPopupStep) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory)

Aggregations

ListPopupStep (com.intellij.openapi.ui.popup.ListPopupStep)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1