Skip to content

Commit ff02108

Browse files
committed
Style workspace selection dialog with default theme setting
1 parent bff29fd commit ff02108

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

bundles/org.eclipse.ui.ide.application/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.21.0,4.0.0)",
1919
org.eclipse.e4.core.services;bundle-version="2.4.0",
2020
org.eclipse.e4.core.contexts;bundle-version="[1.12.0,2.0.0)",
2121
org.eclipse.urischeme;bundle-version="[1.3.0,2.0.0)",
22-
org.eclipse.e4.ui.di
22+
org.eclipse.e4.ui.di,
23+
org.eclipse.e4.ui.css.swt.theme
2324
Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true,
2425
org.eclipse.ui.internal.ide.application.addons;x-internal:=true,
2526
org.eclipse.ui.internal.ide.application.dialogs;x-internal:=true

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
import org.eclipse.core.runtime.Status;
4343
import org.eclipse.core.runtime.jobs.Job;
4444
import org.eclipse.core.runtime.preferences.ConfigurationScope;
45+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
46+
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
47+
import org.eclipse.e4.ui.css.swt.theme.IThemeManager;
4548
import org.eclipse.equinox.app.IApplication;
4649
import org.eclipse.equinox.app.IApplicationContext;
4750
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -71,6 +74,9 @@
7174
import org.eclipse.ui.internal.ide.StatusUtil;
7275
import org.eclipse.ui.preferences.ScopedPreferenceStore;
7376
import org.osgi.framework.Bundle;
77+
import org.osgi.framework.BundleContext;
78+
import org.osgi.framework.FrameworkUtil;
79+
import org.osgi.framework.ServiceReference;
7480
import org.osgi.framework.Version;
7581

7682
/**
@@ -94,6 +100,8 @@ public class IDEApplication implements IApplication, IExecutableExtension {
94100

95101
private static final String USER_NAME = "user.name"; //$NON-NLS-1$
96102

103+
private IThemeEngine themeEngine;
104+
97105
// Use the branding plug-in of the platform feature since this is most likely
98106
// to change on an update of the IDE.
99107
private static final String WORKSPACE_CHECK_REFERENCE_BUNDLE_NAME = "org.eclipse.platform"; //$NON-NLS-1$
@@ -145,6 +153,32 @@ public Object start(IApplicationContext appContext) throws Exception {
145153
Job.getJobManager().suspend();
146154

147155
Display display = createDisplay();
156+
157+
IEclipsePreferences configurationScopeNode = ConfigurationScope.INSTANCE
158+
.getNode("org.eclipse.e4.ui.css.swt.theme"); //$NON-NLS-1$
159+
String defaultThemeId = configurationScopeNode.get("themeid", null); //$NON-NLS-1$
160+
if (defaultThemeId != null) {
161+
Bundle bundle = FrameworkUtil.getBundle(IThemeManager.class);
162+
if (bundle != null) {
163+
BundleContext bundleContext = bundle.getBundleContext();
164+
ServiceReference<IThemeManager> ref = bundleContext.getServiceReference(IThemeManager.class);
165+
if (ref != null) {
166+
IThemeManager mgr = bundleContext.getService(ref);
167+
if (mgr != null) {
168+
themeEngine = mgr.getEngineForDisplay(display);
169+
if (themeEngine != null) {
170+
themeEngine.setTheme(defaultThemeId, false);
171+
display.addListener(SWT.Show, event -> {
172+
if (event.widget instanceof Shell shell) {
173+
themeEngine.applyStyles(shell, true);
174+
}
175+
});
176+
}
177+
}
178+
}
179+
}
180+
}
181+
148182
// processor must be created before we start event loop
149183
DelayedEventsProcessor processor = new DelayedEventsProcessor(display);
150184

@@ -587,6 +621,14 @@ protected Shell getParentShell() {
587621
return null;
588622
}
589623

624+
@Override
625+
protected Control createContents(Composite parent) {
626+
Control contents = super.createContents(parent);
627+
if (themeEngine != null) {
628+
themeEngine.applyStyles(getShell(), true);
629+
}
630+
return contents;
631+
}
590632
}.prompt(force);
591633
}
592634

0 commit comments

Comments
 (0)