Skip to content

Style workspace selection dialog with default theme setting#3855

Merged
vogella merged 1 commit intoeclipse-platform:masterfrom
vogella:style-workspace-launcher-theme
Apr 14, 2026
Merged

Style workspace selection dialog with default theme setting#3855
vogella merged 1 commit intoeclipse-platform:masterfrom
vogella:style-workspace-launcher-theme

Conversation

@vogella
Copy link
Copy Markdown
Contributor

@vogella vogella commented Apr 2, 2026

This PR applies the user's preferred theme to the workspace selection dialog before the workbench and its ThemeEngine start up, so the dialog matches the IDE theme even at first launch.

Implementation:

  • initializeDefaultTheme() reads the theme preference scoped to the current product or application ID (with no cross-product fallback — if no product ID is present, the generic preference is used)
  • A display-level SWT.Show listener applies dark styles to any shell as it appears
  • createContents() in the ChooseWorkspaceDialog subclass applies styles a second time after all controls are constructed, catching widgets not yet present at SWT.Show time
  • Early styling is removed via resetEarlyDarkTheme() before the workbench starts so the ThemeEngine manages the theme from that point on
  • Color objects use the modern display-free Color(r, g, b) constructor

@vogella vogella force-pushed the style-workspace-launcher-theme branch 2 times, most recently from ff02108 to 2e637fb Compare April 2, 2026 13:06
@vogella vogella force-pushed the style-workspace-launcher-theme branch from 2e637fb to 61773fa Compare April 2, 2026 13:19
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 2, 2026

Fixed a crash introduced in the previous version of this commit.

The original code called PartRenderingEngine.initializeStyling() before the workspace picker is shown. That method internally accesses InstanceScope preferences, which requires the workspace location to be set — causing an IllegalStateException.

The fix uses IThemeManager.getEngineForDisplay() + IThemeEngine.setTheme() directly instead (the same pattern used by BootstrapTheme3x). This activates the CSS theme engine without touching instance-scoped preferences, so it works safely before workspace selection.

Also fixed: OSGi service reference now released via ungetService() in a finally block, and the org.eclipse.e4.ui.workbench.swt bundle dependency (which exposed internal API) is removed.

@vogella vogella force-pushed the style-workspace-launcher-theme branch from 61773fa to aa8df91 Compare April 2, 2026 13:43
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 2, 2026

Updated approach: dropped the CSS theme engine for the workspace dialog entirely.

