Skip to content

Commit 61773fa

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

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-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: 41 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,31 @@ 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+
try {
167+
IThemeManager mgr = bundleContext.getService(ref);
168+
if (mgr != null) {
169+
themeEngine = mgr.getEngineForDisplay(display);
170+
if (themeEngine != null) {
171+
themeEngine.setTheme(defaultThemeId, false);
172+
}
173+
}
174+
} finally {
175+
bundleContext.ungetService(ref);
176+
}
177+
}
178+
}
179+
}
180+
148181
// processor must be created before we start event loop
149182
DelayedEventsProcessor processor = new DelayedEventsProcessor(display);
150183

@@ -587,6 +620,14 @@ protected Shell getParentShell() {
587620
return null;
588621
}
589622

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

0 commit comments

Comments
 (0)