Skip to content

Commit 215b38e

Browse files
committed
Show product/application info in Manage Default Theme dialog
The dialog now displays which product or application the default theme applies to, making it transparent that theme defaults are scoped. Examples: - With product: 'Current default theme for Eclipse SDK (org.eclipse.sdk.ide): Dark' - Without product: 'Current default theme for org.eclipse.ui.ide.workbench (org.eclipse.ui.ide.workbench): Dark' - Without either: falls back to unscoped messages
1 parent ef95078 commit 215b38e

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,20 @@ private void setCSSContextVariables(IApplicationContext applicationContext, IEcl
317317
: getArgValue(E4Application.THEME_ID, applicationContext, false);
318318

319319
if (!themeId.isPresent() && !cssURI.isPresent()) {
320-
IEclipsePreferences themeNode = UserScope.INSTANCE
321-
.getNode("org.eclipse.e4.ui.css.swt.theme");
322-
String productOrAppId = getProductOrApplicationId();
323-
String defaultThemeId = null;
324-
if (productOrAppId != null) {
325-
defaultThemeId = themeNode.node(productOrAppId).get("themeid", null);
326-
}
327-
if (defaultThemeId == null) {
328-
defaultThemeId = DEFAULT_THEME_ID;
320+
String defaultThemeId = getProductScopedThemeId();
321+
if (defaultThemeId != null) {
322+
context.set(E4Application.THEME_ID, defaultThemeId);
323+
} else {
324+
context.set(E4Application.THEME_ID, DEFAULT_THEME_ID);
329325
}
330-
context.set(E4Application.THEME_ID, defaultThemeId);
331326
} else {
332-
context.set(E4Application.THEME_ID, themeId.orElseGet(() -> null));
327+
// Check if user has overridden the branding/command-line theme
328+
String userThemeId = getProductScopedThemeId();
329+
if (userThemeId != null) {
330+
context.set(E4Application.THEME_ID, userThemeId);
331+
} else {
332+
context.set(E4Application.THEME_ID, themeId.orElseGet(() -> null));
333+
}
333334
}
334335

335336

@@ -423,6 +424,20 @@ private static String getProductOrApplicationId() {
423424
return System.getProperty("eclipse.application"); //$NON-NLS-1$
424425
}
425426

427+
/**
428+
* Returns the user's product-scoped theme preference, or {@code null} if
429+
* none is set.
430+
*/
431+
private static String getProductScopedThemeId() {
432+
String productOrAppId = getProductOrApplicationId();
433+
if (productOrAppId != null) {
434+
IEclipsePreferences themeNode = UserScope.INSTANCE
435+
.getNode("org.eclipse.e4.ui.css.swt.theme");
436+
return themeNode.node(productOrAppId).get("themeid", null);
437+
}
438+
return null;
439+
}
440+
426441
/**
427442
* Finds an argument's value in the app's command line arguments, branding,
428443
* and system properties

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WorkbenchMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public class WorkbenchMessages extends NLS {
5555
public static String ThemeDefault_dialogTitle;
5656
public static String ThemeDefault_description;
5757
public static String ThemeDefault_currentDefault;
58+
public static String ThemeDefault_currentDefaultUnscoped;
5859
public static String ThemeDefault_noDefault;
60+
public static String ThemeDefault_noDefaultUnscoped;
5961
public static String ThemeDefault_setDefault;
6062
public static String ThemeDefault_removeDefault;
6163

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,24 @@ private void openManageDefaultThemeDialog() {
359359
}
360360
}
361361

362+
String productDisplayName = getProductDisplayName();
363+
362364
String message;
363365
if (currentDefaultLabel != null) {
364-
message = NLS.bind(WorkbenchMessages.ThemeDefault_currentDefault, currentDefaultLabel);
366+
if (productOrAppId != null) {
367+
String displayName = productDisplayName != null ? productDisplayName : productOrAppId;
368+
message = NLS.bind(WorkbenchMessages.ThemeDefault_currentDefault, new Object[] { currentDefaultLabel,
369+
displayName, productOrAppId });
370+
} else {
371+
message = NLS.bind(WorkbenchMessages.ThemeDefault_currentDefaultUnscoped, currentDefaultLabel);
372+
}
365373
} else {
366-
message = WorkbenchMessages.ThemeDefault_noDefault;
374+
if (productOrAppId != null) {
375+
String displayName = productDisplayName != null ? productDisplayName : productOrAppId;
376+
message = NLS.bind(WorkbenchMessages.ThemeDefault_noDefault, displayName, productOrAppId);
377+
} else {
378+
message = WorkbenchMessages.ThemeDefault_noDefaultUnscoped;
379+
}
367380
}
368381
message = WorkbenchMessages.ThemeDefault_description + "\n\n" + message; //$NON-NLS-1$
369382

@@ -411,6 +424,18 @@ private static String getProductOrApplicationId() {
411424
return System.getProperty("eclipse.application"); //$NON-NLS-1$
412425
}
413426

427+
/**
428+
* Returns the product name if a product is configured, or {@code null}
429+
* otherwise.
430+
*/
431+
private static String getProductDisplayName() {
432+
IProduct product = Platform.getProduct();
433+
if (product != null) {
434+
return product.getName();
435+
}
436+
return null;
437+
}
438+
414439
@Override
415440
public void init(IWorkbench workbench) {
416441
MApplication application = workbench.getService(MApplication.class);

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/messages.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,10 @@ ThemeChangeWarningTitle = Theme Changed
503503
ThemeDefault_manageButton = Manage &default...
504504
ThemeDefault_dialogTitle = Manage Default Theme
505505
ThemeDefault_description = The default theme is used for new workspaces and workspaces in which no explicit theme has been set.
506-
ThemeDefault_currentDefault = Current default theme: {0}
507-
ThemeDefault_noDefault = No default theme configured. The product default will be used.
506+
ThemeDefault_currentDefault = Current default theme for {1} ({2}): {0}
507+
ThemeDefault_currentDefaultUnscoped = Current default theme: {0}
508+
ThemeDefault_noDefault = No default theme configured for {0} ({1}). The product default will be used.
509+
ThemeDefault_noDefaultUnscoped = No default theme configured. The product default will be used.
508510
ThemeDefault_setDefault = &Set current theme as default
509511
ThemeDefault_removeDefault = &Remove default
510512
RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed

0 commit comments

Comments
 (0)