Search in sources :

Example 1 with CollectionUtil

use of cn.hutool.core.collection.CollectionUtil in project fast-request by dromara.

the class AllApisNavToolWindow method refreshFilterModule.

public void refreshFilterModule(List<String> selectModule, List<String> selectMethodType) {
    DumbService.getInstance(myProject).smartInvokeLater(() -> {
        Task.Backgroundable task = new Task.Backgroundable(myProject, "Reload apis...") {

            @Override
            public void run(@NotNull ProgressIndicator indicator) {
                indicator.setIndeterminate(false);
                ApplicationManager.getApplication().runReadAction(() -> {
                    if (allApiList == null) {
                        return;
                    }
                    List<ApiService> filterList = allApiList.stream().filter(q -> selectModule.contains(q.getModuleName())).collect(Collectors.toList());
                    indicator.setText("Rendering");
                    List<ApiService.ApiMethod> filterMethodList = new ArrayList<>();
                    filterList.stream().map(ApiService::getApiMethodList).filter(CollectionUtil::isNotEmpty).forEach(filterMethodList::addAll);
                    long count = filterMethodList.stream().filter(q -> selectMethodType.contains(q.getMethodType())).count();
                    RootNode root = new RootNode(count + " apis") {
                    };
                    NodeUtil.convertToRoot(root, NodeUtil.convertToMap(filterList.stream().filter(q -> CollectionUtil.isNotEmpty(q.getApiMethodList())).filter(q -> q.getApiMethodList().stream().anyMatch(p -> selectMethodType.contains(p.getMethodType()))).collect(Collectors.toList())), selectMethodType);
                    apiTree.setModel(new DefaultTreeModel(root));
                });
            }
        };
        ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task));
    });
}
Also used : java.util(java.util) AllIcons(com.intellij.icons.AllIcons) MessageType(com.intellij.openapi.ui.MessageType) ModuleManager(com.intellij.openapi.module.ModuleManager) ApiService(io.github.kings1990.plugin.fastrequest.model.ApiService) KeyAdapter(java.awt.event.KeyAdapter) Border(javax.swing.border.Border) Query(com.intellij.util.Query) PsiClass(com.intellij.psi.PsiClass) PersistentSearchEverywhereContributorFilter(com.intellij.ide.actions.searcheverywhere.PersistentSearchEverywhereContributorFilter) ModuleUtil(com.intellij.openapi.module.ModuleUtil) Task(com.intellij.openapi.progress.Task) MethodType(io.github.kings1990.plugin.fastrequest.model.MethodType) Disposer(com.intellij.openapi.util.Disposer) MouseAdapter(java.awt.event.MouseAdapter) Project(com.intellij.openapi.project.Project) SpeedSearchUtil(com.intellij.ui.speedSearch.SpeedSearchUtil) AllClassesSearch(com.intellij.psi.search.searches.AllClassesSearch) PsiNavigateUtil(com.intellij.util.PsiNavigateUtil) Module(com.intellij.openapi.module.Module) CommonActionsManager(com.intellij.ide.CommonActionsManager) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator) io.github.kings1990.plugin.fastrequest.view.component.tree(io.github.kings1990.plugin.fastrequest.view.component.tree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ProgressManager(com.intellij.openapi.progress.ProgressManager) DumbService(com.intellij.openapi.project.DumbService) CollectionUtil(cn.hutool.core.collection.CollectionUtil) NotificationGroupManager(com.intellij.notification.NotificationGroupManager) ToolWindow(com.intellij.openapi.wm.ToolWindow) PsiMethod(com.intellij.psi.PsiMethod) FastRequestSearchEverywhereConfiguration(io.github.kings1990.plugin.fastrequest.configurable.FastRequestSearchEverywhereConfiguration) CheckBoxFilterAction(io.github.kings1990.plugin.fastrequest.action.CheckBoxFilterAction) KeyEvent(java.awt.event.KeyEvent) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) Disposable(com.intellij.openapi.Disposable) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) List(java.util.List) Constant(io.github.kings1990.plugin.fastrequest.config.Constant) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ProjectScope(com.intellij.psi.search.ProjectScope) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) Task(com.intellij.openapi.progress.Task) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) NotNull(org.jetbrains.annotations.NotNull) ApiService(io.github.kings1990.plugin.fastrequest.model.ApiService) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)

Aggregations

CollectionUtil (cn.hutool.core.collection.CollectionUtil)1 AllIcons (com.intellij.icons.AllIcons)1 CommonActionsManager (com.intellij.ide.CommonActionsManager)1 PersistentSearchEverywhereContributorFilter (com.intellij.ide.actions.searcheverywhere.PersistentSearchEverywhereContributorFilter)1 NotificationGroupManager (com.intellij.notification.NotificationGroupManager)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Module (com.intellij.openapi.module.Module)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 ModuleUtil (com.intellij.openapi.module.ModuleUtil)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Task (com.intellij.openapi.progress.Task)1 BackgroundableProcessIndicator (com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)1 DumbService (com.intellij.openapi.project.DumbService)1 Project (com.intellij.openapi.project.Project)1 MessageType (com.intellij.openapi.ui.MessageType)1 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)1 Disposer (com.intellij.openapi.util.Disposer)1