Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Scholz2014-12-16 20:32:11 +0000
committerLars Vogel2015-01-08 09:02:53 +0000
commit9b58903d98a9c85379b836c057b94d514c238899 (patch)
treedab8021cc9fde552d76cea814c88f2db149d0f13
parent7728ea7d570e1ba4c0763d4dcc39e223219fcab0 (diff)
downloadeclipse.platform.ui-9b58903d98a9c85379b836c057b94d514c238899.tar.gz
eclipse.platform.ui-9b58903d98a9c85379b836c057b94d514c238899.tar.xz
eclipse.platform.ui-9b58903d98a9c85379b836c057b94d514c238899.zip
Bug 430370 - [CSS] Provide CSS handler for Forms Section element
Change-Id: I6b1a784afac77693cf70c1fb6b1222eee3cdc705 Signed-off-by: Simon Scholz <simon.scholz@vogella.com>
-rw-r--r--bundles/org.eclipse.ui.forms/META-INF/MANIFEST.MF6
-rw-r--r--bundles/org.eclipse.ui.forms/build.properties7
-rw-r--r--bundles/org.eclipse.ui.forms/plugin.xml29
-rw-r--r--bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/FormsElementProvider.java38
-rw-r--r--bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/SectionElement.java45
-rw-r--r--bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/properties/css2/CSSPropertyTitleFormsHandler.java66
6 files changed, 186 insertions, 5 deletions
diff --git a/bundles/org.eclipse.ui.forms/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.forms/META-INF/MANIFEST.MF
index d4397afa96c..40edd10407c 100644
--- a/bundles/org.eclipse.ui.forms/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.forms/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
-Bundle-SymbolicName: org.eclipse.ui.forms
+Bundle-SymbolicName: org.eclipse.ui.forms;singleton:=true
Bundle-Version: 3.6.100.qualifier
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
@@ -13,7 +13,9 @@ Export-Package: org.eclipse.ui.forms,
org.eclipse.ui.internal.forms.widgets;x-friends:="org.eclipse.ui.tests.forms"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.6.0,4.0.0)",
- org.eclipse.ui;bundle-version="[3.105.0,4.0.0)";resolution:=optional
+ org.eclipse.ui;bundle-version="[3.105.0,4.0.0)";resolution:=optional,
+ org.eclipse.e4.ui.css.core;bundle-version="0.10.100",
+ org.eclipse.e4.ui.css.swt;bundle-version="0.11.100"
Eclipse-LazyStart: true
Import-Package: com.ibm.icu.text,
javax.xml.parsers,
diff --git a/bundles/org.eclipse.ui.forms/build.properties b/bundles/org.eclipse.ui.forms/build.properties
index b5a06334aeb..c2219a02ad3 100644
--- a/bundles/org.eclipse.ui.forms/build.properties
+++ b/bundles/org.eclipse.ui.forms/build.properties
@@ -1,10 +1,10 @@
###############################################################################
-# Copyright (c) 2003, 2007 IBM Corporation and others.
+# Copyright (c) 2003, 2014 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
-#
+#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
@@ -12,6 +12,7 @@ bin.includes = plugin.properties,\
.,\
about.html,\
META-INF/,\
- icons/
+ icons/,\
+ plugin.xml
source.. = src/
src.includes = about.html
diff --git a/bundles/org.eclipse.ui.forms/plugin.xml b/bundles/org.eclipse.ui.forms/plugin.xml
new file mode 100644
index 00000000000..76edcfc8451
--- /dev/null
+++ b/bundles/org.eclipse.ui.forms/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.e4.ui.css.core.propertyHandler">
+ <handler
+ adapter="org.eclipse.ui.forms.css.dom.SectionElement"
+ composite="false"
+ handler="org.eclipse.ui.forms.css.properties.css2.CSSPropertyTitleFormsHandler">
+ <property-name
+ name="background-color-gradient-titlebar">
+ </property-name>
+ <property-name
+ name="background-color-titlebar">
+ </property-name>
+ <property-name
+ name="border-color-titlebar">
+ </property-name>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.e4.ui.css.core.elementProvider">
+ <provider
+ class="org.eclipse.ui.forms.css.dom.FormsElementProvider">
+ <widget
+ class="org.eclipse.ui.forms.widgets.Section"></widget>
+ </provider>
+ </extension>
+</plugin>
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/FormsElementProvider.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/FormsElementProvider.java
new file mode 100644
index 00000000000..c0b4f5d9366
--- /dev/null
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/FormsElementProvider.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2014 vogella GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lars Vogel <Lars.Vogel@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.forms.css.dom;
+
+import org.eclipse.e4.ui.css.core.dom.IElementProvider;
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.ui.forms.widgets.Section;
+import org.w3c.dom.Element;
+
+/**
+ * Returns the CSS class which is responsible for styling a forms widget
+ *
+ * Registered via the "org.eclipse.e4.ui.css.core.elementProvider" extension
+ * point for the widgets
+ *
+ * {@link IElementProvider} SWT implementation to retrieve w3c Element
+ *
+ */
+public class FormsElementProvider implements IElementProvider {
+
+ public static final IElementProvider INSTANCE = new FormsElementProvider();
+
+ public Element getElement(Object element, CSSEngine engine) {
+ if (element instanceof Section) {
+ return new SectionElement((Section) element, engine);
+ }
+
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/SectionElement.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/SectionElement.java
new file mode 100644
index 00000000000..7576fc37e51
--- /dev/null
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/dom/SectionElement.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2014 vogella GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lars Vogel <Lars.Vogel@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.forms.css.dom;
+
+import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.e4.ui.css.swt.dom.CompositeElement;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * {@link CSSStylableElement} implementation which wrap SWT {@link Section}.
+ *
+ */
+public class SectionElement extends CompositeElement {
+
+
+ private Color titleBarBackground;
+ private Color titleBarBorderColor;
+ private Color titleBarGradientBackground;
+
+ public SectionElement(Section section, CSSEngine engine) {
+ super(section, engine);
+ titleBarBackground = section.getTitleBarBackground();
+ titleBarBorderColor = section.getTitleBarBorderColor();
+ titleBarGradientBackground = section.getTitleBarGradientBackground();
+ }
+
+ public void reset() {
+ super.reset();
+ Section section = (Section) getWidget();
+ section.setTitleBarBackground(titleBarBackground);
+ section.setTitleBarBorderColor(titleBarBorderColor);
+ section.setTitleBarGradientBackground(titleBarGradientBackground);
+ }
+
+}
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/properties/css2/CSSPropertyTitleFormsHandler.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/properties/css2/CSSPropertyTitleFormsHandler.java
new file mode 100644
index 00000000000..92035bc40f6
--- /dev/null
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/css/properties/css2/CSSPropertyTitleFormsHandler.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2014 vogella GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lars Vogel <Lars.Vogel@gmail.com> - Bug 422702
+ * Simon Scholz <simon.scholz@vogella.com> - Bug 430370
+ *******************************************************************************/
+package org.eclipse.ui.forms.css.properties.css2;
+
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.Section;
+import org.w3c.dom.css.CSSValue;
+
+public class CSSPropertyTitleFormsHandler extends AbstractCSSPropertySWTHandler {
+
+ private static final String BACKGROUND_COLOR_GRADIENT_TITLEBAR_PROPERTY = "background-color-gradient-titlebar"; //$NON-NLS-1$
+ private static final String BACKGROUND_COLOR_TITLEBAR_PROPERTY = "background-color-titlebar"; //$NON-NLS-1$
+ private static final String BORDER_COLOR_TITLEBAR_PROPERTY = "border-color-titlebar"; //$NON-NLS-1$
+
+ protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine)
+ throws Exception {
+
+ if (BACKGROUND_COLOR_GRADIENT_TITLEBAR_PROPERTY.equalsIgnoreCase(property)) {
+ if (control instanceof Section) {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay());
+ ((Section) control).setTitleBarGradientBackground(newColor);
+ } else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
+
+ }
+ }
+ } else if (BACKGROUND_COLOR_TITLEBAR_PROPERTY.equalsIgnoreCase(property)) {
+ if (control instanceof Section) {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay());
+ ((Section) control).setTitleBarBackground(newColor);
+ } else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
+
+ }
+ }
+ } else if (BORDER_COLOR_TITLEBAR_PROPERTY.equalsIgnoreCase(property)) {
+ if (control instanceof Section) {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay());
+ ((Section) control).setTitleBarBorderColor(newColor);
+ } else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
+
+ }
+ }
+ }
+ }
+
+ protected String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine)
+ throws Exception {
+
+ return null;
+ }
+
+}

Back to the top