From 845377a245d979d94f16f3fa7c881cf524f66ecb Mon Sep 17 00:00:00 2001 From: Matthias Becker Date: Tue, 29 Oct 2024 10:28:52 +0100 Subject: [PATCH] CSS: Allow Color And Font Definitions To Be Marked As Not Editable Color and Fonts can be defined as not editable if done via the extensions point. Provide the same possibility if they are defined via CSS. --- bundles/org.eclipse.e4.ui.css.swt/plugin.xml | 1 + .../CSSPropertyThemeElementDefinitionHandler.java | 6 ++++++ .../swt/definition/IThemeElementDefinitionOverridable.java | 2 ++ .../org/eclipse/ui/internal/themes/ColorDefinition.java | 6 ++++++ .../org/eclipse/ui/internal/themes/FontDefinition.java | 5 +++++ 5 files changed, 20 insertions(+) diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml index 5a16ca7c001..1ad4315b24f 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml +++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml @@ -494,6 +494,7 @@ + bundleToResourceBundles = new WeakHashMap<>(); @Override @@ -65,6 +67,10 @@ public boolean applyCSSProperty(Object element, String property, case DESCRIPTION_PROP: definition.setDescription(getLabel(value)); break; + case EDITABLE_PROP: + Boolean editable = (Boolean) engine.convert(value, Boolean.class, null); + definition.setEditable(editable); + break; default: return false; } diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/internal/css/swt/definition/IThemeElementDefinitionOverridable.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/internal/css/swt/definition/IThemeElementDefinitionOverridable.java index 2d7c5424930..37c041e471d 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/internal/css/swt/definition/IThemeElementDefinitionOverridable.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/internal/css/swt/definition/IThemeElementDefinitionOverridable.java @@ -27,4 +27,6 @@ public interface IThemeElementDefinitionOverridable { void setName(String name); void setDescription(String description); + + void setEditable(Boolean editable); } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorDefinition.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorDefinition.java index 3a5fcb2b7a8..35e00089bc6 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorDefinition.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorDefinition.java @@ -155,4 +155,10 @@ public void setValue(RGB data) { appendState(State.OVERRIDDEN); } } + + @Override + public void setEditable(Boolean editable) { + isEditable = editable; + } + } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/FontDefinition.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/FontDefinition.java index 71c92d402a8..18c5502860f 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/FontDefinition.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/FontDefinition.java @@ -138,4 +138,9 @@ public void setValue(FontData[] data) { appendState(State.OVERRIDDEN); } } + + @Override + public void setEditable(Boolean editable) { + isEditable = editable; + } }