From ef38658803867765778f129b8136b02dbfc6267d Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Sun, 28 Jul 2024 18:29:18 -0400 Subject: [PATCH] Added expand and collapse all actions to the project window --- .../bld/idea/project/BldProjectWindow.java | 18 ++++++++++++++++++ .../resources/messages/BldBundle.properties | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/rife/bld/idea/project/BldProjectWindow.java b/src/main/java/rife/bld/idea/project/BldProjectWindow.java index 0a1d045..c6510fe 100644 --- a/src/main/java/rife/bld/idea/project/BldProjectWindow.java +++ b/src/main/java/rife/bld/idea/project/BldProjectWindow.java @@ -6,7 +6,10 @@ import com.intellij.execution.RunManagerListener; import com.intellij.execution.ui.ConsoleViewContentType; +import com.intellij.ide.CommonActionsManager; import com.intellij.ide.DataManager; +import com.intellij.ide.DefaultTreeExpander; +import com.intellij.ide.TreeExpander; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.fileEditor.FileDocumentManager; @@ -135,6 +138,14 @@ public void dispose() { config_ = null; } + private final TreeExpander treeExpander_ = new DefaultTreeExpander(() -> tree_) { + @Override + protected boolean isEnabled(@NotNull JTree tree) { + final BldConfiguration config = config_; + return config != null && super.isEnabled(tree); + } + }; + private JPanel createToolbarPanel() { final var group = new DefaultActionGroup(); group.add(new BldProjectActionRefresh(project_)); @@ -143,6 +154,13 @@ private JPanel createToolbarPanel() { group.add(new BldProjectActionEditMain(project_)); group.add(new BldProjectActionEditProperties(project_)); group.addSeparator(); + AnAction action = CommonActionsManager.getInstance().createExpandAllAction(treeExpander_, this); + action.getTemplatePresentation().setDescription(BldBundle.messagePointer("bld.action.expand.all.description")); + group.add(action); + action = CommonActionsManager.getInstance().createCollapseAllAction(treeExpander_, this); + action.getTemplatePresentation().setDescription(BldBundle.messagePointer("bld.action.collapse.all.description")); + group.add(action); + group.addSeparator(); group.add(new BldProjectActionClearCache(project_)); group.addSeparator(); group.add(new BldProjectActionOffline(project_)); diff --git a/src/main/resources/messages/BldBundle.properties b/src/main/resources/messages/BldBundle.properties index 68f4d59..554fe8d 100644 --- a/src/main/resources/messages/BldBundle.properties +++ b/src/main/resources/messages/BldBundle.properties @@ -1,9 +1,11 @@ bld.action.clearCache.description=Remove the bld cache bld.action.clearCache.name=Clear Cache +bld.action.collapse.all.description=Collapse all nodes bld.action.command.help.description=Display help for command bld.action.command.help.name=Help bld.action.edit.description=Edit the bld main class bld.action.edit.name=Edit Main +bld.action.expand.all.description=Expand all nodes bld.action.offline.description=Work with or without internet bld.action.offline.name=Toggle Offline Mode bld.action.properties.description=Edit the bld wrapper properties @@ -40,4 +42,4 @@ bld.project.console.refresh=> refresh\n bld.project.dependencies=Dependencies bld.project.execute.on.action.group.name=Execute On bld.project.progress.commands=Running bld {0} -bld.project.progress.refresh=Refreshing bld \ No newline at end of file +bld.project.progress.refresh=Refreshing bld