Skip to content

Commit eada2d8

Browse files
committed
This change introduces "Expand All" and "Collapse All" toolbar option
in the compilers tab preference page in the UI (Eclipse->Settings->Plugin-Development Environment->compilers).
1 parent abc3cc7 commit eada2d8

File tree

4 files changed

+236
-1
lines changed

4 files changed

+236
-1
lines changed
Lines changed: 165 additions & 0 deletions
Loading

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3162,7 +3162,9 @@ public class PDEUIMessages extends NLS {
31623162
public static String PreferencesSection_generate_merge2;
31633163
public static String PreferencesSection_generate_merge3;
31643164
public static String PreferencesSection_generate_merge4;
3165-
3165+
public static String Preference_expand_all;
3166+
public static String Preference_collapse_all;
3167+
31663168
public static String ConvertPreferencesWizardPage_title;
31673169
public static String ConvertPreferencesWizardPage_description;
31683170
public static String ConvertPreferencesWizardPage_source_file;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ Preferences_MainPage_showObjects = Plug-in presentation:
695695
Preferences_MainPage_useIds = Show &identifiers
696696
Preferences_MainPage_useFullNames = Show &presentation names
697697

698+
Preference_expand_all= Expand all preferences
699+
Preference_collapse_all= Collapse all preferences
700+
698701
ExternalizeStringsWizard_title=Externalize Strings
699702
ExternalizeResolution_attrib=Externalize the {0} attribute
700703
ExternalizeResolution_text=Externalize {0}''s text

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/CompilersPreferencePage.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@
3131
import org.eclipse.pde.internal.ui.PDEUIMessages;
3232
import org.eclipse.pde.internal.ui.SWTFactory;
3333
import org.eclipse.swt.SWT;
34+
import org.eclipse.swt.custom.ScrolledComposite;
35+
import org.eclipse.swt.graphics.Image;
3436
import org.eclipse.swt.layout.GridData;
3537
import org.eclipse.swt.widgets.Composite;
3638
import org.eclipse.swt.widgets.Control;
3739
import org.eclipse.swt.widgets.Link;
40+
import org.eclipse.swt.widgets.ToolBar;
41+
import org.eclipse.swt.widgets.ToolItem;
3842
import org.eclipse.ui.IWorkbench;
3943
import org.eclipse.ui.IWorkbenchPreferencePage;
4044
import org.eclipse.ui.PlatformUI;
4145
import org.eclipse.ui.dialogs.PreferencesUtil;
46+
import org.eclipse.ui.forms.widgets.ExpandableComposite;
47+
import org.eclipse.ui.plugin.AbstractUIPlugin;
4248
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
4349

4450
/**
@@ -61,6 +67,9 @@ public class CompilersPreferencePage extends PreferencePage implements IWorkbenc
6167
private PDECompilersConfigurationBlock fBlock = null;
6268
private Link link = null;
6369

70+
private Image expandImage;
71+
private Image collapseImage;
72+
6473
/**
6574
* Since {@link #applyData(Object)} can be called before createContents, store the data
6675
*/
@@ -78,6 +87,33 @@ public void createControl(Composite composite) {
7887
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMPILERS_PREFERENCE_PAGE);
7988
}
8089

90+
private void expandCollapseItems(Composite parent, boolean expandPage) {
91+
for (Control control : parent.getChildren()) {
92+
if (control instanceof ExpandableComposite page) {
93+
page.setExpanded(expandPage);
94+
Control child = page.getClient();
95+
if (child != null && !child.isDisposed()) {
96+
child.setVisible(expandPage);
97+
}
98+
} else if (control instanceof Composite) {
99+
expandCollapseItems((Composite) control, expandPage);
100+
}
101+
}
102+
parent.layout(true, true);
103+
ScrolledComposite composite = getScrolledComposite(parent);
104+
if (composite != null) {
105+
composite.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
106+
}
107+
}
108+
109+
private ScrolledComposite getScrolledComposite(Composite comp) {
110+
Composite currentComposite = comp;
111+
while (currentComposite != null && !(currentComposite instanceof ScrolledComposite)) {
112+
currentComposite = currentComposite.getParent();
113+
}
114+
return (ScrolledComposite) currentComposite;
115+
}
116+
81117
@Override
82118
protected Control createContents(Composite parent) {
83119
Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
@@ -106,9 +142,38 @@ protected Control createContents(Composite parent) {
106142
new String[] {"org.eclipse.pde.internal.ui.properties.compilersPropertyPage"}, data).open(); //$NON-NLS-1$
107143
}
108144
}));
145+
146+
ToolBar buttonbar = new ToolBar(comp, SWT.FLAT | SWT.RIGHT);
147+
buttonbar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
148+
ToolItem expandItems = new ToolItem(buttonbar, SWT.PUSH);
149+
expandImage = AbstractUIPlugin
150+
.imageDescriptorFromPlugin("org.eclipse.pde.ui", "icons/elcl16/expandall.svg") //$NON-NLS-1$ //$NON-NLS-2$
151+
.createImage();
152+
expandItems.setImage(expandImage);
153+
expandItems.setToolTipText(PDEUIMessages.Preference_expand_all);
154+
155+
ToolItem collapseItems = new ToolItem(buttonbar, SWT.PUSH);
156+
collapseImage = AbstractUIPlugin
157+
.imageDescriptorFromPlugin("org.eclipse.pde.ui", //$NON-NLS-1$
158+
"icons/elcl16/collapseall.svg") //$NON-NLS-1$
159+
.createImage();
160+
collapseItems.setImage(collapseImage);
161+
collapseItems.setToolTipText(PDEUIMessages.Preference_collapse_all);
162+
109163
fBlock = new PDECompilersConfigurationBlock(null, (IWorkbenchPreferenceContainer) getContainer());
110164
fBlock.createControl(comp);
111165

166+
expandItems.addListener(SWT.Selection, e -> expandCollapseItems(comp, true));
167+
collapseItems.addListener(SWT.Selection, e -> expandCollapseItems(comp, false));
168+
comp.addDisposeListener(e -> {
169+
if (!expandImage.isDisposed() && expandImage != null) {
170+
expandImage.dispose();
171+
}
172+
if (!collapseImage.isDisposed() && collapseImage != null) {
173+
collapseImage.dispose();
174+
}
175+
});
176+
112177
// Initialize with data map in case applyData was called before createContents
113178
applyData(fPageData);
114179

0 commit comments

Comments
 (0)