From adecc5c15bbc5f47db2151de97f6e77e1f68b0d2 Mon Sep 17 00:00:00 2001 From: Elsa Zacharia Date: Thu, 20 Nov 2025 12:14:09 +0530 Subject: [PATCH] Add missing descriptions to Colors and Fonts theme entries Some Colors and Fonts entries already provide user-facing descriptions via ThemeElementCategory, while others do not. This change uses the existing descriptions to display in the description box and adds description for ones that doesn't have any entries to ensure the description area is not left empty and that available descriptions are consistently utilised. This aligns with the standard usage elsewhere in Eclipse preference pages. --- .../themes/ColorsAndFontsPreferencePage.java | 23 +++++++++++++++++++ .../plugin.properties | 2 ++ .../org.eclipse.e4.demo.cssbridge/plugin.xml | 12 ++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java index c688fcebda73..4fccb95af229 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java @@ -1959,6 +1959,17 @@ private void editColor(ColorDefinition definition, Display display) { } } + private ThemeElementCategory getCategory() { + IStructuredSelection item = (IStructuredSelection) tree.getViewer().getSelection(); + if (item != null && !item.isEmpty()) { + Object object = item.getFirstElement(); + if (object instanceof ThemeElementCategory) { + return (ThemeElementCategory) object; + } + } + return null; + } + protected void updateControls() { FontDefinition fontDefinition = getSelectedFontDefinition(); if (fontDefinition != null) { @@ -1984,6 +1995,18 @@ protected void updateControls() { setCurrentColor(colorDefinition); return; } + ThemeElementCategory category = getCategory(); + if (category != null) { + fontChangeButton.setEnabled(false); + fontSystemButton.setEnabled(false); + fontResetButton.setEnabled(false); + editDefaultButton.setEnabled(false); + goToDefaultButton.setEnabled(false); + + String desc = category.getDescription() != null ? category.getDescription() : ""; //$NON-NLS-1$ + descriptionText.setText(desc); + return; + } // not a font or a color? fontChangeButton.setEnabled(false); fontSystemButton.setEnabled(false); diff --git a/examples/org.eclipse.e4.demo.cssbridge/plugin.properties b/examples/org.eclipse.e4.demo.cssbridge/plugin.properties index 4d81185dd0c2..5d1e2357a8a2 100644 --- a/examples/org.eclipse.e4.demo.cssbridge/plugin.properties +++ b/examples/org.eclipse.e4.demo.cssbridge/plugin.properties @@ -19,6 +19,8 @@ org.eclipse.e4.demo.cssbridge.blue.theme=Blue theme org.eclipse.e4.demo.cssbridge.green.theme=Green theme org.eclipse.e4.demo.cssbridge.red.theme=Red theme +org.eclipse.e4.demo.cssbridge.ui.views.Theme.description= Colors and fonts used to demonstrate CSS based UI styling. + org.eclipse.e4.demo.cssbridge.ui.views.Theme=CSS bridge demo theme org.eclipse.e4.demo.cssbridge.ui.views.theme.shell.background=Shell background org.eclipse.e4.demo.cssbridge.ui.views.theme.shell.selection.foreground=Shell selection foreground diff --git a/examples/org.eclipse.e4.demo.cssbridge/plugin.xml b/examples/org.eclipse.e4.demo.cssbridge/plugin.xml index 2f4eefd3db91..05d006814a0a 100644 --- a/examples/org.eclipse.e4.demo.cssbridge/plugin.xml +++ b/examples/org.eclipse.e4.demo.cssbridge/plugin.xml @@ -109,10 +109,14 @@ - - + + + %org.eclipse.e4.demo.cssbridge.ui.views.Theme.description + + +