Skip to content

Commit a91ca06

Browse files
committed
GH-1689: added expand/collapse all to structure view for Eclipse
1 parent 035c174 commit a91ca06

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Broadcom, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Broadcom, Inc. - initial API and implementation
10+
*******************************************************************************/
11+
package org.springframework.tooling.boot.ls.views;
12+
13+
import org.eclipse.jdt.internal.ui.JavaPluginImages;
14+
import org.eclipse.jface.action.Action;
15+
16+
class ExpandCollapseAction extends Action {
17+
18+
private final LogicalStructureView logicalStructureView;
19+
private final boolean expand;
20+
21+
@SuppressWarnings("restriction")
22+
ExpandCollapseAction(LogicalStructureView logicalStructureView, boolean expand) {
23+
super(expand ? "Expand All" : "Collapse All");
24+
this.logicalStructureView = logicalStructureView;
25+
this.expand = expand;
26+
setToolTipText(expand ? "Expand All" : "Collapse All");
27+
JavaPluginImages.setLocalImageDescriptors(this, expand ? "expandall.svg" : "collapseall.svg");
28+
}
29+
30+
@Override
31+
public void run() {
32+
if (expand) {
33+
this.logicalStructureView.expandAll();
34+
} else {
35+
this.logicalStructureView.collapseAll();
36+
}
37+
}
38+
}
39+

eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/views/LogicalStructureView.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public void createPartControl(Composite parent) {
121121
private void initActions(IActionBars actionBars) {
122122
actionBars.getToolBarManager().add(new GroupingAction(this));
123123
actionBars.getToolBarManager().add(new RefreshAction(this));
124+
actionBars.getToolBarManager().add(new ExpandCollapseAction(this, true));
125+
actionBars.getToolBarManager().add(new ExpandCollapseAction(this, false));
124126
}
125127

126128
@Override
@@ -135,6 +137,14 @@ void setGroupings(Map<String, List<String>> groupings) {
135137
Map<String, List<String>> getGroupings() {
136138
return groupingRepository.getWorkspaceGroupings();
137139
}
140+
141+
void expandAll() {
142+
treeViewer.expandAll();
143+
}
144+
145+
void collapseAll() {
146+
treeViewer.collapseAll();
147+
}
138148

139149
}
140150

0 commit comments

Comments
 (0)