Skip to content

Commit

Permalink
Added expand and collapse all actions to the project window
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Jul 28, 2024
1 parent 52e504e commit ef38658
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/main/java/rife/bld/idea/project/BldProjectWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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_));
Expand All @@ -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_));
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/messages/BldBundle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
bld.project.progress.refresh=Refreshing bld

0 comments on commit ef38658

Please sign in to comment.