The dark theme CSS uses symbolic color variables (#org-eclipse-ui-workbench-DARK_BACKGROUND etc.) that are resolved via ColorAndFontProviderImpl, which calls Workbench.getInstance().getThemeManager(). Since Workbench.getInstance() is null before the workbench starts, these colors can never resolve at this stage — so CSS styling of the pre-workspace dialog is not feasible.

New approach: if the configured theme ID contains "dark", directly set SWT colors on the dialog's widget tree using the literal RGB values from the dark theme CSS (#48484c background, #eeeeee foreground). Colors are allocated once on the shell and disposed via a DisposeListener.

@vogella vogella force-pushed the style-workspace-launcher-theme branch from aa8df91 to 175f350 Compare April 2, 2026 13:45
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 2, 2026

First iteration:

image

@vogella vogella force-pushed the style-workspace-launcher-theme branch from 175f350 to ae04fe3 Compare April 2, 2026 13:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Test Results

   852 files  ±0     852 suites  ±0   55m 27s ⏱️ - 4m 34s
 7 894 tests ±0   7 651 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 184 runs  ±0  19 529 ✅ ±0  655 💤 ±0  0 ❌ ±0 

Results for commit 6ef3929. ± Comparison against base commit f22f75c.

♻️ This comment has been updated with latest results.

@vogella vogella force-pushed the style-workspace-launcher-theme branch from ae04fe3 to 9388e35 Compare April 2, 2026 16:37
@vogella vogella mentioned this pull request Apr 2, 2026
@vogella vogella force-pushed the style-workspace-launcher-theme branch from 9388e35 to f8d5fb0 Compare April 2, 2026 16:44
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 2, 2026

Getter better:

image

@vogella vogella force-pushed the style-workspace-launcher-theme branch 3 times, most recently from 4dd9659 to 9df0418 Compare April 8, 2026 07:44
@vogella vogella force-pushed the style-workspace-launcher-theme branch 2 times, most recently from 8a5381a to d5a9ae8 Compare April 12, 2026 18:09
@vogella vogella marked this pull request as ready for review April 12, 2026 18:10
@vogella vogella force-pushed the style-workspace-launcher-theme branch 6 times, most recently from 02754cf to 37c8419 Compare April 13, 2026 22:06
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 13, 2026

image

Browse also uses the default theme:

image

@vogella vogella force-pushed the style-workspace-launcher-theme branch from 37c8419 to 49199aa Compare April 14, 2026 06:58
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 14, 2026

Test in a local Eclipse SDK build and I do not see any issues with it. Planning to merge today

@iloveeclipse iloveeclipse requested a review from Copilot April 14, 2026 08:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds early/default-theme-aware styling so the workspace selection UI (and other pre-workbench shells) can be styled consistently before the main ThemeEngine takes over.

Changes:

  • Initialize and apply a “default theme” (dark) preference early in IDEApplication.start(), including a temporary SWT.Show listener to style shells before workbench startup.
  • Explicitly style ExpandableComposite and Link controls in workspace selection dialogs to improve dark-mode appearance.
  • Update theme engine and bundle manifests to support/enable the behavior (including a newer SWT requirement in the theme bundle).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java Sets ExpandableComposite title/toggle colors to align with the dialog foreground.
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java Styles recent-workspaces ExpandableComposite twistie/title colors and sets link foreground.
bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java Adds early theme detection, temporary global shell styling, and explicit styling hook for the workspace dialog.
bundles/org.eclipse.ui.ide.application/META-INF/MANIFEST.MF Adds org.eclipse.ui.forms dependency used by new styling logic.
bundles/org.eclipse.e4.ui.css.swt.theme/src/org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine.java Updates display dark-preference whenever the theme changes.
bundles/org.eclipse.e4.ui.css.swt.theme/META-INF/MANIFEST.MF Raises the required SWT bundle version range.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

private void applyDarkStyles(Shell shell) {
Color bg = new Color(shell.getDisplay(), 72, 72, 76); // #48484c
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "modern" Color constructors like new Color(72, 72, 76)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (productOrAppId != null) {
defaultThemeId = themeNode.node(productOrAppId).get("themeid", null); //$NON-NLS-1$
}
if (defaultThemeId == null) {
Copy link
Copy Markdown
Member

@iloveeclipse iloveeclipse Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should if (defaultThemeId == null) be inside the "else" branch of the product?
Means, if product never defined the theme, now it can change the theme used because some other Eclipse based application defined the theme?

if (defaultThemeId == null) {
defaultThemeId = themeNode.get("themeid", null); //$NON-NLS-1$
}
isDark = defaultThemeId != null && defaultThemeId.contains("dark"); //$NON-NLS-1$
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultThemeId.contains("dark") seem to match only default theme id.
If product defines theme "com.my.product.themeid", there is not necessarily "dark" in the id but the theme can be "dark".

Ideally this could be extracted to a protected boolean isDarkTheme(String themeId)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is currently the way the theme engine detects a dark theme. We can make this more flexible here but the rest of theming engine will just look for the "dark" string so that would make this not aligned with the rest of the theming.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is currently the way the theme engine detects a dark theme

OMG

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The theming code is a pleasure to look at. Tons of unused abstraction in lots of places and lots of hard coded values in others.

@vogella vogella force-pushed the style-workspace-launcher-theme branch from 756a862 to ccb3003 Compare April 14, 2026 09:32
@iloveeclipse
Copy link
Copy Markdown
Member

Test in a local Eclipse SDK build and I do not see any issues with it. Planning to merge today

Given the fact that that "theming" is different on different platforms, it would be good if at least Windows & Mac behavior could be verified for this change upfront.

I've checked Linux with no themes and it seem to not break this use case. For the rest I don't have time.

When the user's preferred theme is dark, apply dark styling to the
workspace selection dialog before the workbench and its ThemeEngine
start up. This ensures the dialog matches the IDE theme even at
first launch.

Styling is applied in two passes:
- A display-level SWT.Show listener as an early pass when the shell
  first appears.
- In createContents() after all dialog controls are constructed, to
  catch dynamically created widgets not yet present at SWT.Show time.

Color objects use the modern display-free Color(r, g, b) constructor
rather than the deprecated Color(Display, r, g, b) form.
@vogella vogella force-pushed the style-workspace-launcher-theme branch from ccb3003 to 6ef3929 Compare April 14, 2026 09:58
@vogella
Copy link
Copy Markdown
Contributor Author

vogella commented Apr 14, 2026

Looks also good on Windows:

image image

Unfortunately no access to a Mac.

@vogella vogella merged commit 3466789 into eclipse-platform:master Apr 14, 2026
18 checks passed
@vogella vogella deleted the style-workspace-launcher-theme branch April 14, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants