Enable theming preference check box is not working as expected and forces to restart twice
Let's make sure issue is not already fixed in latest builds first.
- [X] I verified I can reproduce this issue against latest Integration Build of Eclipse SDK
Steps to reproduce
From a fresh installation and clean workspace:
Install the setup of 'platform ui' by dragging the setup link in the banner of the installer : see Setting your environment and projects guide
Open the preference dialog and filter on 'theme'. Disable theming if there is one selected by unchecking the 'Enable Theming' checkbox and restart. Eclipse restarts without any theme.
Then reopen the preference dialog and filter on 'theme' then check the 'Enable theming' check box again and click Apply.
Eclipse will ask to restart, while no Theme has been yet selected.. and no theme has been proposed. The possible themes will appear after the restart and will be applicable, but we will have to restart again... this is not straightforward and totally counterintuitive.
Actually, when the 'Enable theming' is selected, it must display the themes and then propose to select one and restart when it is applied (even if the theme was not changed in the combo).
This is the current situation when we switch from 'Enable theming' unchecked to checked:
| What we have (unchecked to checked) | What we expect |
|---|---|
On the other hand, if we unchecked the theme while it was checked, the list of themes should be hidden:
| What we have (checked to unchecked) | What we expect |
|---|---|
The Plugin Spy (Alt Shift F1), launched when the preference page is displayed says that this preference page is managed by the ViewsPreferencePage in the org.eclipse.ui.workbench plugin :
A change event listener could be added on the preference checkbox editor so as to react on the change and display or not the bloc of theme list.
Tested under this environment:
- OS & version: macOS X 15.1 (sequoia).
- Eclipse IDE/Platform version (as shown in Help > About): Version: 2024-12 (4.34) Build id: I20241117-1800 (got from the platform.ui current setup)
Community
- [X] I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.
I'm working on this.
I added the event listener to the createContents method to respond to a change in the selection of the themingEnabled button. It works for checked-to-unchecked, hiding the theme-dependent elements when clicked. However, after restarting the dialog, when themingEnabled button is clicked again (unchecked-to-checked), the content is still hidden. We still need to restart twice to get the desired effect of enabling and changing themes.
protected Control createContents(Composite parent) {
// same code
Composite comp = new Composite(parent, SWT.NONE);
GridLayout mainLayout = new GridLayout();
comp.setLayout(mainLayout);
themingEnabled = createCheckButton(comp, WorkbenchMessages.ThemingEnabled, engine != null);
// same code
Composite themeDependentComp = new Composite(comp, SWT.NONE);
GridLayout dependentLayout = new GridLayout(2, false);
dependentLayout.horizontalSpacing = 10;
themeDependentComp.setLayout(dependentLayout);
GridData dependentData = new GridData(SWT.FILL, SWT.TOP, true, false);
themeDependentComp.setLayoutData(dependentData);
createThemeDependentComposite(themeDependentComp);
createThemeIndependentComposite(comp);
currentColorsAndFontsTheme = getCurrentColorsAndFontsTheme();
// same code
SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean isThemingEnabled = themingEnabled.getSelection();
themeDependentComp.setVisible(isThemingEnabled);
GridData gridData = ((GridData) themeDependentComp.getLayoutData());
gridData.exclude = !isThemingEnabled;
comp.layout();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
themeDependentComp.setVisible(true);
}
};
themingEnabled.addSelectionListener(listener);
I organized the theme-dependent elements in a private method.
private void createThemeDependentComposite(Composite comp) {
createThemeIdCombo(comp);
createColorsAndFontsThemeCombo(comp);
// Theme dependent controls for Tab icons and titles in view areas
createShowFullTextForViewTabs(comp);
createHideIconsForViewTabs(comp);
createTabDependency(showFullTextForViewTabs, hideIconsForViewTabs);
}
Hi,
I think you didn't consider to save/restore the preference value associated to your boolean checkbox. And when you restart your application, the saved value is not applied on your swt widgets.
You can check the calls to
private boolean getSwtRendererPreference(String prefName, boolean defaultValue) {
return Platform.getPreferencesService().getBoolean(PREF_QUALIFIER_ECLIPSE_E4_UI_WORKBENCH_RENDERERS_SWT,
prefName, defaultValue, null);
}
which gets the value from the preference store.
The file that contains the preference values managed by this screen is located in your workspace, in the folder : .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs
For my sample, it contains :
HIDE_ICONS_FOR_VIEW_TABS=false SHOW_FULL_TEXT_FOR_VIEW_TABS=true USE_ROUND_TABS=true eclipse.preferences.version=1 enableMRU=true themeEnabled=true
When you change your values and you apply the preferences, you could check which values have changed in this file and write the code to restore the value when you create (for the first time) the preference page.
Hello!
It seems the problem stems from disabling themingEnabled disables engine which is needed to create the theme combo dropdown and other components that depend on the engine to be initialized. When engine is null, the page only shows the basic buttons that do not rely on themingEnabled, so that's why we need to restart twice. Once to initialize engine so it can getThemes(), and twice to apply any other new changes. I'm not sure about other workarounds.