Search in sources :

Example 1 with CheckBoxFilterAction

use of io.github.kings1990.plugin.fastrequest.action.CheckBoxFilterAction in project fast-request by dromara.

the class AllApisNavToolWindow method initActionBar.

private void initActionBar() {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new RefreshApiAction());
    group.add(CommonActionsManager.getInstance().createExpandAllAction(apiTree, apiTree));
    group.add(CommonActionsManager.getInstance().createCollapseAllAction(apiTree, apiTree));
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    List<String> moduleList = Arrays.stream(modules).map(Module::getName).sorted().collect(Collectors.toList());
    moduleFilter = new CheckBoxFilterAction.Filter<>(moduleList, module -> module, module -> null, FastRequestSearchEverywhereConfiguration.getInstance());
    group.add(new CheckBoxFilterAction<>("Filter Module", "Filter module", AllIcons.Actions.GroupByModule, moduleFilter, this::refresh));
    List<String> methodNameList = Constant.METHOD_TYPE_LIST.stream().map(MethodType::getName).collect(Collectors.toList());
    Map<String, Icon> iconMap = Constant.METHOD_TYPE_LIST.stream().collect(Collectors.toMap(MethodType::getName, MethodType::getIcon));
    methodTypeFilter = new CheckBoxFilterAction.Filter<>(methodNameList, methodName -> methodName, iconMap::get, FastRequestSearchEverywhereConfiguration.getInstance());
    group.add(new CheckBoxFilterAction<>("Filter Method", "Filter Method", AllIcons.Actions.GroupByMethod, methodTypeFilter, this::refresh));
    ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.TOOLWINDOW_CONTENT, group, false);
    actionToolbar.setTargetComponent(panel);
    JComponent toolbarComponent = actionToolbar.getComponent();
    Border border = IdeBorderFactory.createBorder(SideBorder.BOTTOM);
    actionToolbar.getComponent().setBorder(border);
    setToolbar(toolbarComponent);
}
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) CheckBoxFilterAction(io.github.kings1990.plugin.fastrequest.action.CheckBoxFilterAction) Module(com.intellij.openapi.module.Module) Border(javax.swing.border.Border)

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