Skip to content

Commit f8d5fb0

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

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Export-Package: org.eclipse.e4.ui.internal.workbench.swt;
3939
x-friends:="org.eclipse.e4.ui.workbench.addons.swt,
4040
org.eclipse.e4.ui.workbench.renderers.swt,
4141
org.eclipse.ui.workbench,
42-
org.eclipse.e4.ui.bindings.tests",
42+
org.eclipse.e4.ui.bindings.tests,
43+
org.eclipse.ui.ide.application",
4344
org.eclipse.e4.ui.internal.workbench.swt.handlers;x-internal:=true,
4445
org.eclipse.e4.ui.workbench.swt,
4546
org.eclipse.e4.ui.workbench.swt.factories;x-friends:="org.eclipse.e4.ui.workbench.renderers.swt,org.eclipse.ui.workbench",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ 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,
24+
org.eclipse.e4.ui.workbench.swt
2325
Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true,
2426
org.eclipse.ui.internal.ide.application.addons;x-internal:=true,
2527
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
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.core.contexts.EclipseContextFactory;
47+
import org.eclipse.e4.core.contexts.IEclipseContext;
48+
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
49+
import org.eclipse.e4.ui.css.swt.theme.IThemeManager;
50+
import org.eclipse.e4.ui.internal.workbench.swt.E4Application;
51+
import org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine;
4552
import org.eclipse.equinox.app.IApplication;
4653
import org.eclipse.equinox.app.IApplicationContext;
4754
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -71,6 +78,9 @@
7178
import org.eclipse.ui.internal.ide.StatusUtil;
7279
import org.eclipse.ui.preferences.ScopedPreferenceStore;
7380
import org.osgi.framework.Bundle;
81+
import org.osgi.framework.BundleContext;
82+
import org.osgi.framework.FrameworkUtil;
83+
import org.osgi.framework.ServiceReference;
7484
import org.osgi.framework.Version;
7585

7686
/**
@@ -94,6 +104,8 @@ public class IDEApplication implements IApplication, IExecutableExtension {
94104

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

107+
private IThemeEngine themeEngine;
108+
97109
// Use the branding plug-in of the platform feature since this is most likely
98110
// to change on an update of the IDE.
99111
private static final String WORKSPACE_CHECK_REFERENCE_BUNDLE_NAME = "org.eclipse.platform"; //$NON-NLS-1$
@@ -145,6 +157,35 @@ public Object start(IApplicationContext appContext) throws Exception {
145157
Job.getJobManager().suspend();
146158

147159
Display display = createDisplay();
160+
161+
IEclipsePreferences configurationScopeNode = ConfigurationScope.INSTANCE
162+
.getNode("org.eclipse.e4.ui.css.swt.theme"); //$NON-NLS-1$
163+
String defaultThemeId = configurationScopeNode.get("themeid", null); //$NON-NLS-1$
164+
if (defaultThemeId != null) {
165+
IEclipseContext tempContext = EclipseContextFactory.create();
166+
tempContext.set(E4Application.THEME_ID, defaultThemeId);
167+
PartRenderingEngine.initializeStyling(display, tempContext);
168+
169+
Bundle bundle = FrameworkUtil.getBundle(IThemeManager.class);
170+
if (bundle != null) {
171+
BundleContext bundleContext = bundle.getBundleContext();
172+
ServiceReference<IThemeManager> ref = bundleContext.getServiceReference(IThemeManager.class);
173+
if (ref != null) {
174+
IThemeManager mgr = bundleContext.getService(ref);
175+
if (mgr != null) {
176+
themeEngine = mgr.getEngineForDisplay(display);
177+
if (themeEngine != null) {
178+
display.addListener(SWT.Show, event -> {
179+
if (event.widget instanceof Shell shell) {
180+
themeEngine.applyStyles(shell, true);
181+
}
182+
});
183+
}
184+
}
185+
}
186+
}
187+
}
188+
148189
// processor must be created before we start event loop
149190
DelayedEventsProcessor processor = new DelayedEventsProcessor(display);
150191

@@ -587,6 +628,14 @@ protected Shell getParentShell() {
587628
return null;
588629
}
589630

631+
@Override
632+
protected Control createContents(Composite parent) {
633+
Control contents = super.createContents(parent);
634+
if (themeEngine != null) {
635+
themeEngine.applyStyles(getShell(), true);
636+
}
637+
return contents;
638+
}
590639
}.prompt(force);
591640
}
592641

bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.eclipse.jface.dialogs.IDialogConstants;
4040
import org.eclipse.jface.dialogs.IDialogSettings;
4141
import org.eclipse.jface.dialogs.TitleAreaDialog;
42+
import org.eclipse.jface.resource.JFaceColors;
4243
import org.eclipse.jface.util.Geometry;
4344
import org.eclipse.jface.window.Window;
4445
import org.eclipse.osgi.util.NLS;
@@ -319,6 +320,7 @@ private void createRecentWorkspacesComposite(final Composite composite) {
319320
recentWorkspacesForm.getBody().setLayout(new GridLayout());
320321
ExpandableComposite recentWorkspacesExpandable = toolkit.createExpandableComposite(recentWorkspacesForm.getBody(),
321322
ExpandableComposite.TWISTIE);
323+
recentWorkspacesExpandable.setTitleBarForeground(composite.getForeground());
322324
recentWorkspacesForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
323325
recentWorkspacesExpandable.setBackground(composite.getBackground());
324326
recentWorkspacesExpandable.setText(IDEWorkbenchMessages.ChooseWorkspaceDialog_recentWorkspaces);
@@ -352,6 +354,7 @@ public void expansionStateChanged(ExpansionEvent e) {
352354
final String recentWorkspace = uniqueWorkspaceEntry.getValue();
353355

354356
Link link = new Link(panel, SWT.WRAP);
357+
link.setForeground(JFaceColors.getHyperlink(composite.getDisplay()));
355358
link.setLayoutData(new RowData(SWT.DEFAULT, SWT.DEFAULT));
356359
link.setText("<a>" + uniqueWorkspaceEntry.getKey() + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
357360
link.setToolTipText(recentWorkspace);

bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ private void createSettingsControls(Composite workArea) {
128128

129129
copySettingsExpandable.setText(IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SettingsGroupName);
130130
copySettingsExpandable.setBackground(workArea.getBackground());
131+
copySettingsExpandable.setTitleBarForeground(workArea.getForeground());
131132
copySettingsExpandable.setLayout(new GridLayout());
132133
copySettingsExpandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
133134
copySettingsExpandable.addExpansionListener(new IExpansionListener() {

0 commit comments

Comments
 (0)