Skip to content

Commit ad58c92

Browse files
committed
This change introduces "Expand All" and "Collapse All" toolbar options
in the API Errors/Warnings preference page in the UI (Eclipse->Settings->Plugin-Development Environment->API Errors/Warnings).
1 parent ebb6634 commit ad58c92

File tree

4 files changed

+207
-0
lines changed

4 files changed

+207
-0
lines changed
Lines changed: 149 additions & 0 deletions
Loading

apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/ApiErrorsWarningsPreferencePage.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@
3232
import org.eclipse.pde.api.tools.ui.internal.SWTFactory;
3333
import org.eclipse.swt.SWT;
3434
import org.eclipse.swt.events.SelectionListener;
35+
import org.eclipse.swt.graphics.Image;
3536
import org.eclipse.swt.layout.GridData;
3637
import org.eclipse.swt.widgets.Composite;
3738
import org.eclipse.swt.widgets.Control;
3839
import org.eclipse.swt.widgets.Link;
40+
import org.eclipse.swt.widgets.ToolBar;
41+
import org.eclipse.swt.widgets.ToolItem;
3942
import org.eclipse.ui.IWorkbench;
4043
import org.eclipse.ui.IWorkbenchPreferencePage;
4144
import org.eclipse.ui.PlatformUI;
4245
import org.eclipse.ui.dialogs.PreferencesUtil;
46+
import org.eclipse.ui.forms.widgets.ExpandableComposite;
47+
import org.eclipse.ui.plugin.AbstractUIPlugin;
4348
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
4449

4550
/**
@@ -85,6 +90,9 @@ public class ApiErrorsWarningsPreferencePage extends PreferencePage implements I
8590
ApiErrorsWarningsConfigurationBlock block = null;
8691
private Link link = null;
8792

93+
private Image expandImage;
94+
private Image collapseImage;
95+
8896
/**
8997
* Since {@link #applyData(Object)} can be called before createContents,
9098
* store the data
@@ -98,6 +106,21 @@ public ApiErrorsWarningsPreferencePage() {
98106
super(PreferenceMessages.ApiErrorsWarningsPreferencePage_0);
99107
}
100108

109+
private void expandCollapseItems(Composite parent, boolean expandPage) {
110+
for (Control control : parent.getChildren()) {
111+
if (control instanceof ExpandableComposite page) {
112+
page.setExpanded(expandPage);
113+
Control child = page.getClient();
114+
if (child != null && !child.isDisposed()) {
115+
child.setVisible(expandPage);
116+
}
117+
} else if (control instanceof Composite) {
118+
expandCollapseItems((Composite) control, expandPage);
119+
}
120+
}
121+
parent.layout(true, true);
122+
}
123+
101124
@Override
102125
protected Control createContents(Composite parent) {
103126
Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
@@ -127,9 +150,38 @@ protected Control createContents(Composite parent) {
127150
new String[] { IApiToolsConstants.ID_ERRORS_WARNINGS_PROP_PAGE }, data).open();
128151
}
129152
}));
153+
154+
ToolBar buttonbar = new ToolBar(comp, SWT.FLAT | SWT.RIGHT);
155+
buttonbar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true,
156+
false));
157+
ToolItem expandItems = new ToolItem(buttonbar, SWT.PUSH);
158+
expandImage = AbstractUIPlugin
159+
.imageDescriptorFromPlugin("org.eclipse.pde.api.tools.ui", "icons/full/elcl16/expandall.svg") //$NON-NLS-1$ //$NON-NLS-2$
160+
.createImage();
161+
expandItems.setImage(expandImage);
162+
expandItems.setToolTipText(PreferenceMessages.Preference_Expand_All);
163+
164+
ToolItem collapseItems = new ToolItem(buttonbar, SWT.PUSH);
165+
collapseImage = AbstractUIPlugin
166+
.imageDescriptorFromPlugin("org.eclipse.pde.api.tools.ui", "icons/full/elcl16/collapseall.svg") //$NON-NLS-1$ //$NON-NLS-2$
167+
.createImage();
168+
collapseItems.setImage(collapseImage);
169+
collapseItems.setToolTipText(PreferenceMessages.Preference_Collapse_All);
170+
130171
block = new ApiErrorsWarningsConfigurationBlock(null, (IWorkbenchPreferenceContainer) getContainer());
131172
block.createControl(comp);
132173

174+
expandItems.addListener(SWT.Selection, e -> expandCollapseItems(comp, true));
175+
collapseItems.addListener(SWT.Selection, e -> expandCollapseItems(comp, false));
176+
comp.addDisposeListener(e -> {
177+
if (!expandImage.isDisposed() && expandImage != null) {
178+
expandImage.dispose();
179+
}
180+
if (!collapseImage.isDisposed() && collapseImage != null) {
181+
collapseImage.dispose();
182+
}
183+
});
184+
133185
// Initialize with data map in case applyData was called before
134186
// createContents
135187
applyData(fPageData);

apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/PreferenceMessages.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ public class PreferenceMessages extends NLS {
165165
public static String CONSTRUCTOR_CHANGED_DECREASE_ACCESS;
166166
public static String CONSTRUCTOR_REMOVED_TYPE_PARAMETER;
167167

168+
public static String Preference_Collapse_All;
169+
public static String Preference_Expand_All;
170+
168171
public static String TYPE_PARAMETER_ADDED_CLASS_BOUND;
169172
public static String TYPE_PARAMETER_ADDED_INTERFACE_BOUND;
170173
public static String TYPE_PARAMETER_CHANGED_CLASS_BOUND;

apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/preferencemessages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ CONSTRUCTOR_CHANGED_VARARGS_TO_ARRAY=Converted variable argument type to array t
139139
CONSTRUCTOR_CHANGED_DECREASE_ACCESS=The visibility has been reduced:
140140
CONSTRUCTOR_REMOVED_TYPE_PARAMETER=A type parameter has been removed:
141141

142+
Preference_Collapse_All= Collapse All
143+
Preference_Expand_All= Expand All
144+
142145
TYPE_PARAMETER_ADDED_CLASS_BOUND=A class bound has been added:
143146
TYPE_PARAMETER_ADDED_INTERFACE_BOUND=An interface bound has been added:
144147
TYPE_PARAMETER_CHANGED_CLASS_BOUND=A class bound has been modified:

0 commit comments

Comments
 (0)