aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2012-03-25 22:01:53 -0400
committerBrian de Alwis2012-03-25 22:01:53 -0400
commitdf1c03fce34e53b69b11d512acb76821b5b0f883 (patch)
tree6b7f533aa2110da6b992bb844185c1474ad09fb2
parent39cafd6f245ef26afacbdea71c58711940b18ffa (diff)
downloadeclipse.platform.ui-df1c03fce34e53b69b11d512acb76821b5b0f883.zip
eclipse.platform.ui-df1c03fce34e53b69b11d512acb76821b5b0f883.tar.gz
eclipse.platform.ui-df1c03fce34e53b69b11d512acb76821b5b0f883.tar.xz
Bug 375282 - [CSS] Add support for Composite.setBackgroundMode()v20120326-0201
Add new 'swt-background-mode' property to get/set the background mode on Composites/Shells where 'none' is SWT.INHERIT_NONE, 'force' is SWT.INHERIT_FORCE, and 'default' is SWT.INHERIT_DEFAULT.
-rw-r--r--bundles/org.eclipse.e4.ui.css.swt/plugin.xml7
-rw-r--r--bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSBackgroundModePropertyHandler.java49
-rw-r--r--examples/org.eclipse.e4.demo.contacts/css/blue-gradient.css1
-rw-r--r--examples/org.eclipse.e4.demo.contacts/css/bright-gradient.css1
-rw-r--r--examples/org.eclipse.e4.demo.contacts/css/dark-gradient.css1
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java5
6 files changed, 64 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
index cdf7c5c..d3c6d49 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
+++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
@@ -440,6 +440,13 @@
name="padding-bottom">
</property-name>
</handler>
+ <handler
+ adapter="org.eclipse.e4.ui.css.swt.dom.CompositeElement"
+ handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSBackgroundModePropertyHandler">
+ <property-name
+ name="swt-background-mode">
+ </property-name>
+ </handler>
</extension>
diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSBackgroundModePropertyHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSBackgroundModePropertyHandler.java
new file mode 100644
index 0000000..5c346ca
--- /dev/null
+++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSBackgroundModePropertyHandler.java
@@ -0,0 +1,49 @@
+package org.eclipse.e4.ui.css.swt.properties.custom;
+
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.w3c.dom.css.CSSValue;
+
+public class CSSBackgroundModePropertyHandler extends
+ AbstractCSSPropertySWTHandler {
+
+ @Override
+ protected void applyCSSProperty(Control control, String property,
+ CSSValue value, String pseudo, CSSEngine engine) throws Exception {
+ if (value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE) {
+ return;
+ }
+ if (control instanceof Composite) {
+ Composite composite = (Composite) control;
+ String stringValue = value.getCssText().toLowerCase();
+ if ("default".equalsIgnoreCase(stringValue)) {
+ composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ } else if ("force".equalsIgnoreCase(stringValue)) {
+ composite.setBackgroundMode(SWT.INHERIT_FORCE);
+ } else if ("none".equalsIgnoreCase(stringValue)) {
+ composite.setBackgroundMode(SWT.INHERIT_NONE);
+ }
+ }
+ }
+
+ @Override
+ protected String retrieveCSSProperty(Control control, String property,
+ String pseudo, CSSEngine engine) throws Exception {
+ if (control instanceof Composite) {
+ Composite composite = (Composite) control;
+ switch (composite.getBackgroundMode()) {
+ case SWT.INHERIT_DEFAULT:
+ return "default";
+ case SWT.INHERIT_FORCE:
+ return "force";
+ case SWT.INHERIT_NONE:
+ return "none";
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.e4.demo.contacts/css/blue-gradient.css b/examples/org.eclipse.e4.demo.contacts/css/blue-gradient.css
index 35c1cc4..a604fff 100644
--- a/examples/org.eclipse.e4.demo.contacts/css/blue-gradient.css
+++ b/examples/org.eclipse.e4.demo.contacts/css/blue-gradient.css
@@ -75,4 +75,5 @@ CTabItem.active:selected {
Shell {
background-color: #e3efff #c1d5ef 60%;
+ swt-background-mode: default;
}
diff --git a/examples/org.eclipse.e4.demo.contacts/css/bright-gradient.css b/examples/org.eclipse.e4.demo.contacts/css/bright-gradient.css
index 1f210f2..11e944a 100644
--- a/examples/org.eclipse.e4.demo.contacts/css/bright-gradient.css
+++ b/examples/org.eclipse.e4.demo.contacts/css/bright-gradient.css
@@ -75,4 +75,5 @@ CTabItem.active:selected {
Shell {
background-color: #e8e8e8 #cccccc 60%;
+ swt-background-mode: default;
}
diff --git a/examples/org.eclipse.e4.demo.contacts/css/dark-gradient.css b/examples/org.eclipse.e4.demo.contacts/css/dark-gradient.css
index 6443929..a6ba01d 100644
--- a/examples/org.eclipse.e4.demo.contacts/css/dark-gradient.css
+++ b/examples/org.eclipse.e4.demo.contacts/css/dark-gradient.css
@@ -72,5 +72,6 @@ CTabItem.active:selected {
}
Shell {
+ swt-background-mode: default;
background-color: gradient radial #575757 #101010 60%;
}
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java
index 97c64ed..1c2518e 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java
@@ -211,4 +211,9 @@ public class ShellTest extends CSSSWTTestCase {
assertEquals(SWT.ITALIC, fontData.getStyle());
}
+ public void testBackgroundMode() throws Exception {
+ Shell shellToTest = createTestShell("Shell { swt-background-mode: force; }");
+ assertEquals(SWT.INHERIT_FORCE, shellToTest.getBackgroundMode());
+ }
+
} \ No newline at end of file